forked from StuC-F88/CW_Ansible_AIX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
show_vm_details.yml
52 lines (43 loc) · 1.84 KB
/
show_vm_details.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
52
---
# Simple playbook to set facts about a VM from gathered facts and command execution
- name: Show VM details
hosts: all
gather_facts: yes
tasks:
- name: Collect OS version for host {{ inventory_hostname }}
command: "oslevel -s"
register: oslevel_info
when:
- ansible_system == "AIX"
- name: Set os_level fact from registered output
set_fact:
os_level: "{{ oslevel_info.stdout }}"
when:
- ansible_system == "AIX"
- name: Collecting processor type for host {{ inventory_hostname }}
set_fact:
proc_type: "{{item}}"
with_items: "{{ansible_processor}}"
- name: Collecting server type for host {{ inventory_hostname }}
set_fact:
server_type: "{{item}}"
with_items: "{{ansible_product_name}}"
- name: Collecting hosting server serial number for host {{ inventory_hostname }}
set_fact:
server_serial: "{{item}}"
with_items: "{{ansible_product_serial}}"
- name: Collecting default IP information for host {{ inventory_hostname }}
set_fact:
default_ip: "{{item}}"
with_items: "{{ansible_default_ipv4.address}}"
- name: Show VM host information from facts gathered in this playbook
debug:
msg: "VM {{ inventory_hostname }} is running on server serial no:{{ server_serial }}, type:{{ server_type }}, processor:{{ proc_type}}"
- name: Show VM default IP information from data collected during gather facts
debug:
msg: "VM {{ inventory_hostname }} has IP {{ ansible_default_ipv4.address }} on interface {{ ansible_default_ipv4.device }}"
- name: Show VM OS level information collected using the command module
debug:
msg: "VM {{ inventory_hostname}} is running AIX version {{ os_level }}"
when:
- ansible_system == "AIX"