Dynamic inventory with Cobbler

523 views
Skip to first unread message

Shuo Yang

unread,
Feb 4, 2014, 11:41:08 PM2/4/14
to ansible...@googlegroups.com

One question regarding the following code snippet. I would love to hear a high level explanation of what this code has achieved line by line. If it is too long answer to write, I would like to at least understand how/where "a, b, c" is persisted to (are they actually being persisted to host_vars/foo, host_vars/bar and group_vars/webserver?)

Thanks,
Shuo

    -------------
cobbler profile add --name=webserver --distro=CentOS6-x86_64
cobbler profile edit --name=webserver --mgmt-classes="webserver" --ksmeta="a=2 b=3"
cobbler system edit --name=foo --dns-name="foo.example.com" --mgmt-classes="atlanta" --ksmeta="c=4"
cobbler system edit --name=bar --dns-name="bar.example.com" --mgmt-classes="atlanta" --ksmeta="c=5"
-------------

James Tanner

unread,
Feb 5, 2014, 8:38:57 AM2/5/14
to ansible...@googlegroups.com
--
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.
For more options, visit https://groups.google.com/groups/opt_out.

I can't really speak from experience with the cobbler script, but for most other dynamic inventory scripts, vars for each host end up in hostvars[hostname].

http://docs.ansible.com/developing_inventory.html

The the json output from the cobbler script would shed more light on how it works.

James Cammarata

unread,
Feb 5, 2014, 9:42:51 AM2/5/14
to ansible...@googlegroups.com
In the above, a new profile is created based on the CentOS one. This is done so that specific kickstart metadata (the ksmeta options) can be assigned to it. The kickstart metadata will be listed as variables in the Ansible inventory. Two new systems are then created using the new profile, assigned to a management class (the equivalent of a group in Ansible), and additional metadata are assigned to it.

When viewed with --host, the foo server would look like this:

{
  "a": "2", 
  "b": "3", 
  "c": "4"
}

while bar would look like this:

{
  "a": "2", 
  "b": "3", 
  "c": "5"
}



Reply all
Reply to author
Forward
0 new messages