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] [-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.

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.
  -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 6, 2024
1 parent 23d0813 commit 3e8cc3a
Show file tree
Hide file tree
Showing 4 changed files with 377 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
13 changes: 6 additions & 7 deletions ansible/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
---
- name: infra-role-bootstrap-linux
src: [email protected]:status-im/infra-role-bootstrap-linux.git
scm: git
src: [email protected]:status-im/infra-role-bootstrap-linux.git

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

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

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

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

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

0 comments on commit 3e8cc3a

Please sign in to comment.