Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include the Ansible config file in the ansible-playbook command?

Tags:

ansible

I run my ansible-playbook with the following command in my localhost:

ansible-playbook -i "localhost," -c local GitClone.yaml

However, I also have a GitClone.cfg file which has:

[defaults]
transport = ssh

[ssh_connection]
ssh_args = -o ForwardAgent=yes

The GitClone.cfg file is in the same directory as the GitClone.yaml file.

How do I include this file in the command?

The command mentioned above is not picking up the .cfg file.

like image 699
Dawny33 Avatar asked Feb 05 '23 05:02

Dawny33


2 Answers

The proper name for the Ansible configuration file is ansible.cfg.

It is a fixed name and Ansible does not look for any other .cfg file unless you explicitly provided the path in ANSIBLE_CONFIG variable.

Have a look at the documentation. Ansible checks the files in the following order:

  • ANSIBLE_CONFIG (an environment variable)
  • ansible.cfg (in the current directory)
  • .ansible.cfg (in the home directory)
  • /etc/ansible/ansible.cfg
like image 122
techraf Avatar answered Mar 05 '23 16:03

techraf


The above documentation link got expired

Here is the sample ansible.cfg file from ansible git repo https://github.com/ansible/ansible/blob/stable-2.9/examples/ansible.cfg

Documentation link: https://docs.ansible.com/ansible/latest/reference_appendices/config.html

enter image description here

for checking which configuration values are active in a current directory. run the below commands will provide you the infromation enter image description here

like image 45
buchi manikanta reddy Avatar answered Mar 05 '23 17:03

buchi manikanta reddy