summaryrefslogtreecommitdiff
path: root/test/integration/targets/tower_host/tasks/main.yml
blob: cda418f94fd06794c4dc4af9a8cdc4f750ffedeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
- name: create a tempdir for hostvars
  shell: mktemp -d
  register: tempdir

- name: write a file w/ hostvars
  lineinfile:
    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"

- 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.'"