Mohammed Naser 4d6516700d give jobs names
Change-Id: I387d5e02d8474c3d0680500de373387952783d47
2022-05-01 18:52:33 -04:00

69 lines
2.2 KiB
YAML

---
- hosts: ubuntu-focal
roles:
- role: ensure-clouds-yaml
- role: ensure-molecule
vars:
molecule_version: 3.5.2
- hosts: ubuntu-focal
tasks:
# TODO(mnaser): Get artifact from build job
- name: Build & Install collection
block:
- name: Install build-time dependencies
become: true
pip:
name: ['pbr', 'pyyaml']
- name: Generate galaxy.yml file
shell: python3 tools/generate-galaxy-yml.py
args:
chdir: "{{ zuul.project.src_dir }}"
- name: Install collection
shell: ansible-galaxy collection install -f {{ zuul.project.src_dir }}
- name: molecule create
shell: molecule create
args:
chdir: "{{ zuul.project.src_dir }}"
environment:
ATMOSPHERE_STACK_NAME: "atmosphere-{{ zuul.build }}"
- name: Grab the Molecule instance configuration
slurp:
src: "{{ ansible_user_dir }}/.cache/molecule/{{ zuul.project.short_name }}/default/instance_config.yml"
register: _molecule_instance_config
- name: Grab the Molecule SSH key
slurp:
src: "{{ ansible_user_dir }}/.cache/molecule/{{ zuul.project.short_name }}/default/id_rsa"
register: _molecule_ssh_key
- name: Copy the SSH key down to exector
fetch:
src: "{{ ansible_user_dir }}/.cache/molecule/{{ zuul.project.short_name }}/default/id_rsa"
dest: "{{ ansible_user_dir }}/.ssh/id_molecule"
flat: yes
- name: Add SSH key to the executor
delegate_to: localhost
command: ssh-add {{ ansible_user_dir }}/.ssh/id_molecule
- name: Add all of the hosts to the inventory
add_host:
name: "{{ item.instance }}"
groups: ["molecule"]
ansible_user: "{{ item.user }}"
ansible_host: "{{ item.address }}"
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['content'] | b64decode | from_yaml }}"
loop_control:
label: "{{ item.instance }}"
- hosts: molecule
tasks:
- ping: