2018-03-16 18:28:19 +01:00
|
|
|
- name: create a tempdir for hostvars
|
2019-04-27 02:33:59 +02:00
|
|
|
shell: mktemp -d
|
2018-03-16 18:28:19 +01:00
|
|
|
register: tempdir
|
|
|
|
|
|
|
|
- name: write a file w/ hostvars
|
2019-04-27 02:33:59 +02:00
|
|
|
lineinfile:
|
2018-03-16 18:28:19 +01:00
|
|
|
dest: "{{ tempdir.stdout }}/vars"
|
|
|
|
line: '{"foo": "bar"}'
|
|
|
|
create: true
|
|
|
|
|
|
|
|
- name: Create a Host
|
|
|
|
tower_host:
|
|
|
|
name: "some-host"
|
|
|
|
inventory: "Demo Inventory"
|
|
|
|
state: present
|
|
|
|
variables: "@{{ tempdir.stdout }}/vars"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result is changed"
|
|
|
|
|
|
|
|
- name: Delete a Host
|
|
|
|
tower_host:
|
|
|
|
name: "some-host"
|
|
|
|
inventory: "Demo Inventory"
|
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result is changed"
|
2019-01-09 15:31:21 +01:00
|
|
|
|
|
|
|
- name: Check module fails with correct msg
|
|
|
|
tower_host:
|
|
|
|
name: test-host
|
|
|
|
description: Host Description
|
|
|
|
inventory: test-non-existing-inventory
|
|
|
|
state: present
|
|
|
|
register: result
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.msg =='Failed to update host, inventory not found: The requested object could not be found.'"
|