Hi All,
I have a current setup in puppet which applies the classes based on facter values on nodes. During provisioning phase i have a file called /etc/company_facts.txt and has values like
role = dev_tst
platform = production
location = london
On the puppetmaster side i assign/define the roles and classes based on facter facts rather than having to define node definitions.
The above is a pull based setup and with mcollective i could do adhoc system management based on facts.
As i see that custom facts can be setup on the client side during provisioning phase easily. something like
custom_role=dev_tst
custom_platform=production
custom_location=london
My question is
- How can i eliminate all the host definitions in the inventory file in a push mode ansible or in ansible-pull setup, which will allow me to apply playbooks based on facts rather then node definitons in the inventory file.
- Allow me do adhoc system management based on facts rather than specifying node definitions in inventory file.
Whole purpose is to eliminate host definitions in the inventory file. Any suggestions/feedback would be helpful.
Regards,
Kevin
Hi All,
I have a current setup in puppet which applies the classes based on facter
values on nodes. During provisioning phase i have a file called
/etc/company_facts.txt and has values like
You can totally do if statements based on Ansible facts (or even reuse
facts from facter or ohai, since the setup module will run them for
you).
You don't even need if statements!
If you want to assign things that feel like roles though, the
"group_by" module is a great thing for this.
http://ansible.cc/docs/modules.html#group-by
Here is an example:
http://ansible.cc/docs/bestpractices.html#operating-system-and-distribution-variance
Whole purpose is to eliminate host definitions in the inventory file. Any
suggestions/feedback would be helpful.
This will eliminate your class definitions. If you don't want to keep
up with inventory entirely, you can use an external inventory script
to
go further and pull inventory/group information from sources like EC2,
Nova, or Cobbler -- or build your own. New in Ansible 1.1 (devel),
Ansible can load a directory if "-i" specifies a directory and use
multiple simultaneous inventory sources, including a mixture of files
and dynamic sources.
Hope this helps!
Hi Micheal,
The group_by sounds a good alternative.
However how would running ad-hoc commands based on system facts work out with ansible?
I just had a wild solution for solving the above problem tonight. The client machines would register its facts in sort of CMDB on the ansible master machine and the ansible command line would read the CMDB and could extract the needed hosts from the requested facts that were presented on the command line. Just any idea. Let me know your feedback.
Regards,
Kevin
group_by does not work with /usr/bin/ansible.
It's very likely when ansible-commander lifts off (starting next week)
we can have iTunes-like smart groups just like you say in the near
future, and you may not even have to use group_by for some things.
TBD... but yes, an external inventory source can totally do this.
--Michael