Disclaimer: I'm new to ansible and couldn't find an answer here, here or here.
I need to run a playbook against 2 hosts. I understand how to do that with a static inventory in yaml
or INI
format, but I'm lost when trying it using a dynamic inventory--specifically, VMWare dynamic inventory - vmware_inventory.py .
The results of running the dynamic inventory look like this:
{
"_meta": {
"hostvars": {
"foo_420be125-0a38-6dcd-247c-1d1839717804": {
"ansible_connection": "ssh",
"ansible_user": "root",
"config.cpuHotAddEnabled": false,
"config.cpuHotRemoveEnabled": false,
"config.hardware.numCPU": 4,
"config.instanceUuid": "500b86dc-b51e-25fb-165d-e51c62ecd725",
"config.name": "foo",
"config.template": false,
"guest.guestId": null,
"guest.guestState": "notRunning",
"guest.hostName": "foo.bar.com",
"guest.ipAddress": "1.2.3.4",
"name": "foo",
"runtime.maxMemoryUsage": null,
"stage": "dev"
},
"bar_fffe-6f29-3e32-0ce9a80d0ad3": {
"ansible_connection": "ssh",
...
}
},
"activedirectory-devops": {
"hosts": [
"foo_420be125-0a38-6dcd-247c-1d1839717804",
"bar_fffe-6f29-3e32-0ce9a80d0ad3"
]
},
"all": {
"children": [
"activedirectory-devops",
"centos64Guest",
"centos7_64Guest",
"com.vmware.vr.HasVrDisks",
"other3xLinux64Guest",
"otherGuest",
...
NOTE: activedirectory-devops
is a "tag" in VMWare vCenter that is (apparently) returned as an ansible "host group".
Given that, how can I run a playbook against the hosts in activedirectory-devops
? After all, "foo_420be125-0a38-6dcd-247c-1d1839717804" can't be resolved by DNS.
My best guess is:
ansible-playbook -i vmware.yml site.yml