-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee3cbb1
commit 016c6c8
Showing
9 changed files
with
984 additions
and
148 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.PHONY: all clean | ||
|
||
CMD:=poetry run | ||
ANSIBLE_PLAYBOOK_ENTRYPOINT:=config.yml | ||
|
||
all: lint | ||
|
||
lint: | ||
$(CMD) ansible-playbook --syntax-check $(ANSIBLE_PLAYBOOK_ENTRYPOINT) | ||
$(CMD) yamllint -sc .yamllint.yml . | ||
$(CMD) ansible-lint $(ANSIBLE_PLAYBOOK_ENTRYPOINT) | ||
|
||
clean: | ||
git clean -Xdf # Delete all files in .gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,33 @@ | ||
# SOWN Ansible | ||
Role-based Ansible configuration | ||
|
||
## Usage | ||
This is the ansible playbook for SOWN. | ||
|
||
### Getting your own copy of ansible | ||
You must install the exact version of ansible we are using: | ||
``` | ||
python3 -m venv venv | ||
./venv/bin/pip3 install -r requirements.txt | ||
``` | ||
It contains a number of roles and applies them to hosts according to information from our | ||
Netbox server. | ||
|
||
## Usage | ||
|
||
### Cloning the repo | ||
|
||
You need to include submodules to get monitoring scripts as well: | ||
```console | ||
user@sown-auth2:~$ git clone --recurse-submodules [email protected]:sown/ansible.git | ||
$ git clone --recurse-submodules [email protected]:sown/ansible.git | ||
Cloning into 'ansible'... | ||
... | ||
``` | ||
|
||
### Installing Dependencies | ||
|
||
You must install the exact version of ansible we are using. | ||
|
||
The easiest way to do this is using [poetry](https://python-poetry.org/docs/#installing-with-pipx) | ||
|
||
Poetry 1.8 or later is required. | ||
|
||
```console | ||
poetry install | ||
``` | ||
|
||
### Netbox setup | ||
|
||
You'll need a netbox token stored in the `NETBOX_TOKEN` environment variable. | ||
|
@@ -30,22 +39,23 @@ You can create one through the Netbox admin interface, or steal one from `/home/ | |
|
||
This will run everything, but won't make changes, and print a full diffs of changes that would be made. | ||
```console | ||
user@sown-auth2:~/ansible$ sudo -E ~/ansible/venv/bin/ansible-playbook playbook.yml --diff --check | ||
$ sudo -E ansible-playbook playbook.yml --diff --check | ||
``` | ||
Remove `--check` to actually make changes. | ||
|
||
### Running against a single host | ||
|
||
```console | ||
user@sown-auth2:~/ansible$ sudo -E ~/ansible/venv/bin/ansible-playbook playbook.yml --diff --check --limit VMS | ||
$ sudo -E ansible-playbook playbook.yml --diff --check --limit VMS | ||
``` | ||
You can run this (without `--check`) against a new host to set it up with standard SOWN configuration. | ||
|
||
### Running a single role via tags | ||
|
||
It can take a while to run everything, so you can selectively run parts of our ansible configuration via tags. See the documentation below for tags you can use. | ||
|
||
```console | ||
user@sown-auth2:~/ansible$ sudo -E ~/ansible/venv/bin/ansible-playbook playbook.yml --diff --check --tags pxe | ||
$ sudo -E ansible-playbook playbook.yml --diff --check --tags pxe | ||
``` | ||
|
||
## Working on roles | ||
|
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[tool.poetry] | ||
name = "sown-ansible" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["Your Name <[email protected]>"] | ||
license = "MIT" | ||
readme = "README.md" | ||
package-mode = false | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.10" | ||
ansible = "^9.3.0" | ||
pytz = "^2024.1" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
ansible-compat = "<4" | ||
ansible-lint = "^6.8.7" | ||
yamllint = "^1.35.1" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.