GiorgioRegni / AnsibleScratch

Apache License 2.0
0 stars 0 forks source link

Set OS in Ansilble Hosts File #4

Closed ratmav closed 8 years ago

ratmav commented 8 years ago

We need to be able to assign the OS to each node type, probably using a variable. The OS variable is used to determine whether to run apt or yum, etc. Here's a sketch of what it needs to look like:

[frontend] 
proxy1      ansible_user=root   ansible_host=192.168.1.15 operatingSystem=cent7
proxy2      ansible_user=root   ansible_host=192.168.1.16 operatingSystem=cent7

[storage] 
node1  ansible_user=ubuntu ansible_host=192.168.0.13 operatingSystem=ubuntu14
node2  ansible_user=ubuntu ansible_host=192.168.0.14 operatingSystem=ubuntu14
node3  ansible_user=ubuntu ansible_host=192.168.0.15 operatingSystem=ubuntu14
node4  ansible_user=ubuntu ansible_host=192.168.0.16 operatingSystem=ubuntu14
node5  ansible_user=ubuntu ansible_host=192.168.0.17 operatingSystem=ubuntu14

If Ansible's variable support in the hosts file doesn't do what we need, Write a Python script that parses a custom YAML configuration file and generates the ansible_hosts file in the necessary format.

ratmav commented 8 years ago

The variable works fine. Closing out.