Open gasoo44 opened 4 years ago
Are constructed inventories not supported
It's something I never heard of before to be honest, so I never built any official support in for it.
It looks pretty powerful, so implementing support for this is not going to be easy. Currently ansible-cmdb uses its own host/var/fact parser. That's pretty clumsy, so I want to start using ansible's own parsers. There's a PR request open for that (#215) which I intend to review and merge. However, no garantuees for now that constructed inventories will be supported by that.
Stay tuned...
as a workaround, you could use ansible-inventory --export --output static.json
to dump the original constructed inventory into a "static" variant to pass to ansible-cmdb. Not pretty and probably not performant, though.
@azrdev I tried generating a statiic inventory file as you described. I had to add --list as it is mandatory to add --list, --graph or --host
ansible-inventory -i inventories/hosts.yml -i inventories/inventory.config --export --list --output static.json
As far as I can tell, the resulting json file looks to be valid.
{
"Group_1": {
"hosts": [
"host1",
"host2",
"host3"
],
"vars": {
"var1": "value1",
"var2": "value2",
"var3": "Value3"
....cut....
However, ansible-cmdb does throw errors when using the static json file.
ansible-cmdb --template html_fancy_split -d -i static.json tempo/
Determining type of inventory_path static.json
static.json is a file. Handle as static inventory file
Inventory path static.json is a file. Reading as inventory.
Unsupported vars syntax. Skipping line: "Group_1": {
Unsupported vars syntax. Skipping line: "hosts": [
Unsupported vars syntax. Skipping line: "vars": {
...cut....
I also tried with yaml as output but the errors are the same. Does ansible-cmdb require ini inventories?
Does ansible-cmdb require ini inventories?
@gasoo44 I do think so. Have you tried ansible-inventory --toml
?
It seems that ansible-cmdb does not recognize my constructed inventory file as a dynamic inventory. I followed the example from the ansible website: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/constructed_inventory.html
But when ansible-cmdb runs, it seems to think that the file inventory.config is a static inventory file and does not parse it correctly.
Are constructed inventories not supported or have I made a mistake?
Thanks