Skip to content

Commit

Permalink
roles.py: script to replace Ansible Galaxy
Browse files Browse the repository at this point in the history
Usage:
```
usage: roles.py [-h] [-f FILTER] [-w WORKERS] [-r REQUIREMENTS] [-s ROLES_SYMLINK] [-l LOG_LEVEL] [-d] [-a] [-i | -c | -u]

This tool managed Ansible roles as Git repositories.
It is both faster and simpler than Ansible Galaxy.

By default ~/.ansible/roles is symlinked to ~/work.
Override it using --roles-symlink or ROLES_SYMLINK.

Installation behavior:
- If no version is specified newest is pulled.
- If version is matching nothing is done.
- If repo is dirty or detached nothing is done.
- If version is newer user is notified.

options:
  -h, --help            show this help message and exit
  -f FILTER, --filter FILTER
                        Filter role repo names.
  -w WORKERS, --workers WORKERS
                        Max workers to run in parallel.
  -r REQUIREMENTS, --requirements REQUIREMENTS
                        Location of requirements.yml file.
  -s ROLES_SYMLINK, --roles-symlink ROLES_SYMLINK
                        Actual location of installed roles.
  -l LOG_LEVEL, --log-level LOG_LEVEL
                        Logging level.
  -d, --fail-dirty      Fail if repo is dirty.
  -a, --fail-detached   Fail if repo has detached head.
  -i, --install         Clone and update required roles.
  -c, --check           Only check roles, no installing.
  -u, --update          Update requirements with current commits.

Examples:
./roles.py --install
./roles.py --check
./roles.py --update
```

Signed-off-by: Jakub Sokołowski <[email protected]>
  • Loading branch information
jakubgs committed Jun 12, 2024
1 parent 23d0813 commit d8c8bf0
Show file tree
Hide file tree
Showing 4 changed files with 409 additions and 84 deletions.
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ PROVISIONER_ARCHIVE = $(PROVISIONER_NAME)-$(subst _,-,$(ARCH))_$(PROVISIONER_VER
PROVISIONER_URL = https://github.com/radekg/terraform-provisioner-ansible/releases/download/$(PROVISIONER_VERSION)/$(PROVISIONER_ARCHIVE)
PROVISIONER_PATH = $(TF_PLUGINS_DIR)/$(ARCH)/$(PROVISIONER_NAME)_$(PROVISIONER_VERSION)

all: requirements install-provisioner secrets init-terraform
all: roles install-provisioner secrets init-terraform
@echo "Success!"

requirements-install:
ansible-galaxy install --keep-scm-meta --ignore-errors --force -r ansible/requirements.yml
roles-install:
ansible/roles.py --install

requirements-check:
ansible/versioncheck.py
roles-check:
ansible/roles.py --check

requirements: requirements-install requirements-check
roles-update:
ansible/roles.py --update

roles: roles-install roles-check

$(PROVISIONER_PATH):
@mkdir -p $(TF_PLUGINS_DIR)/$(ARCH); \
Expand Down
7 changes: 0 additions & 7 deletions ansible/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
---
- name: infra-role-bootstrap-linux
src: [email protected]:status-im/infra-role-bootstrap-linux.git
scm: git

- name: infra-role-wireguard
src: [email protected]:status-im/infra-role-wireguard.git
scm: git

- name: infra-role-open-ports
src: [email protected]:status-im/infra-role-open-ports.git
scm: git

- name: infra-role-swap-file
src: [email protected]:status-im/infra-role-swap-file.git
scm: git

- name: infra-role-consul-service
src: [email protected]:status-im/infra-role-consul-service.git
scm: git

- name: infra-role-systemd-timer
src: [email protected]:status-im/infra-role-systemd-timer.git
scm: git
Loading

0 comments on commit d8c8bf0

Please sign in to comment.