Skip to content

Commit

Permalink
Use a temporary file and cleanup at the end.
Browse files Browse the repository at this point in the history
XXX we must use delegate_to: localhost instead of hosts: localhost
because of the braindamaged localhost group.
  • Loading branch information
pcahyna committed May 31, 2019
1 parent 88aea98 commit ed52e31
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions tests/tests_default_wrapper.yml
Original file line number Diff line number Diff line change
@@ -1,19 +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: inventory.yaml
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 inventory.yaml --check tests_default.yml
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 ed52e31

Please sign in to comment.