-
Notifications
You must be signed in to change notification settings - Fork 15
/
delete_service_generic_objects.yml
45 lines (40 loc) · 1.15 KB
/
delete_service_generic_objects.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
---
- name: Delete the service's generic objects
hosts: localhost
tasks:
- name: Find the generic objects that belong to this service
uri:
url: "{{ manageiq.api_url }}/api/{{ manageiq.service }}?attributes=generic_objects"
method: GET
validate_certs: no
headers:
X-Auth-Token: "{{ manageiq.api_token }}"
body_format: json
register: service
- set_fact:
generic_objects: "{{ service.json.generic_objects }}"
- name: Remove the resources from 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: remove_resource
resource:
resource:
href: "{{ item.href }}"
with_items: "{{ generic_objects }}"
- name: Delete the generic objects
uri:
url: "{{ item.href }}"
method: POST
validate_certs: no
headers:
X-Auth-Token: "{{ manageiq.api_token }}"
body_format: json
body:
action: delete
with_items: "{{ generic_objects }}"