-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a temporary file and cleanup at the end.
XXX we must use delegate_to: localhost instead of hosts: localhost because of the braindamaged localhost group.
- Loading branch information
Showing
1 changed file
with
18 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |