feat(tooling): added tasks to generate a new ansible role or collection with default skeleton

This commit is contained in:
NaeiKinDus 2024-07-04 18:25:24 +00:00
parent 317c562e7a
commit fc11d3ee83
2 changed files with 35 additions and 9 deletions

View file

@ -6,6 +6,7 @@ env:
vars:
PYTHON_WRAPPER: '{{.ROOT_DIR}}/scripts/python_wrapper.sh'
MOLECULE_DIR: '{{.ROOT_DIR}}/collections/ansible_collections/nullified/infrastructure/extensions'
COLLECTIONS_DIR: '{{.ROOT_DIR}}/collections/ansible_collections'
tasks:
setup:venv:
@ -117,3 +118,20 @@ tasks:
desc: execute a molecule command
dir: '{{.MOLECULE_DIR}}'
cmd: '{{.PYTHON_WRAPPER}} molecule {{.CLI_ARGS}}'
ansible:new:role:*:
desc: create a new role for the specified collection
vars:
COLLECTION_NAME: '{{default "nullified.infrastructure" .COLLECTION_NAME}}'
ROLE_NAME: '{{index .MATCH 0}}'
cmds:
- '{{.PYTHON_WRAPPER}} ansible-galaxy role init {{.ROLE_NAME}} --init-path {{.COLLECTIONS_DIR}}/{{.COLLECTION_NAME | replace "." "/"}}/roles'
ansible:new:collection:*:
desc: create a new collection
vars:
COLLECTION_NAME: '{{index .MATCH 0}}'
COLLECTION_SUBPATH: 'collections/ansible_collections'
cmds:
- '{{.PYTHON_WRAPPER}} ansible-galaxy collection init {{.COLLECTION_NAME}} --init-path {{.COLLECTIONS_DIR}}'
- 'echo "!{{.COLLECTION_SUBPATH}}/{{(.COLLECTION_NAME | split ".")._0}}" | tee -a .gitignore > /dev/null'