validation_init¶
About The Role¶
The validation_init
role aims to create new validation from a skeleton.
Requirements¶
None.
Dependencies¶
None.
Example Playbook¶
- name: Create my new role
hosts: localhost
connection: local
gather_facts: false
roles:
- { role: validation_init, validation_init_role_name: "mynewrolename"}
License¶
Apache
Full Description¶
Role Documentation¶
Welcome to the “validation_init” role documentation.
Role Defaults¶
This section highlights all of the defaults and variables set within the “validation_init” role.
# All variables intended for modification should place placed in this file.
# All variables within this role should have a prefix of "validation_init"
# Debugging mode
validation_init_debug: false
# New role prefix
validation_init_prefix: tripleo
# Absolute path of the directory where the skeletin will be deployed
validation_init_skeleton_role_dir: /tmp
# Absolute/Relative path to the roles directory where the new role will be
# created
validation_init_roles_dir: roles
# Absolute/Relative path to the CI molecule yaml file
validation_init_zuuld_molecule: zuul.d/molecule.yaml
# Absolute/Relative path to the playbooks directory where the new playbook will
# be created
validation_init_playbooks_dir: playbooks
# Absolute/Relative path to the documentation roles directory
validation_init_roles_doc_dir: doc/source/roles
# If 'true', the documentation and CI configuration will be created, otherwise not.
# Will be used to create new custom validation through the CLI.
validation_init_enabling_ci: true
# If sets to 'true', the molecule directory created from the skeleton won't be deleted
# from the role and a CI job will be added in zuul.d/molecule.yaml file.
# If sets to 'false', the molecule directory will be deleted after the creation
# of the new role and no ci job will be added in zuul.d/molecule.yaml file.
validation_init_molecule: true
Molecule Scenarios¶
Molecule is being used to test the “validation_init” role. The following section highlights the drivers in service and provides an example playbook showing how the role is leveraged.
- Driver: podman:
- Driver: podman:
Scenario: no_molecule_test¶
Molecule Platform(s)¶
- name: centos
hostname: centos
image: centos/centos:stream8
registry:
url: quay.io
dockerfile: ../../../../.config/molecule/Dockerfile
pkg_extras: python*-setuptools python*-pyyaml
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
privileged: true
environment:
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
ulimits:
- host
Molecule Inventory¶
hosts:
all:
hosts:
centos:
ansible_python_interpreter: /usr/bin/python3
Example no_molecule_test playbook¶
- name: Converge - Role without molecule tests
hosts: all
gather_facts: false
tasks:
- name: Create new role
include_role:
name: validation_init
vars:
validation_init_role_name: skeleton_test_no_molecule
validation_init_prefix: tripleo
validation_init_skeleton_role_dir: /tmp
validation_init_roles_dir: /tmp/roles
validation_init_zuuld_molecule: /tmp/zuul.d/molecule.yaml
validation_init_playbooks_dir: /tmp/playbooks
validation_init_roles_doc_dir: /tmp/doc/source/roles
validation_init_molecule: false
Scenario: default¶
Molecule Platform(s)¶
- name: centos
hostname: centos
image: centos/centos:stream8
registry:
url: quay.io
dockerfile: ../../../../.config/molecule/Dockerfile
pkg_extras: python*-setuptools python*-pyyaml
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
privileged: true
environment:
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
ulimits:
- host
Molecule Inventory¶
hosts:
all:
hosts:
centos:
ansible_python_interpreter: /usr/bin/python3
Example default playbook¶
- name: Converge
hosts: all
gather_facts: false
tasks:
- name: Create new role
include_role:
name: validation_init
vars:
validation_init_role_name: skeleton_test
validation_init_prefix: tripleo
validation_init_skeleton_role_dir: /tmp
validation_init_roles_dir: /tmp/roles
validation_init_zuuld_molecule: /tmp/zuul.d/molecule.yaml
validation_init_playbooks_dir: /tmp/playbooks
validation_init_roles_doc_dir: /tmp/doc/source/roles
- name: Create a new role with the same name
block:
- name: Run the validation_init role again
include_role:
name: validation_init
vars:
validation_init_role_name: skeleton_test
validation_init_prefix: tripleo
validation_init_skeleton_role_dir: /tmp
validation_init_roles_dir: /tmp/roles
validation_init_zuuld_molecule: /tmp/zuul.d/molecule.yaml
validation_init_playbooks_dir: /tmp/playbooks
validation_init_roles_doc_dir: /tmp/doc/source/roles
rescue:
- name: Clear host error
meta: clear_host_errors
- name: Role addition output
debug:
msg: The Role works! End the playbook run
- name: End play
meta: end_play
- name: Fail the test
fail:
msg: |
The validation_init role didn't properly detect that the role name was
already been taken!