running playbook for windows plus dynamic inventory and dynamic groups_vars

98 views
Skip to first unread message

Ritesh Shetty

unread,
May 13, 2015, 2:17:43 AM5/13/15
to ansible...@googlegroups.com, ritesh...@hp.com
Hi
I have a requirement to run playbook on hyperv compute nodes (windows) i tried the method mentioned to keep all variables .

ansible_ssh_user: Administrator
ansible_ssh_pass: password
ansible_ssh_port: 5986
ansible_connection: winrm


I use dynamic inventory to get the target hosts dynamically. Since the hosts are not static and they keep changing i cannot keep the above variables in a static file in group_vars

Question is can group_vars be passed as part of the dynamic inventory json ? Can i have a section in _meta as group_vars ? if yes what would be the structure ?

{
    "_meta": {
        "hostvars": {
            "192.168.0.68": {
                "username": "Administrator",
                "hypervisor_type": "hyperv",
                "hypervisor_id_list": [
                    "2"
                ],
                "password": "password",
                "port": "5986"
            }
        }
    },
    "computenodes": {
        "hosts": [
            "192.168.0.68"
        ]
    }
}


Andrea Tartaglia

unread,
May 13, 2015, 3:27:17 AM5/13/15
to ansible...@googlegroups.com, ritesh...@hp.com
Hi, 

you just have to add “vars” to the group name, so assuming “computenodes” is your group you would have something like:

"computenodes": {
        "hosts": [
            "192.168.0.68"
        ],
“vars”:{
   “var1”: “Var”,
  “var2”: 2
}
    }
Have a look here:


Andrea




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/54d59730-8f73-4402-b008-4fb7b4ee136e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc

Ritesh Shetty

unread,
May 14, 2015, 2:24:36 PM5/14/15
to ansible...@googlegroups.com, m...@andreatartaglia.com, ritesh...@hp.com
Thank you It works !!
Reply all
Reply to author
Forward
0 new messages