Integrating test-molecule role commit b90b020ad2
Gitea Actions - molecule test work / Explore-molecule-Gitea-Action (push) Failing after 25s
Gitea Actions - molecule test work / Explore-molecule-Gitea-Action (push) Failing after 25s
This commit is contained in:
1 parent
004d301f66
commit
7c86412b04
6 files changed
+130
-59
No files matched your search
@@ -3,33 +3,80 @@
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
# no_log: "{{ molecule_no_log }}"
|
||||
vars:
|
||||
molecule_inventory:
|
||||
all:
|
||||
hosts: {}
|
||||
molecule: {}
|
||||
|
||||
tasks:
|
||||
# TODO: Developer must implement and populate 'server' variable
|
||||
- name: Create a container
|
||||
community.docker.docker_container:
|
||||
name: "{{ item.name }}"
|
||||
image: "{{ item.image }}"
|
||||
state: started
|
||||
command: sleep 1d
|
||||
log_driver: json-file
|
||||
register: result
|
||||
loop: "{{ molecule_yml.platforms }}"
|
||||
|
||||
- name: Create instance config
|
||||
when: server.changed | default(false) | bool # noqa no-handler
|
||||
block:
|
||||
- name: Populate instance config dict # noqa jinja
|
||||
ansible.builtin.set_fact:
|
||||
instance_conf_dict: {}
|
||||
# instance': "{{ }}",
|
||||
# address': "{{ }}",
|
||||
# user': "{{ }}",
|
||||
# port': "{{ }}",
|
||||
# 'identity_file': "{{ }}", }
|
||||
with_items: "{{ server.results }}"
|
||||
register: instance_config_dict
|
||||
- name: Print some info
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.results }}"
|
||||
|
||||
- name: Convert instance config dict to a list
|
||||
ansible.builtin.set_fact:
|
||||
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
|
||||
- name: Fail if container is not running
|
||||
when: >
|
||||
item.container.State.ExitCode != 0 or
|
||||
not item.container.State.Running
|
||||
ansible.builtin.include_tasks:
|
||||
file: tasks/create-fail.yml
|
||||
loop: "{{ result.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.container.Name }}"
|
||||
|
||||
- name: Dump instance config
|
||||
ansible.builtin.copy:
|
||||
content: |
|
||||
# Molecule managed
|
||||
- name: Add container to molecule_inventory
|
||||
vars:
|
||||
inventory_partial_yaml: |
|
||||
all:
|
||||
children:
|
||||
molecule:
|
||||
hosts:
|
||||
"{{ item.name }}":
|
||||
ansible_connection: community.docker.docker
|
||||
ansible.builtin.set_fact:
|
||||
molecule_inventory: >
|
||||
{{ molecule_inventory | combine(inventory_partial_yaml | from_yaml, recursive=true) }}
|
||||
loop: "{{ molecule_yml.platforms }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
|
||||
{{ instance_conf | to_json | from_json | to_yaml }}
|
||||
dest: "{{ molecule_instance_config }}"
|
||||
mode: "0600"
|
||||
- name: Dump molecule_inventory
|
||||
ansible.builtin.copy:
|
||||
content: |
|
||||
{{ molecule_inventory | to_yaml }}
|
||||
dest: "{{ molecule_ephemeral_directory }}/inventory/molecule_inventory.yml"
|
||||
mode: "0600"
|
||||
|
||||
- name: Force inventory refresh
|
||||
ansible.builtin.meta: refresh_inventory
|
||||
|
||||
- name: Fail if molecule group is missing
|
||||
ansible.builtin.assert:
|
||||
that: "'molecule' in groups"
|
||||
fail_msg: |
|
||||
molecule group was not found inside inventory groups: {{ groups }}
|
||||
run_once: true # noqa: run-once[task]
|
||||
|
||||
# we want to avoid errors like "Failed to create temporary directory"
|
||||
- name: Validate that inventory was refreshed
|
||||
hosts: molecule
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Check uname
|
||||
ansible.builtin.raw: uname -a
|
||||
register: result
|
||||
changed_when: false
|
||||
|
||||
- name: Display uname info
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.stdout }}"
|
||||
Reference in new issue
Block a user