-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathset_service_name.yml
52 lines (46 loc) · 1.32 KB
/
set_service_name.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
---
- name: Set Service Name
hosts: all
tasks:
- set_fact:
timestamp: "{{ lookup('pipe', 'date +%Y-%m-%d\\ %H:%M') }}"
- name: Print the service description
debug:
msg: "Service description is {{ description }}"
when: description is defined
- name: Get the existing service name
uri:
url: "{{ manageiq.api_url }}/api/{{ manageiq.service }}"
method: GET
validate_certs: no
headers:
X-Auth-Token: "{{ manageiq.api_token }}"
body_format: json
register: current_service
- name: Update the service name with appended timestamp
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: edit
resource:
name: "{{ current_service.json.name }} {{ timestamp }}"
#- pause:
# minutes: 1
#
#- name: Now delete the service
# uri:
# url: "{{ manageiq.api_url }}/api/services"
# method: POST
# validate_certs: no
# headers:
# X-Auth-Token: "{{ manageiq.api_token }}"
# body_format: json
# body:
# action: delete
# resource:
# href: "{{ manageiq.api_url }}/api/{{ manageiq.service }}"