-
Notifications
You must be signed in to change notification settings - Fork 15
/
manageiq_automate_role_examples.yml
298 lines (255 loc) · 9.73 KB
/
manageiq_automate_role_examples.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
---
- name: manageiq-automate role example usage
hosts: localhost
connection: local
vars:
- object: root
- interval: 600
- manageiq_validate_certs: false
gather_facts: False
roles:
- manageiq-core.manageiq-automate
tasks:
# Working with input parameters:
#
# 'method_parameter_exists'
# 'get_method_parameters’
# 'get_method_parameter'
# 'get_decrypted_method_parameter'
- name: Get the list of method parameters (get_method_parameters)
manageiq_automate:
workspace: "{{ workspace }}"
get_method_parameters: yes
register: get_method_parameters
- debug: msg="Result:{{ get_method_parameters.value }}"
- name: Check if a method parameter called 'ipam_url' exists (method_parameter_exists)
manageiq_automate:
workspace: "{{ workspace }}"
method_parameter_exists:
parameter: "ipam_url"
register: method_parameter_exists
- debug: msg="Result:{{ method_parameter_exists.value }}"
- name: Get the value of a method parameter called 'ipam_url' (get_method_parameter)
manageiq_automate:
workspace: "{{ workspace }}"
get_method_parameter:
parameter: "ipam_url"
register: method_parameter
- debug: msg="Result:{{ method_parameter.value }}"
- debug: msg="(The same from a built-in var:{{ ipam_url }})"
- name: Decrypt a method_parameter called 'default_password' (get_decrypted_method_parameter)
manageiq_automate:
workspace: "{{ workspace }}"
get_decrypted_method_parameter:
attribute: default_password
register: decrypted_method_parameter
- debug: msg=Result:{{ decrypted_method_parameter.value }}
- debug: msg="(The same from a built-in var:{{ default_password }})"
# Working with Objects:
#
# 'object_exists'
# 'get_object_names'≠≠≠
# 'get_object_attribute_names'
# 'get_vmdb_object'
#- name: check whether the configuration domain exists in the workspace (object_exists)
# manageiq_automate:
# workspace: "{{ workspace }}"
# object_exists:
# object: "/Configuration/OpenShift/Parameters/default"
# register: object_exists
#- debug: msg="Result:{{ object_exists.value }}"
- name: Get the full list of objects/instances in the workspace (get_object_names)
manageiq_automate:
workspace: "{{ workspace }}"
get_object_names: yes
register: workspace_object_names
- debug: msg="Result:{{ workspace_object_names.value }}"
- name: Get the list of root object attribute names (get_object_attribute_names)
manageiq_automate:
workspace: "{{ workspace }}"
get_object_attribute_names:
object: "root"
register: root_object_attribute_names
- debug: msg="Result:{{ root_object_attribute_names.value }}"
- name: "Get each of the root object's attributes (get_attribute)"
manageiq_automate:
workspace: "{{ workspace }}"
get_attribute:
object: root
attribute: "{{ item }}"
ignore_errors: yes
loop: "{{ root_object_attribute_names.value }}"
register: root_attributes
- name: Get the root object's href'able attributes as objects (get_vmdb_object)
manageiq_automate:
workspace: "{{ workspace }}"
get_vmdb_object:
object: root
attribute: "{{ item }}"
no_log: True
loop:
- miq_server
- user
- miq_group
- tenant
register: objects
- debug: msg="Result:{{ objects|dict2items }}"
# Working with attributes:
#
# 'attribute_exists':
# 'get_attribute'
# 'get_decrypted_attribute'
# 'get_object_attribute_names'
# 'set_attribute'
# 'set_attributes'
# 'set_encrypted_attribute'
- name: Get the full list of configuration domain attribute names (get_object_attribute_names)
manageiq_automate:
workspace: "{{ workspace }}"
get_object_attribute_names:
object: "/Configuration/OpenShift/Parameters/default"
register: configuration_domain_attribute_names
- debug: msg="Result:{{ configuration_domain_attribute_names.value }}"
- name: Check if an object/instance attribute exists (attribute_exists)
manageiq_automate:
workspace: "{{ workspace }}"
attribute_exists:
object: "/Configuration/OpenShift/Parameters/default"
attribute: "rhel_subscription_pool"
register: attribute_exists
- debug: msg="Result:{{ attribute_exists.value }}"
- name: Get the "rhel_subscription_pool" attribute from a configuration domain instance (get_attribute)
manageiq_automate:
workspace: "{{ workspace }}"
get_attribute:
object: "/Configuration/OpenShift/Parameters/default"
attribute: "rhel_subscription_pool"
register: rhel_subscription_pool
- debug: msg="Result:{{ rhel_subscription_pool }}"
- name: Get the "ldap_user_password" encrypted attribute from a configuration domain instance (get_decrypted_attribute)
manageiq_automate:
workspace: "{{ workspace }}"
get_decrypted_attribute:
object: "/Configuration/OpenShift/Parameters/default"
attribute: "ldap_user_password"
register: ldap_user_password
- debug: msg="Result:{{ ldap_user_password }}"
- name: Get the "rhel_subscription_pass" encrypted attribute from a configuration domain instance (get_decrypted_attribute)
manageiq_automate:
workspace: "{{ workspace }}"
get_decrypted_attribute:
object: "/Configuration/OpenShift/Parameters/default"
attribute: "rhel_subscription_pass"
register: rhel_subscription_pass
- debug: msg="Result:{{ rhel_subscription_pass.value }}"
- name: Get the value of the "ipam_passwd" attribute defined by a prior Ruby method (get_attribute)
manageiq_automate:
workspace: "{{ workspace }}"
get_attribute:
object: root
attribute: "ipam_passwd"
register: ipam_password
ignore_errors: yes
- debug:
msg: Result = {{ ipam_password.value }}
when: ipam_password is succeeded
- name: Set a "domain_name" root attribute (set_attribute)
manageiq_automate:
workspace: "{{ workspace }}"
set_attribute:
object: "root"
attribute: "domain_name"
value: "company.org"
- name: Set several IPAM-related root attributes (set_attributes)
manageiq_automate:
workspace: "{{ workspace }}"
set_attributes:
object: "root"
attributes:
ipam_ip_address: "192.168.1.23"
ipam_netmask: "255.255.255.0"
ipam_gateway: "192.168.2.254"
- name: Encrypt a "root_passwd" object attribute (set_encrypted_attribute)
manageiq_automate:
workspace: "{{ workspace }}"
set_encrypted_attribute:
object: root
attribute: "root_passwd"
value: "very_very_secret"
- name: Decrypt an attribute from an object (get_decrypted_attribute)
manageiq_automate:
workspace: "{{ workspace }}"
get_decrypted_attribute:
object: root
attribute: "root_passwd"
register: decrypted_attribute
- debug: msg=Result:{{ decrypted_attribute.value }}
# Working with state machines:
#
# 'set_retry'
# 'get_state_var_names'
# 'state_var_exists'
# 'get_state_var'
# 'set_state_var'
- name: Get the list of state vars (get_state_var_names)
manageiq_automate:
workspace: "{{ workspace }}"
get_state_var_names: yes
register: get_state_var_names
- debug: msg="Result:{{ get_state_var_names.value }}"
- name: Check whether a "task_id" state var exists (state_var_exists)
manageiq_automate:
workspace: "{{ workspace }}"
state_var_exists:
attribute: "task_id"
register: state_var_exists
- debug: msg="Result:{{ state_var_exists.value }}"
- name: Get the value of the "request_id" state var (get_state_var)
manageiq_automate:
workspace: "{{ workspace }}"
get_state_var:
attribute: "request_id"
register: state_var1
- debug:
msg: Result = {{ state_var1.value }}
- name: Get the value of the "task_id" state var (get_state_var)
manageiq_automate:
workspace: "{{ workspace }}"
get_state_var:
attribute: "task_id"
register: state_var2
- debug:
msg: Result = {{ state_var2.value }}
- name: Set a "job_id" state var (set_state_var)
manageiq_automate:
workspace: "{{ workspace }}"
set_state_var:
attribute: "job_id"
value: "68008"
- name: Get the value of ae_state_retries
manageiq_automate:
workspace: "{{ workspace }}"
get_attribute:
object: root
attribute: "ae_state_retries"
register: ae_state_retries
- debug:
msg: State retry number {{ ae_state_retries.value }}
- name: Set state status to retry
manageiq_automate:
workspace: "{{ workspace }}"
set_retry:
interval: 60
when: ae_state_retries.value|int < 3
#- debug:
# msg: State retry number {{ workspace.workspace.input.objects.root.ae_state_retries }}
#- name: Set state status to retry
# manageiq_automate:
# workspace: "{{ workspace }}"
# set_retry:
# interval: 30
# when: workspace.workspace.input.objects.root.ae_state_retries|int < 3
#- name: dump the workspace
# hosts: localhost
# roles:
# - ansible-role-listvars