Hello,
in the past i used this inventory entries.
inventory.ini format:
[DATABASE1]
hostname1.com
[DATABASE2]
hostname47.de
dynamic inventory json format:
{
“DATABASE1” : { “hosts” : [ "hostname1.com ] },
“DATABASE2” : { “hosts” : [ "hostname47.de ] }
}
This setup wors fine.
For internal reasons i have to cahneg the format.
Here is a example that works for me as i expect in inventory.ini format:
[DATABASE1]
DATABASE1_hostname1.com ansible_host=hostname1.com
[DATABASE2]
DATABASE_2_hostname47.de ansible_host=hostname47.de
Can please someone give me the eqivalent json format?
Many thanks
Frank
sivel
(sivel)
April 18, 2018, 2:07pm
2
My recommendation, is to use the ansible-inventory command to show you what the output should look like:
ansible-inventory -i inventory.ini --list
system
(system)
April 18, 2018, 6:08pm
3
for recreating an inventory: ansible-inventory -i inventory.ini --list
--export, w/o the --export it just shows a 'flattened view' which is
what ansible sees internally, good for debugging but not for emulating
in your own inventory source.
Hello,
i did a ansible-inventory -i inventory.ini --list against my working inventory.ini and got the following result:
$ ansible-inventory -i inventory.ini --list
[WARNING]: * Failed to parse /APPL/ansible/cfg/inventory.ini with ini plugin: /APPL/ansible/cfg/inventory.ini:2: Expected key=value host variable assignment, got: :
[WARNING]: Unable to parse /APPL/ansible/cfg/inventory.ini as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
“_meta”: {
“hostvars”: {
“{”: {
“ansible_ssh_pass”: “xxx”,
“ansible_user”: “oracle”
}
}
},
“all”: {
“children”: [
“ungrouped”
]
},
“ungrouped”: {
“hosts”: [
“{”
]
}
}
So i still do not know how the the json format should be…
Frank
Hi
Can you post contents of your inventory.ini
Hello,
as i did in my question - but here again:
[DATABASE1]
DATABASE1_hostname1.com ansible_host=hostname1.com
[DATABASE2]
DATABASE_2_hostname47.de ansible_host=hostname47.de
Hello,
ansible-inventory -i inventory.ini --list worked now fine for me.
(I had a typo in the inventory.ini which prevented ansible-Inventory … --list from working in the correct way).
Many tnaks for all your help!
Frank