Skip to content

Commit

Permalink
Merge pull request #39 from i386x/check-mode-tests
Browse files Browse the repository at this point in the history
Run tests_default both in normal and in check mode
  • Loading branch information
pcahyna authored May 31, 2019
2 parents 36b771c + ed52e31 commit 983656e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/inventory.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ { 'all': { 'hosts': hostvars } } | to_yaml }}
34 changes: 34 additions & 0 deletions tests/tests_default_wrapper.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 983656e

Please sign in to comment.