blob: 7281c259562d534bef0191b27a61c75c2f77e0c0 (
plain)
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
|
---
#
# The hosts group used is provided by the group variable or defaulted to 'Intersight_Servers'.
# You can specify a specific host (or host group) on the command line:
# ansible-playbook ... -e group=<your host group>
# e.g., ansible-playbook server_profiles.yml -e group=TME_Demo
#
- hosts: "{{ group | default('Intersight_Servers') }}"
collections:
- cisco.intersight
connection: local
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
tasks:
# Get HclStatus
- name: Get HCL Status for Server
intersight_rest_api:
<<: *api_info
resource_path: /cond/HclStatuses
query_params:
$filter: "ManagedObject.Moid eq '{{ server_moid }}'"
delegate_to: localhost
register: hcl_resp
when:
- server_moid is defined
# Create .csv file with version and status information
- copy:
content: |
Name, FW version, OS vendor, OS version, HW status, SW status, Overall Status
{% for host in hostvars %}
{% set vars = hostvars[host|string] %}
{% if vars.hcl_resp.api_response is defined %}
{{ vars.inventory_hostname }}, {{ vars.hcl_resp.api_response.HclFirmwareVersion }}, {{ vars.hcl_resp.api_response.HclOsVendor }}, {{ vars.hcl_resp.api_response.HclOsVersion }}, {{ vars.hcl_resp.api_response.HardwareStatus }}, {{ vars.hcl_resp.api_response.SoftwareStatus }}, {{ vars.hcl_resp.api_response.Status }} {{ vars.hcl_resp.api_response.ServerReason }}
{% endif %}
{% endfor %}
dest: /tmp/hcl_status.csv
backup: false
run_once: true
delegate_to: localhost
|