forked from pemcg/ansible_playbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_generic_object.yml
54 lines (50 loc) · 1.52 KB
/
create_generic_object.yml
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
---
- name: Create Generic Object from Service
hosts: all
vars:
- manageiq_validate_certs: False
- go_class_name: "{{ 'MyGOClass'|urlencode }}"
tasks:
- name: Find the generic object class definition
uri:
url: "{{ manageiq.api_url }}/api/generic_object_definitions?expand=resources&filter[]=name='{{ go_class_name }}'"
method: GET
validate_certs: no
headers:
X-Auth-Token: "{{ manageiq.api_token }}"
body_format: json
register: go_definition
- name: Create generic object
uri:
url: "{{ manageiq.api_url }}/api/generic_objects"
method: POST
validate_certs: no
headers:
X-Auth-Token: "{{ manageiq.api_token }}"
body_format: json
body:
action: create
name: "{{ go_name }}"
generic_object_definition:
href: "{{ go_definition.json.resources[0].href }}"
property_attributes:
attribute_1: "{{ attribute_1 }}"
attribute_2: "{{ attribute_2 }}"
attribute_3: "false"
associations:
vms:
- href: "{{ manageiq.api_url }}/api/{{ association_vm }}"
register: new_go
- name: Add generic object to service
uri:
url: "{{ manageiq.api_url }}/api/{{ manageiq.service }}"
method: POST
validate_certs: no
headers:
X-Auth-Token: "{{ manageiq.api_token }}"
body_format: json
body:
action: add_resource
resource:
resource:
href: "{{ new_go.json.results[0].href }}"