Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you convert ansible ini inventory into json or yaml

Ansible AWX requires inventories to be entered in yaml or json format.

When you start learning ansible, you may take the choice to start off with your inventory in ini format.

https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html

Is it possible to convert between formats?

like image 578
user1717259 Avatar asked Aug 30 '19 13:08

user1717259


People also ask

What format are Ansible inventory files formatted it?

ansible. builtin. yaml inventory – Uses a specific YAML file as an inventory source.

What is INI file in Ansible?

INI file based inventory, sections are groups or group related with special :modifiers . Entries in sections [group_1] are hosts, members of the group. Hosts can have variables defined inline as key/value pairs separated by = . The children modifier indicates that the section contains groups.


Video Answer


1 Answers

Example given here

https://evrard.me/convert-ansible-inventories-with-ansible-inventory-cli

ansible-inventory -i inventory.ini -y --list > inventory.yaml

The -y flag gives yaml output. Omitting the flag gives json.

like image 122
user1717259 Avatar answered Nov 15 '22 12:11

user1717259