Compare commits
6 commits
d0e4450645
...
6707ece8e0
Author | SHA1 | Date | |
---|---|---|---|
|
6707ece8e0 | ||
|
6ae15ccbbc | ||
|
f46827bada | ||
|
bf7159d79e | ||
|
170f972185 | ||
|
a710ec9644 |
11 changed files with 40 additions and 34 deletions
|
@ -70,16 +70,16 @@ Execute a command using the Python wrapper that activates the virtual env, e.g.
|
||||||
*build*: build all docker images available in `/images`, e.g. `task docker:build`
|
*build*: build all docker images available in `/images`, e.g. `task docker:build`
|
||||||
|
|
||||||
#### module:\<module_name\>
|
#### module:\<module_name\>
|
||||||
Directly execute a Python module located in `collections/ansible_collections/nullified/infrastructure/plugins/modules` with its default configuration
|
Directly execute a Python module located in `ansible_collections/nullified/infrastructure/plugins/modules` with its default configuration
|
||||||
(typically the path to a test YAML file). Used only for debugging purpose.
|
(typically the path to a test YAML file). Used only for debugging purpose.
|
||||||
Example call: `task module:github_artifact`.
|
Example call: `task module:github_artifact`.
|
||||||
|
|
||||||
#### test:collections
|
#### test:collections
|
||||||
Executes molecule tests on each collections declared in `collections/ansible_collections`. Requires the collection to have a working molecule configuration.
|
Executes molecule tests on each collections declared in `ansible_collections`. Requires the collection to have a working molecule configuration.
|
||||||
Useful to ensure playbooks behave as expected using a Docker container.
|
Useful to ensure playbooks behave as expected using a Docker container.
|
||||||
|
|
||||||
#### test:modules
|
#### test:modules
|
||||||
Run Ansible's sanity tests on each collections declared in `collections/ansible_collections`.
|
Run Ansible's sanity tests on each collections declared in `ansible_collections`.
|
||||||
|
|
||||||
#### nosey
|
#### nosey
|
||||||
Run `noseyparker`, a tool that aims to find potential data leak such as passwords and security token.
|
Run `noseyparker`, a tool that aims to find potential data leak such as passwords and security token.
|
||||||
|
|
|
@ -10,11 +10,15 @@ includes:
|
||||||
env:
|
env:
|
||||||
DOCKER_REPOSITORY: pouncetech/molecule
|
DOCKER_REPOSITORY: pouncetech/molecule
|
||||||
ANSIBLE_VAULT_PASSWORD_FILE: '{{.ROOT_DIR}}/scripts/pass_get_vault_id.sh'
|
ANSIBLE_VAULT_PASSWORD_FILE: '{{.ROOT_DIR}}/scripts/pass_get_vault_id.sh'
|
||||||
|
ANSIBLE_LIBRARY:
|
||||||
|
sh: >
|
||||||
|
find .venv -name modules -type d -printf "{{.ROOT_DIR}}/%h/%f:" | sed 's/.$//'
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
PYTHON_WRAPPER: '{{.ROOT_DIR}}/scripts/python_wrapper.sh'
|
PYTHON_WRAPPER: '{{.ROOT_DIR}}/scripts/python_wrapper.sh'
|
||||||
MOLECULE_DIR: '{{.ROOT_DIR}}/ansible_collections/nullified/infrastructure/extensions'
|
MOLECULE_DIR: '{{.ROOT_DIR}}/ansible_collections/nullified/infrastructure/extensions'
|
||||||
COLLECTIONS_DIR: '{{.ROOT_DIR}}/ansible_collections'
|
COLLECTIONS_DIR: '{{.ROOT_DIR}}/ansible_collections'
|
||||||
|
GALAXY_COLLECTIONS_DIR: '{{.ROOT_DIR}}/galaxy'
|
||||||
ANSIBLE_PASS_PATH: ansible/vault-id
|
ANSIBLE_PASS_PATH: ansible/vault-id
|
||||||
ANSIBLE_PASS_LENGTH: 50
|
ANSIBLE_PASS_LENGTH: 50
|
||||||
|
|
||||||
|
@ -64,6 +68,8 @@ tasks:
|
||||||
desc: execute a molecule command
|
desc: execute a molecule command
|
||||||
dir: '{{.MOLECULE_DIR}}'
|
dir: '{{.MOLECULE_DIR}}'
|
||||||
cmd: '{{.PYTHON_WRAPPER}} molecule {{.CLI_ARGS}}'
|
cmd: '{{.PYTHON_WRAPPER}} molecule {{.CLI_ARGS}}'
|
||||||
|
env:
|
||||||
|
ANSIBLE_COLLECTIONS_PATH: '{{.COLLECTIONS_DIR}}:{{.GALAXY_COLLECTIONS_DIR}}'
|
||||||
|
|
||||||
molecule:purge:
|
molecule:purge:
|
||||||
desc: purge libvirtd and reset firewall rules
|
desc: purge libvirtd and reset firewall rules
|
||||||
|
@ -90,7 +96,7 @@ tasks:
|
||||||
desc: create a new collection
|
desc: create a new collection
|
||||||
vars:
|
vars:
|
||||||
COLLECTION_NAME: '{{index .MATCH 0}}'
|
COLLECTION_NAME: '{{index .MATCH 0}}'
|
||||||
COLLECTION_SUBPATH: 'collections/ansible_collections'
|
COLLECTION_SUBPATH: 'ansible_collections'
|
||||||
cmds:
|
cmds:
|
||||||
- '{{.PYTHON_WRAPPER}} ansible-galaxy collection init {{.COLLECTION_NAME}} --init-path {{.COLLECTIONS_DIR}}'
|
- '{{.PYTHON_WRAPPER}} ansible-galaxy collection init {{.COLLECTION_NAME}} --init-path {{.COLLECTIONS_DIR}}'
|
||||||
- 'echo "!{{.COLLECTION_SUBPATH}}/{{(.COLLECTION_NAME | split ".")._0}}" | tee -a .gitignore > /dev/null'
|
- 'echo "!{{.COLLECTION_SUBPATH}}/{{(.COLLECTION_NAME | split ".")._0}}" | tee -a .gitignore > /dev/null'
|
||||||
|
|
|
@ -3,10 +3,6 @@
|
||||||
- name: Fail if molecule group is missing
|
- name: Fail if molecule group is missing
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
tasks:
|
tasks:
|
||||||
- name: Print some info
|
|
||||||
ansible.builtin.debug:
|
|
||||||
msg: "{{ groups }}"
|
|
||||||
|
|
||||||
- name: Assert group existence
|
- name: Assert group existence
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "'molecule' in groups"
|
that: "'molecule' in groups"
|
||||||
|
@ -17,12 +13,12 @@
|
||||||
hosts: molecule
|
hosts: molecule
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
vars_files:
|
vars_files:
|
||||||
- ../../../../../../../inventory/group_vars/all/vars.yml
|
- ../../../../../../inventory/group_vars/all/vars.yml
|
||||||
- ../../../../../../../inventory/group_vars/all/vault.yml
|
- ../../../../../../inventory/group_vars/all/vault.yml
|
||||||
- ./platform_vars.yml
|
- ./platform_vars.yml
|
||||||
tasks:
|
tasks:
|
||||||
- include_vars: ../../../../../../../inventory/group_vars/all/vars.yml
|
- include_vars: ../../../../../../inventory/group_vars/all/vars.yml
|
||||||
- include_vars: ../../../../../../../inventory/group_vars/all/vault.yml
|
- include_vars: ../../../../../../inventory/group_vars/all/vault.yml
|
||||||
- include_vars: ./platform_vars.yml
|
- include_vars: ./platform_vars.yml
|
||||||
- name: Platform hostvars
|
- name: Platform hostvars
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
|
|
|
@ -35,7 +35,7 @@ provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
config_options:
|
config_options:
|
||||||
defaults:
|
defaults:
|
||||||
vault_password_file: ${HOME}/.config/ansible/vault-id
|
vault_password_file: ${ANSIBLE_VAULT_PASSWORD_FILE}
|
||||||
inventory:
|
inventory:
|
||||||
group_vars:
|
group_vars:
|
||||||
molecule:
|
molecule:
|
||||||
|
|
|
@ -2,3 +2,4 @@ collections:
|
||||||
- community.docker
|
- community.docker
|
||||||
- ansible.netcommon
|
- ansible.netcommon
|
||||||
- kubernetes.core
|
- kubernetes.core
|
||||||
|
- community.vagrant
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
---
|
---
|
||||||
collections:
|
collections:
|
||||||
- name: kubernetes.core
|
- name: kubernetes.core
|
||||||
version: 5.0.0
|
version: 5.1.0
|
||||||
- name: community.general
|
- name: community.general
|
||||||
version: 9.1.0
|
version: 10.3.0
|
||||||
- name: ansible.utils
|
- name: ansible.utils
|
||||||
version: 5.0.0
|
version: 5.1.2
|
||||||
- name: moreati.jq
|
- name: moreati.jq
|
||||||
version: 0.2.1
|
version: 0.2.1
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
ansible-lint==25.1.3
|
||||||
|
libvirt-python==11.1.0
|
||||||
|
molecule-plugins[vagrant]==23.7.0
|
||||||
|
molecule==25.3.1
|
||||||
|
pylint==3.3.4
|
||||||
|
python-vagrant==1.0.0
|
||||||
|
yamllint==1.35.1
|
|
@ -1,15 +1,9 @@
|
||||||
ansible-core==2.17.1
|
ansible-core==2.18.3
|
||||||
ansible-lint==24.7.0
|
|
||||||
docker==7.1.0
|
docker==7.1.0
|
||||||
Jinja2==3.1.4
|
Jinja2==3.1.6
|
||||||
jsonschema==4.23.0
|
jsonschema==4.23.0
|
||||||
molecule==24.7.0
|
|
||||||
molecule-plugins==23.5.3
|
|
||||||
netaddr==1.3.0
|
netaddr==1.3.0
|
||||||
paramiko==3.4.0
|
paramiko==3.5.1
|
||||||
pycurl==7.45.3
|
pycurl==7.45.6
|
||||||
pylint==3.2.5
|
|
||||||
python-vagrant==1.0.0
|
|
||||||
yamllint==1.35.1
|
|
||||||
jq==1.8.0
|
jq==1.8.0
|
||||||
dnspython==2.6.1
|
dnspython==2.7.0
|
||||||
|
|
0
scripts/reset_virtd.sh
Normal file → Executable file
0
scripts/reset_virtd.sh
Normal file → Executable file
|
@ -3,7 +3,7 @@ version: '3'
|
||||||
tasks:
|
tasks:
|
||||||
modules:
|
modules:
|
||||||
desc: run `ansible-test sanity` on collections to find common issues for modules and collections
|
desc: run `ansible-test sanity` on collections to find common issues for modules and collections
|
||||||
dir: collections/ansible_collections
|
dir: ansible_collections
|
||||||
vars:
|
vars:
|
||||||
ANSIBLE_COLLECTIONS:
|
ANSIBLE_COLLECTIONS:
|
||||||
sh: find -mindepth 2 -maxdepth 2 -type d
|
sh: find -mindepth 2 -maxdepth 2 -type d
|
||||||
|
@ -11,7 +11,7 @@ tasks:
|
||||||
- for: { var: ANSIBLE_COLLECTIONS }
|
- for: { var: ANSIBLE_COLLECTIONS }
|
||||||
task: 'test:module:sanity'
|
task: 'test:module:sanity'
|
||||||
vars:
|
vars:
|
||||||
COLLECTION_PATH: 'collections/ansible_collections/{{.ITEM}}'
|
COLLECTION_PATH: 'ansible_collections/{{.ITEM}}'
|
||||||
|
|
||||||
module:sanity:
|
module:sanity:
|
||||||
internal: true
|
internal: true
|
||||||
|
@ -21,7 +21,7 @@ tasks:
|
||||||
|
|
||||||
collections:
|
collections:
|
||||||
desc: run molecule tests for all roles and collections.
|
desc: run molecule tests for all roles and collections.
|
||||||
dir: collections/ansible_collections
|
dir: ansible_collections
|
||||||
vars:
|
vars:
|
||||||
ANSIBLE_COLLECTIONS:
|
ANSIBLE_COLLECTIONS:
|
||||||
sh: find -mindepth 2 -maxdepth 2 -type d
|
sh: find -mindepth 2 -maxdepth 2 -type d
|
||||||
|
@ -29,7 +29,7 @@ tasks:
|
||||||
- for: { var: ANSIBLE_COLLECTIONS }
|
- for: { var: ANSIBLE_COLLECTIONS }
|
||||||
task: 'test:collection:molecule'
|
task: 'test:collection:molecule'
|
||||||
vars:
|
vars:
|
||||||
COLLECTION_PATH: 'collections/ansible_collections/{{.ITEM}}'
|
COLLECTION_PATH: 'ansible_collections/{{.ITEM}}'
|
||||||
|
|
||||||
collection:molecule:
|
collection:molecule:
|
||||||
internal: true
|
internal: true
|
||||||
|
@ -40,7 +40,7 @@ tasks:
|
||||||
module:github_artifact:
|
module:github_artifact:
|
||||||
desc: run a module from the collection for testing purposes
|
desc: run a module from the collection for testing purposes
|
||||||
vars:
|
vars:
|
||||||
PLUGINS_DIR: '{{.ROOT_DIR}}/collections/ansible_collections/nullified/infrastructure/plugins'
|
PLUGINS_DIR: '{{.ROOT_DIR}}/ansible_collections/nullified/infrastructure/plugins'
|
||||||
cmd: |
|
cmd: |
|
||||||
{{.PYTHON_WRAPPER}} python3 {{.PLUGINS_DIR}}/modules/github_artifact.py {{.PLUGINS_DIR}}/tests/github_artifact.json |
|
{{.PYTHON_WRAPPER}} python3 {{.PLUGINS_DIR}}/modules/github_artifact.py {{.PLUGINS_DIR}}/tests/github_artifact.json |
|
||||||
{{.PYTHON_WRAPPER}} python3 -m json.tool | {{.PYTHON_WRAPPER}} pygmentize -l json
|
{{.PYTHON_WRAPPER}} python3 -m json.tool | {{.PYTHON_WRAPPER}} pygmentize -l json
|
||||||
|
|
|
@ -22,6 +22,8 @@ tasks:
|
||||||
vault:init:
|
vault:init:
|
||||||
desc: Create a vault id file in your home directory for encrypting/decrypting vault files
|
desc: Create a vault id file in your home directory for encrypting/decrypting vault files
|
||||||
cmds:
|
cmds:
|
||||||
- 'pass generate {{.ANSIBLE_PASS_PATH}} {{.ANSIBLE_PASS_LENGTH}} > /dev/null'
|
- |
|
||||||
|
pass show {{.ANSIBLE_PASS_PATH}} &> /dev/null ||
|
||||||
|
pass generate {{.ANSIBLE_PASS_PATH}} {{.ANSIBLE_PASS_LENGTH}} > /dev/null
|
||||||
status:
|
status:
|
||||||
- 'pass show {{.ANSIBLE_PASS_PATH}} &> /dev/null '
|
- 'pass show {{.ANSIBLE_PASS_PATH}} &> /dev/null'
|
||||||
|
|
Loading…
Add table
Reference in a new issue