forked from xcloudlive/ansible-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redfish_info.yml
46 lines (44 loc) · 1.39 KB
/
redfish_info.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
---
- name: check server health based on redfish rest service
hosts: all
gather_facts: no
vars:
result: ok
tasks:
- name: Check if server is health
block:
- debug:
var: inventory_hostname
- name: do checking....
uri:
url: "https://{{ inventory_hostname }}/redfish/v1/Systems/1"
# refer to group_vars/huawei_redfish.yml
url_username: "{{ username }}"
url_password: "{{ password }}"
force_basic_auth: yes
return_content: yes
validate_certs: no
timeout: 5
status_code: 200
register: contents
delegate_to: localhost
# - debug: var=contents
- name: check if it is health
debug: msg="{{ contents.json | json_query(jmesquery) }}"
register: status
vars:
jmesquery: "{SerialNumber: SerialNumber, Model: Model, Manufacturer: Manufacturer, UUID: UUID, Health:Status.Health}"
failed_when: status.msg.Health != "OK"
rescue:
- set_fact:
result: failed
- fail:
msg: error is happened
when: result == "failed"
- name:
debug:
msg: "I also never execute :-("
always:
- name: always to check result
debug:
msg: "all tasks are finished, result is {{ result }}"