Hi all,

I developed a small playbook which uses an inventory file to store my 
variables.
I chose an ini format since it is more easy to define groups and it makes 
the file more organize and readable.
My first question is, do you recommend this type of management, though an 
ini file, or is there another alternative way to do this?

Now, I want to build a new ansible tool, that generates this inventory ini 
file using the user input.
I saw a module called ini_file which I thought might be helpful, but it 
seems that it format the file different than the ini format described in 
the ansible documentation 
http://docs.ansible.com/ansible/latest/intro_inventory.html

Here are few examples of the differences between the two:
1. ini_file module - When adding a value with ini_file module the syntax 
must always be [key]=[value] even if there is no value:
[webservers]
foo=foo.example.com
bar=None

ansible docs - In the docs the ini file uses standalone names, so we can 
have a group with only hostnames, for example:
[webservers]
foo.example.com
bar.example.com

2. ini_file module - It is not possible to declare host variables in a one 
liner:
[atlanta]
http_port=80
maxRequestsPerChild=808

ansible docs:
[atlanta]
host1 http_port=80 maxRequestsPerChild=808

Also it seems that the ini_file module does not support reading from the 
ini file only insert or update.

What do you recommend for the best approach? is there any other ansible 
module I can use to manipulate data in my INI file or should I use a 
different approach? 

Here is an example of my ini file:
# INI file
[data_storage]
data_storage name=name1 address1=12.12.12.12 path1=data_storage dc_name=DC1


[data_storage_ver2]
data_storage_ver2 name=name2 address1=12.12.12.13 path1=data_storage2 
dc_name=DC2


[storage:children]
data_storage
data_storage_ver2


The playbook looks like this:
# main playbook 
....
....
- include: library/add_NFS_domain.yml storage={{ item }}
  with_inventory_hostnames: storage
....


# task file
- ovirt_hosts_facts:
   pattern: "status=up and datacenter={{ hostvars[storage]['dc_name'] }}"
   auth: "{{ ovirt_auth }}"


- ovirt_storage_domains:
        name: "{{ hostvars[storage]['name'] }}"
        host: "{{ ovirt_hosts[0].name }}"
        data_center: "{{ hostvars[storage]['dc_name'] }}"
        auth: "{{ ovirt_auth }}"
        nfs:
                address: "{{ hostvars[storage]['ip1'] }}"
                path: "{{ hostvars[storage]['path1'] }}"



-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3e4a9e25-1853-4963-95e8-b65e1cc85b69%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to