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

@ -100,6 +100,23 @@ Run Ansible's sanity tests on each collections declared in `collections/ansible_
#### nosey
Run `noseyparker`, a tool that aims to find potential data leak such as passwords and security token.
#### ansible:new:collection:\<name\>
Creates a new collection `<name>` and add an exception in .gitignore in order to let git track it.
Example:
```shell
task ansible:new:collection:my_org.my_collection
```
#### ansible:new:role:\<name\>
Creates a new role `<name>` in the default or specified collection.
Examples:
```shell
#New role for the default (nullified.infrastructure) collection
task ansible:new:role:my_new_role
# New role the collection "my_org.my_collection"
COLLECTION_NAME=my_org.my_collection task ansible:new:role:my_new_role
```
### Examples
```shell
# encrypt vault
@ -112,15 +129,6 @@ task venv -- ansible-playbook --ask-vault-password -l my_host playbooks/test.yml
task venv -- ansible --ask-vault-password -m import_role --args 'name=nullified.infrastructure.security' my_host
```
### Generic collection / roles commands
```shell
mkdir -p collections/ansible_collections
cd collections/ansible_collections
task venv -- ansible-galaxy collection init nullified.infrastructure
cd nullified/infrastructure/roles
task venv -- ansible-galaxy collection init tooling
```
## Advanced Configuration
### Global variables
Global variables are defined in `inventory/group_vars/all/vars.yml` and are used in multiple roles and playbooks.