Busra Koken
Busra Koken

Reputation: 273

Is there any way to print out which configuration file ansible using?

According to doc, Ansible uses configuration file in this order:

  1. ANSIBLE_CONFIG (an environment variable)
  2. ansible.cfg (in the current directory)
  3. .ansible.cfg (in the home directory)
  4. /etc/ansible/ansible.cfg

But I still want to see when I run my playbook, at that moment which ansible.cfg is being used?

If I remember correctly, I was able to see when I used verbose mode. But I can not see it now. Version is Ansible 1.9.6

Is there any way to print out which configuration file ansible using? OR any command that I can pass while calling ansible-playbook command with a custom ansible.cfg?

Upvotes: 3

Views: 2314

Answers (2)

Konstantin Suvorov
Konstantin Suvorov

Reputation: 68289

ansible-playbook -v myplaybook.yml does the trick on modern versions: used config file is printed as the first message.

Upvotes: 1

udondan
udondan

Reputation: 60029

When you call ansible with the --version option it will also show you the used configuration file:

$ ansible --version
ansible 2.2.0 (devel 9c5bcda4fe) last updated 2016/09/05 10:38:26 (GMT +000)
  lib/ansible/modules/core: (detached HEAD 982c4557d2) last updated 2016/09/05 11:34:57 (GMT +000)
  lib/ansible/modules/extras: (detached HEAD 06bd2a5ce2) last updated 2016/09/05 11:34:58 (GMT +000)
  config file = /home/user/playbooks/ansible.cfg

Upvotes: 6

Related Questions