# Load ansible.cfg in each playbook dir

**URL:** <https://forum.ansible.com/t/load-ansible-cfg-in-each-playbook-dir/35314>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [June 8, 2021, 8:09pm UTC](https://forum.ansible.com/t/load-ansible-cfg-in-each-playbook-dir/35314 "2021-06-08T20:09:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Baptiste\_Doublet](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@Baptiste\_Doublet](https://forum.ansible.com/u/Baptiste_Doublet)\
**Post date:** [June 8, 2021, 8:09pm UTC](https://forum.ansible.com/t/load-ansible-cfg-in-each-playbook-dir/35314/1 "2021-06-08T20:09:39Z")

</div>

Hello,

I’m looking for a solution to load local ansible.cfg at root playbook\_dir.  
This is my architeture folder of playbooks:

ansible  
├── deploy\_manager  
│ ├── ansible.cfg  
│ ├── deploy\_manager.yml  
│ ├── environments  
│ │ ├── demo  
│ │ │ ├── group\_vars  
│ │ │ │ └── demo.yml  
│ │ │ ├── inventory.yml  
│ │ │ └── vars  
│ │ │ └── vault.yml  
│ │ ├── int  
│ │ │ ├── group\_vars  
│ │ │ │ └── int.yml  
│ │ │ ├── inventory.yml  
│ │ │ └── vars  
│ │ │ └── vault.yml  
│ │ └── prod  
│ │ ├── group\_vars  
│ │ │ └── prod.yml  
│ │ ├── inventory.yml  
│ │ └── vars  
│ │ └── vault.yml  
│ ├── README.md  
│ └── roles  
│ ├── create\_instance  
│ │ └── tasks

│ │ └── main.yml

When I execute the playbook with ansible-playbook cli, I have an ansible.cfg in current dir so ansible.cfg is loaded.

When I execute the playbook from AWX, the project is in tmp/cev039fj/awx\_1900\_tw78u5vh/project.  
There is no ansible.cfg in /tmp/ cev039fj/awx\_1900\_tw78u5vh so it’s the /etc/ansible/ansible.cfg which is loaded.  
I have an ansible.cfg in each playbook directory with different params so how could I setup the ANSIBLE\_CONFIG path to playbook dir ansible.cfg when a playbook is launched by AWX ?

I did some tests unsuccessful with ANSIBLE\_CONFIG setup.

Have you any ideas ?

Thanks

---

<div class="post-metadata">

**Author:** ![Seth\_Foster](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Seth\_Foster](https://forum.ansible.com/u/Seth_Foster)\
**Post date:** [June 9, 2021, 12:03am UTC](https://forum.ansible.com/t/load-ansible-cfg-in-each-playbook-dir/35314/2 "2021-06-09T00:03:06Z")

</div>

Hi!

ansible.cfg should be at the root directory of your playbook (in your example, ansible.cfg should be in the directory tmp/cev039fj/awx\_1900\_tw78u5vh/project)

_“In order to use a custom ansible.cfg file, place it at the root of your project. Ansible Tower runs ansible-playbook from the root of the project directory, where it will then find the custom ansible.cfg file. An ansible.cfg anywhere else in the project will be ignored.”_

[https://docs.ansible.com/ansible-tower/latest/html/administration/tipsandtricks.html#locate-and-configure-the-ansible-configuration-file](https://docs.ansible.com/ansible-tower/latest/html/administration/tipsandtricks.html#locate-and-configure-the-ansible-configuration-file)

---

<div class="post-metadata">

**Author:** ![Baptiste\_Doublet](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@Baptiste\_Doublet](https://forum.ansible.com/u/Baptiste_Doublet)\
**Post date:** [June 9, 2021, 12:19am UTC](https://forum.ansible.com/t/load-ansible-cfg-in-each-playbook-dir/35314/3 "2021-06-09T00:19:11Z")

</div>

Thanks for your answer.  
That means there is no solution to have an ansible.cfg per playbook directory ?

I have several playbooks directories like deploy\_manager in ansible folder with specific ansible.cfg.

I searched for a solution with ANSIBLE\_CONFIG maybe set dynamically at job execution. For example, there is AWX\_PRIVATE\_DATA\_DIR which is set to /tmp/cev039fj/awx\_1900\_tw78u5vh/ in envvars so I tried something like ANSIBLE\_CONFIG=$PRIVATE\_DATA\_DIR but don’t know if AWX load it before playbooks execution.

To sum up, I have this folder and need to load specific ansible.cfg if I execute deploy\_manager.yml or deploy\_manager2.yml

ansible  
├── deploy\_manager  
│ ├── ansible.cfg  
│ ├── deploy\_manager.yml  
│ ├── environments  
│ └── roles  
│ ├── create\_instance  
│ │ └── tasks

│ │ └── main.yml  
├── deploy\_manager\_2  
│ ├── ansible.cfg  
│ ├── deploy\_manager\_2.yml  
│ ├── environments  
│ └── roles  
│ ├── create\_instance\_2  
│ │ └── tasks

│ │ └── main.yml

Maybe, there is no way ?
