Hi,

Thank you for your reply.

I can create this structure in YAML format, but what i really want to 
achieve is pass this structure as json/yaml variable. As I read this YAML 
plugin still require to save structure to file and than pass it to ansible 
API (if I'm wrong please correct me).
To be more precise (using example from: ansible Python API 
<https://docs.ansible.com/ansible/latest/dev_guide/developing_api.html#python-api>)
 
I would like to create inventory variable like below;

# create inventory, use path to host config file as source or hosts in a 
comma separated string 
inventory = InventoryManager(loader=loader, sources=sources)

where source would be like:
source = {
'hosts': { 
    'hosts': ['host001', 'host001'], 
    'vars': { 
        'var01': "value01",
    } 
},
'_meta': { 
    'hostvars': { 
        'host001': { 'var001' : "value02" },
        'host002': { 'var002': "value03" }
     } 
} 
}
Here I use json format, but it can be any YAML formatted variable.

Best regards
Filip
On Wednesday, January 27, 2021 at 4:59:15 PM UTC+1 Brian Coca wrote:

> You can feed JSON to the YAML inventory plugin (since JSON is mostly
> a subset of YAML), but it must follow the structure it uses, which is
> different than the inventory script.
>
>
> -- 
> ----------
> Brian Coca
>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ac24ced1-7467-435f-9c6f-f711eb179366n%40googlegroups.com.

Reply via email to