[root@localhost ~]# cat gfacts.yml
---
- hosts: localhost
connection: local
tasks:
- name: get facts from vcenter
vsphere_guest:
vcenter_hostname: 192.168.0.103
username: root
password: vmware
guest: cento
vmware_guest_facts: yes #Gather facts from vCenter on a particular VM
validate_certs: no
register: facts
- name: show msg
debug: msg="{{facts}}"
[root@localhost ~]# ansible-playbook gfacts.yml
PLAY [localhost] *************************************************************************************************************************************
TASK [Gathering Facts] *******************************************************************************************************************************
ok: [localhost]
TASK [get facts from vcenter] ************************************************************************************************************************
ok: [localhost]
TASK [show msg] **************************************************************************************************************************************
ok: [localhost] => {
"msg": {
"ansible_facts": {
"hw_eth0": {
"addresstype": "assigned",
"ipaddresses": [],
"label": "Network adapter 1",
"macaddress": "00:50:56:93:0f:66",
"macaddress_dash": "00-50-56-93-0f-66",
"summary": "VM Network"
},
"hw_guest_full_name": "CentOS 4/5/6/7 (64-bit)",
"hw_guest_id": "centos64Guest",
"hw_instance_uuid": "501316f5-c97e-27a8-f2e4-2cdd78fdede8",
"hw_interfaces": [
"eth0"
],
"hw_memtotal_mb": 512,
"hw_name": "cento",
"hw_power_status": "POWERED OFF",
"hw_processor_count": 1,
"hw_product_uuid": "4213b043-04ca-ca0b-02db-dac960b3842a",
"module_hw": true
},
"changed": false,
"failed": false
}
}
PLAY RECAP *******************************************************************************************************************************************
localhost : ok=3 changed=0 unreachable=0 failed=0
---
- hosts: localhost
connection: local
tasks:
- name: get facts from vcenter
vsphere_guest:
vcenter_hostname: 192.168.0.103
username: root
password: vmware
guest: cento
vmware_guest_facts: yes #Gather facts from vCenter on a particular VM
validate_certs: no
register: facts
- name: show msg
debug: msg="{{facts}}"
[root@localhost ~]# ansible-playbook gfacts.yml
PLAY [localhost] *************************************************************************************************************************************
TASK [Gathering Facts] *******************************************************************************************************************************
ok: [localhost]
TASK [get facts from vcenter] ************************************************************************************************************************
ok: [localhost]
TASK [show msg] **************************************************************************************************************************************
ok: [localhost] => {
"msg": {
"ansible_facts": {
"hw_eth0": {
"addresstype": "assigned",
"ipaddresses": [],
"label": "Network adapter 1",
"macaddress": "00:50:56:93:0f:66",
"macaddress_dash": "00-50-56-93-0f-66",
"summary": "VM Network"
},
"hw_guest_full_name": "CentOS 4/5/6/7 (64-bit)",
"hw_guest_id": "centos64Guest",
"hw_instance_uuid": "501316f5-c97e-27a8-f2e4-2cdd78fdede8",
"hw_interfaces": [
"eth0"
],
"hw_memtotal_mb": 512,
"hw_name": "cento",
"hw_power_status": "POWERED OFF",
"hw_processor_count": 1,
"hw_product_uuid": "4213b043-04ca-ca0b-02db-dac960b3842a",
"module_hw": true
},
"changed": false,
"failed": false
}
}
PLAY RECAP *******************************************************************************************************************************************
localhost : ok=3 changed=0 unreachable=0 failed=0
Comments
Post a Comment