Add more Molecule fixes

- Add STACK_NAME with zuul job
- Slurp isntance config from Zuul controller

Change-Id: Ifec5c21aced37557ef8fba2305e7248760b9a39f
This commit is contained in:
Mohammed Naser 2022-04-29 22:59:18 -04:00
parent 28464fa186
commit 0c8f31d6c5
2 changed files with 12 additions and 13 deletions

View File

@ -3,12 +3,14 @@
roles:
- fetch-output
# NOTE(mnaser): We refresh the inventory to drop all the hosts we've added using
# the add_host task to avoid any failures after we destroy.
- meta: refresh_inventory
- hosts: ubuntu-focal
tasks:
# NOTE(mnaser): We refresh the inventory to drop all the hosts we've added
# using the add_host task to avoid any failures after.
- meta: refresh_inventory
- shell: molecule destroy
args:
chdir: "{{ zuul.project.src_dir }}"
environment:
ATMOSPHERE_STACK_NAME: "atmosphere-{{ zuul.build }}"

View File

@ -25,16 +25,13 @@
- shell: molecule create
args:
chdir: "{{ zuul.project.src_dir }}"
- shell: molecule prepare
args:
chdir: "{{ zuul.project.src_dir }}"
environment:
ATMOSPHERE_STACK_NAME: "atmosphere-{{ zuul.build }}"
- name: Grab the Molecule instance configuration
set_fact:
molecule_instance_config: "{{ lookup('file', molecule_instance_config_path) | from_yaml }}"
vars:
molecule_instance_config_path: "{{ ansible_user_dir }}/.cache/molecule/{{ zuul.project.short_name }}/default/instance_config.yml"
slurp:
src: "{{ ansible_user_dir }}/.cache/molecule/{{ zuul.project.short_name }}/default/instance_config.yml"
register: _molecule_instance_config
- name: Add all of the hosts to the inventory
add_host:
@ -45,7 +42,7 @@
ansible_port: "{{ item.port }}"
ansible_private_key_file: "{{ item.identity_file }}"
ansible_ssh_extra_args: -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
loop: "{{ molecule_instance_config }}"
loop: "{{ _molecule_instance_config['content'] | b64decode | from_yaml }}"
loop_control:
label: "{{ item.instance }}"