diff --git a/tests/inventory.yaml.j2 b/tests/inventory.yaml.j2 new file mode 100644 index 0000000..0ef9a45 --- /dev/null +++ b/tests/inventory.yaml.j2 @@ -0,0 +1 @@ +{{ { 'all': { 'hosts': hostvars } } | to_yaml }} diff --git a/tests/tests_default_wrapper.yml b/tests/tests_default_wrapper.yml new file mode 100644 index 0000000..a768f4c --- /dev/null +++ b/tests/tests_default_wrapper.yml @@ -0,0 +1,34 @@ +--- +- name: Create static inventory from hostvars + hosts: all + tasks: + - name: create temporary file + tempfile: + state: file + suffix: .inventory.yaml + register: tempinventory + delegate_to: localhost + + - name: Create static inventory from hostvars + template: + src: inventory.yaml.j2 + dest: "{{ tempinventory.path }}" + delegate_to: localhost + + +- name: Run tests_default.yml normally + import_playbook: tests_default.yml + +- name: Run tests_default.yml in check_mode + hosts: all + tasks: + - name: Run ansible-playbook with tests_default.yml in check mode + command: ansible-playbook -vvv -i {{ tempinventory.path }} --check tests_default.yml + delegate_to: localhost + + - name: remove the temporary file + file: + path: "{{ tempinventory.path }}" + state: absent + when: tempinventory.path is defined + delegate_to: localhost