From 0c8f31d6c5c3c686e078964c1e4c482f69bc3290 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Fri, 29 Apr 2022 22:59:18 -0400 Subject: [PATCH] Add more Molecule fixes - Add STACK_NAME with zuul job - Slurp isntance config from Zuul controller Change-Id: Ifec5c21aced37557ef8fba2305e7248760b9a39f --- playbooks/molecule/post-run.yaml | 10 ++++++---- playbooks/molecule/pre-run.yaml | 15 ++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/playbooks/molecule/post-run.yaml b/playbooks/molecule/post-run.yaml index da3eda2..6148f32 100644 --- a/playbooks/molecule/post-run.yaml +++ b/playbooks/molecule/post-run.yaml @@ -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 }}" \ No newline at end of file diff --git a/playbooks/molecule/pre-run.yaml b/playbooks/molecule/pre-run.yaml index 9cf68f1..b5d14c9 100644 --- a/playbooks/molecule/pre-run.yaml +++ b/playbooks/molecule/pre-run.yaml @@ -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 }}"