Hello,
I am currently writing an dynamic inventory to query out central database (CMDB.
Regarding to http://docs.ansible.com/developing_inventory.html, I am implementing the _meta field for host variables. As far as I understood, “_meta” resolves in the function “–host” to be deprecated. So i just wrote a ‘stupid’ script without any parameters.
My output looks like this:
{
“ungrouped”: {
“hosts”: [
“ServerA”,
“ServerB”
]
},
“_meta”: {
“hostvars”: {
“ServerA”: {
“ansible_ssh_host”: “192.168.0.1”
},
“ServerB”: {
“ansible_ssh_host”: “192.168.0.2”
}
}
}
}
Everything should be fine. But running ansible produces the following error (Ignore the first 2 lines. Those are warnings regarding to the SLES version of libraries):
user@host ~/git/ansible $ ansible-playbook site.yml -i /tmp/dyn_cmdb_inv.py
/usr/lib64/python2.6/site-packages/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.
_warn(“Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.”, PowmInsecureWarning)
Traceback (most recent call last):
File “/usr/bin/ansible-playbook”, line 269, in
sys.exit(main(sys.argv[1:]))
File “/usr/bin/ansible-playbook”, line 86, in main
inventory = ansible.inventory.Inventory(options.inventory)
File “/usr/lib64/python2.6/site-packages/ansible/inventory/init.py”, line 105, in init
self.parser = InventoryParser(filename=host_list)
File “/usr/lib64/python2.6/site-packages/ansible/inventory/ini.py”, line 41, in init
self._parse()
File “/usr/lib64/python2.6/site-packages/ansible/inventory/ini.py”, line 45, in _parse
self._parse_base_groups()
File “/usr/lib64/python2.6/site-packages/ansible/inventory/ini.py”, line 83, in _parse_base_groups
tokens = shlex.split(line)
File “/usr/lib64/python2.6/shlex.py”, line 279, in split
return list(lex)
File “/usr/lib64/python2.6/shlex.py”, line 269, in next
token = self.get_token()
File “/usr/lib64/python2.6/shlex.py”, line 96, in get_token
raw = self.read_token()
File “/usr/lib64/python2.6/shlex.py”, line 172, in read_token
raise ValueError, “No closing quotation”
ValueError: No closing quotation
Do you have any hint, why this error is produced? All quotations and formats are correct. The output is generated in python with “print (json.dumps(inventory, cls=DateEncoder, indent=4))”, while “inventory” is a dictionary.
Thank you.
Alex