Role to manage the creation and destruction of openstack resources for running molecule in a shared CI environment. A hash of the molecule role name, the current scenario, and the executing user to appended to generated resources to prevent naming conflicts when a given role scenario is tested by two users simultaneously in the shared environment.
Ansible 2.4 or higher
Red Hat Enterprise Linux 7 or equivalent
Valid Red Hat Subscriptions
Currently the following variables are supported:
molecule_openstack_ci_ssh_user
- Username used to log in to provisioned instance, defaults to "cloud-user".molecule_openstack_ci_ssh_port
- SSH port to connect to provisioned instance, defaults to 22.molecule_openstack_ci_security_group_name
- Security group name prefix to use when generating security group. Defaults to "molecule". The actual security group(s) created will have the run hash appended to their name.molecule_openstack_ci_security_group_description
- Security group description, defaults to "Security group for testing Molecule"molecule_openstack_ci_security_group_rules
- Array of argument dictionaries passed to (os_security_group_rule)[https://docs.ansible.com/ansible/latest/modules/os_security_group_rule_module.html] module, defaults to `[{"ethertype": "IPv4"}, {"ethertype": "IPv6"}], effectively allowing all access to molecule instances by default.molecule_openstack_ci_keypair_name
- molecule_keymolecule_openstack_ci_security_group_name
- SSH keypair name prefix to use when generating keypair. Defaults to "molecule_key". The actual keypair created will have the run hash appended to its name.
python-openstacksdk
must be installed on the machine running molecule, as the openstack config is loaded using theopenstack.config
module.
Molecule scenario create.yml
:
- name: Create
hosts: localhost
connection: local
gather_facts: false
no_log: |-
{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or
molecule_yml.provisioner.log|default(false) | bool) }}
roles:
- name: oasis_roles.molecule_openstack_ci
vars:
# this var is required for create and destroy
molecule_openstack_ci_state: present
# other vars can be set here, e.g.
# molecule_openstack_ci_ssh_user: yourcloudusername
Molecule scenario destroy.yml
:
- name: Destroy
hosts: localhost
connection: local
gather_facts: false
no_log: |-
{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or
molecule_yml.provisioner.log|default(false) | bool) }}
roles:
- name: oasis_roles.molecule_openstack_ci
vars:
molecule_openstack_ci_state: absent
Note: Remember to add "oasis_roles.molecule_openstack_ci" to your molecule scenario dependencies.
Molecule scenario requirements.yml
:
- name: oasis_roles.molecule_openstack_ci
GPLv3
Author Name authoremail@domain.net