summaryrefslogtreecommitdiff
path: root/test/integration/targets/tower_send/tasks/main.yml
blob: 0d83896301eb8a3c40f2f5bc1ce323be18be8af4 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
- name: Test no parameters
  tower_send:
  register: result
  ignore_errors: yes

- assert:
    that:
      - "result is failed"

- name: Create user json
  set_fact:
    user:
      - username: "jowestco"
        first_name: "John"
        last_name: "Westcott"
        asset_type: "user"
        email: "john.westcott.iv@redhat.com"

- name: Test a new import of asset
  tower_send:
    assets: "{{ user | to_json() }}"
  register: result

- assert:
    that:
      - "result is changed"

- name: Test an existing import of asset
  tower_send:
    assets: "{{ user | to_json() }}"
  register: result

- assert:
    that:
      - "result is successful"
      - "result is not changed"

- name: Change an existing asset
  tower_send:
    assets: "{{ user | combine({'last_name': 'Westcott IV'}) | to_json() }}"
  register: result

- assert:
    that:
      - "result is changed"

- name: Create organization json
  set_fact:
    organization:
      - asset_type: organization
        name: "Red Hat"

- name: Create temp file
  tempfile:
    state: file
  register: my_temp_file

- name: Drop down a file to import
  copy:
    dest: "{{ my_temp_file.path }}"
    content: "{{ organization | to_nice_json() }}"

- name: Create org via files
  tower_send:
    files: "{{ my_temp_file.path }}"
  register: result

- assert:
    that:
      - "result is changed"

- name: Remove Temp File
  file:
    path: "{{ my_temp_file.path }}"
    state: absent