Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Update dependency management #69

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .yamllint

This file was deleted.

File renamed without changes.
14 changes: 14 additions & 0 deletions Makefile
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
34 changes: 22 additions & 12 deletions README.md
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.
Expand All @@ -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
Expand Down
File renamed without changes.
926 changes: 926 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions pyproject.toml
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"
5 changes: 0 additions & 5 deletions requirements.in

This file was deleted.

125 changes: 0 additions & 125 deletions requirements.txt

This file was deleted.

Loading