-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab12_task02_reboot_history.yml
51 lines (46 loc) · 1.35 KB
/
lab12_task02_reboot_history.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: MAKING API CALLS USING THE REAL TIME API
hosts: all
connection: local
gather_facts: no
tasks:
- name: ENSURE REPORTS DIRECTORY EXISTS
file:
path: ./reports
state: directory
run_once: true
- name: GET COOKIE WITH POST
uri:
url: "https://{{ inventory_hostname }}/j_security_check"
method: POST
body:
j_username: "{{ username }}"
j_password: "{{ password }}"
body_format: form-urlencoded
return_content: yes
validate_certs: no
register: login_data
- name: ASSIGN THE SESSION COOKIE TO A VARIABLE
set_fact:
vmanage_cookie: "{{ login_data.set_cookie }}"
- name: VIEW THE COOKIE
debug:
var: vmanage_cookie
- name: PAUSE FOR VIEWING THE COOKIE
pause:
seconds: 3
- name: GET REBOOT HISTORY DETAILS
uri:
url: "https://{{ inventory_hostname }}/dataservice/device/reboothistory/details"
method: GET
headers:
Cookie: "{{ vmanage_cookie }}"
return_content: yes
validate_certs: no
register: reboot_history
- name: PRINT REBOOT HISTORY
debug:
var: reboot_history
- name: CREATE REBOOT STATS REPORT
template:
src: reboot-history-report.j2
dest: ./reports/reboot-history.txt