-
Notifications
You must be signed in to change notification settings - Fork 15
/
create_firewall_group.yml
71 lines (63 loc) · 2.02 KB
/
create_firewall_group.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
- name: Create Firewall Group
hosts: localhost
vars:
- go_name: "{{ 'FirewallGroup'|urlencode }}"
tasks:
- name: Find the "FirewallGroup" generic object definition
uri:
url: "{{ manageiq.api_url }}/api/generic_object_definitions?expand=resources&filter[]=name='{{ go_name }}'"
method: GET
validate_certs: no
headers:
X-Auth-Token: "{{ manageiq.api_token }}"
body_format: json
register: go_definition
- set_fact:
go_definition_href: "{{ go_definition.json.resources[0].href }}"
- name: Lookup the requesting user
uri:
url: "{{ manageiq.api_url }}/api/{{ manageiq.user }}"
method: GET
validate_certs: no
headers:
X-Auth-Token: "{{ manageiq.api_token }}"
body_format: json
register: requester
- set_fact:
requester_name: "{{ requester.json.name | default('') }}"
- name: Create the generic object entry
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: "{{ firewall_group_name }}"
generic_object_definition:
href: "{{ go_definition_href }}"
property_attributes:
requester: "{{ requester_name }}"
service_id: "{{ manageiq.service.split('/')[1] }}"
description: "{{ firewall_group_description }}"
provisioning_change_request: "{{ provisioning_change_request }}"
register: new_go
- set_fact:
new_go_href: "{{ new_go.json.results[0].href }}"
- name: Register the new generic object with the 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_href }}"
register: output