
But I would say to use the “.ini” format as in this you are not bound to use any keywords every time.
Indentation is very important to maintain, otherwise, you will have syntaxĮxample: Below is the contents of the file name “abc.yaml”īoth of the above have different advantages over others, but both work fine in all cases and easy to reuse, read, and modify. In this format file, Single host entry can end without “:”, but more than one entry has to be ended with “:”, like in below example. File extension must be “.yaml” or “.yml” or “.json”. Children are ‘child groups’, which can also have their own “vars” or “hosts” “children” and so. defined sub-entries of any Host entries will be treated as. It must start with the “all” group and contain “hosts”, “vars” and “children” entries. YAML (YAML Ain’t Markup Language, which is a structural language supports parent-children formatting):. These can also be grouped based on your environment or some common property like below: INI (the plain text format): This is a plain file with a key name and its value. There are two types of formats supported in Ansible environments Then, an order of preference will be followed which is below: – On Ansible controller host, the default location of the hosts’ file is /etc/ansible/hosts, but if that file is missing or hosts files are available at other locations. ~/.ansible.cfg (in your home directory). ANSIBLE_CONFIG (environment variable if set). Ansible searches for “ansible.cfg” in these mentioned locations in the below order and obviously, according to the configuration file the inventory file will be realized while running playbooks. Ansible uses the first “ansible.cfg” file it finds and ignores others. In such cases, values set in configuration files have lower precedence. Those files will be realized by Ansible in alphabetical order of their file names.Īlso, that hosts file which can be used from the /etc/ansible/ansible.cfg file, environment variables “ANSIBLE_CONFIG”, the user’s current working directory or user’s home directory. Which can be set against the parameter “inventory”, Like below:Īlso, if you have multiple hosts files, then you can set a directory location against the parameter “inventory” in /etc/ansible/ansible.cfg and resides all your hosts’ files in that directory.
You can set your default hosts file location in it. Web development, programming languages, Software testing & othersīut it can be modified in /etc/ansible/ansible.cfg file, which is the default ansible configuration file. Start Your Free Software Development Course