mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-04 05:04:22 -07:00
parent
bc99432f89
commit
eaa5e07b28
247 changed files with 7318 additions and 7375 deletions
|
@ -9,59 +9,59 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- block:
|
||||
- name: Create temporary playbook files
|
||||
tempfile:
|
||||
state: file
|
||||
suffix: temp
|
||||
loop: "{{ tests }}"
|
||||
loop_control:
|
||||
loop_var: test
|
||||
label: "{{ test.name }}"
|
||||
register: temporary_playbook_files
|
||||
- name: Create temporary playbook files
|
||||
tempfile:
|
||||
state: file
|
||||
suffix: temp
|
||||
loop: "{{ tests }}"
|
||||
loop_control:
|
||||
loop_var: test
|
||||
label: "{{ test.name }}"
|
||||
register: temporary_playbook_files
|
||||
|
||||
- name: Set temporary playbook file content
|
||||
copy:
|
||||
content: "{{ test.playbook }}"
|
||||
dest: "{{ temporary_playbook_files.results[test_idx].path }}"
|
||||
loop: "{{ tests }}"
|
||||
loop_control:
|
||||
loop_var: test
|
||||
index_var: test_idx
|
||||
label: "{{ test.name }}"
|
||||
- name: Set temporary playbook file content
|
||||
copy:
|
||||
content: "{{ test.playbook }}"
|
||||
dest: "{{ temporary_playbook_files.results[test_idx].path }}"
|
||||
loop: "{{ tests }}"
|
||||
loop_control:
|
||||
loop_var: test
|
||||
index_var: test_idx
|
||||
label: "{{ test.name }}"
|
||||
|
||||
- name: Collect outputs
|
||||
command: "ansible-playbook -i {{ inventory }} {{ playbook }}"
|
||||
environment: "{{ test.environment }}"
|
||||
loop: "{{ tests }}"
|
||||
loop_control:
|
||||
loop_var: test
|
||||
label: "{{ test.name }}"
|
||||
register: outputs
|
||||
changed_when: false
|
||||
vars:
|
||||
inventory: "{{ role_path }}/inventory.yml"
|
||||
playbook: "
|
||||
{%- for result in temporary_playbook_files.results -%}
|
||||
{%- if result.test.name == test.name -%}
|
||||
{{- result.path -}}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}"
|
||||
- name: Collect outputs
|
||||
command: "ansible-playbook -i {{ inventory }} {{ playbook }}"
|
||||
environment: "{{ test.environment }}"
|
||||
loop: "{{ tests }}"
|
||||
loop_control:
|
||||
loop_var: test
|
||||
label: "{{ test.name }}"
|
||||
register: outputs
|
||||
changed_when: false
|
||||
vars:
|
||||
inventory: "{{ role_path }}/inventory.yml"
|
||||
playbook: "
|
||||
{%- for result in temporary_playbook_files.results -%}
|
||||
{%- if result.test.name == test.name -%}
|
||||
{{- result.path -}}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}"
|
||||
|
||||
- name: Assert test output equals expected output
|
||||
assert:
|
||||
that: result.output.differences | length == 0
|
||||
loop: "{{ outputs.results | callback_results_extractor }}"
|
||||
loop_control:
|
||||
loop_var: result
|
||||
label: "{{ result.name }}"
|
||||
register: assertions
|
||||
- name: Assert test output equals expected output
|
||||
assert:
|
||||
that: result.output.differences | length == 0
|
||||
loop: "{{ outputs.results | callback_results_extractor }}"
|
||||
loop_control:
|
||||
loop_var: result
|
||||
label: "{{ result.name }}"
|
||||
register: assertions
|
||||
|
||||
always:
|
||||
- name: Remove temporary playbooks
|
||||
file:
|
||||
path: "{{ temporary_file.path }}"
|
||||
state: absent
|
||||
loop: "{{ temporary_playbook_files.results }}"
|
||||
loop_control:
|
||||
loop_var: temporary_file
|
||||
label: "{{ temporary_file.test.name }}: {{ temporary_file.path }}"
|
||||
- name: Remove temporary playbooks
|
||||
file:
|
||||
path: "{{ temporary_file.path }}"
|
||||
state: absent
|
||||
loop: "{{ temporary_playbook_files.results }}"
|
||||
loop_control:
|
||||
loop_var: temporary_file
|
||||
label: "{{ temporary_file.test.name }}: {{ temporary_file.path }}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue