Awx: ansible.cfg adjacent to playbook inside subdir is ignored

Created on 20 Oct 2017  Â·  2Comments  Â·  Source: ansible/awx

ISSUE TYPE

  • Bug Report
COMPONENT NAME

  • API
SUMMARY

According to the documentation, an ansible.cfg adjacent to a playbook should be picked up and used by Ansible Tower during job run. This is not working.

Instead, ansible.cfg inside a project is only read if it is at the root of the project.

ENVIRONMENT
  • AWX version: 3.2.1.21
  • AWX install method: AMI provided by Ansible
  • Ansible version: 2.4.0.0
  • Operating System: CentOS 7.4.1708
  • Web Browser: Safari 11.0 (12604.1.38.1.7)
STEPS TO REPRODUCE
  1. Create a new project using this repo and the master branch.
  2. Create a Job Template that runs subdir/bug.yml with Show Changes enabled and set the verbosity to 3(Debug).
  3. Run the Job Template.

screen shot 2017-10-20 at 12 38 02

EXPECTED RESULTS

Ansible will see the ansible.cfg adjacent to the playbook and use that. It will be reflected in the debug output:

Identity added: /tmp/awx_66_RIxb4K/credential_3 (/tmp/awx_66_RIxb4K/credential_3)
ansible-playbook 2.4.0.0
  config file = /var/lib/awx/projects/_6__bug_demo/subdir/ansible.cfg
  configured module search path = [u'/var/lib/awx/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Using /var/lib/awx/projects/_6__bug_demo/subdir/ansible.cfg as config file

...

TASK [Create a file using setting in ansible.cfg] ******************************
task path: /var/lib/awx/projects/_6__bug_demo/subdir/bug.yml:7

...

--- before: /tmp/template.txt
+++ after: /tmp/tmpyRyXCE/template.j2
@@ -1,2 +1,2 @@
-# Ansible managed
+# SET IN ADJACENT ANSIBLE.CFG
 # The line above should read SET IN ADJACENT ANSIBLE.CFG
ACTUAL RESULTS

Ansible does not see the config file and does not use settings specificed in the ansible.cfg adjacent to the playbook in the repository.

Identity added: /tmp/awx_48_0lFZ3j/credential_3 (/tmp/awx_48_0lFZ3j/credential_3)
ansible-playbook 2.4.0.0
  config file = None
  configured module search path = [u'/var/lib/awx/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
No config file found; using defaults
Parsed /tmp/awx_48_0lFZ3j/tmpQ7jDnB.awxrest.py inventory source with script plugin

...

TASK [Create a file using setting in ansible.cfg] ******************************
task path: /var/lib/awx/projects/_6__bug_demo/subdir/bug.yml:7

...

--- before: /tmp/template.txt
+++ after: /tmp/tmpcNJ5lq/template.j2
@@ -1,2 +1,2 @@
+# Ansible managed
 # The line above should read SET IN ADJACENT ANSIBLE.CFG
ADDITIONAL INFORMATION

Disable job isolation seems to have no affect on this bug — behavior is the same in both cases.

I also have a branch in that bug repo that puts an ansible.cfg file at the root of the repo. If you change the Project to use the top-level-config branch, then run the same Job Template, you can see that the config file at the root of the repo, not adjacent to the playbook, gets picked up. This should not be the case.

Identity added: /tmp/awx_66_RIxb4K/credential_3 (/tmp/awx_66_RIxb4K/credential_3)
ansible-playbook 2.4.0.0
  config file = /var/lib/awx/projects/_6__bug_demo/ansible.cfg
  configured module search path = [u'/var/lib/awx/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Using /var/lib/awx/projects/_6__bug_demo/ansible.cfg as config file
Parsed /tmp/awx_66_RIxb4K/tmpbDIjjO.awxrest.py inventory source with script plugin

...

TASK [Create a file using setting in ansible.cfg] ******************************
task path: /var/lib/awx/projects/_6__bug_demo/subdir/bug.yml:7

...

--- before: /tmp/template.txt
+++ after: /tmp/tmpyRyXCE/template.j2
@@ -1,2 +1,2 @@
-# Ansible managed
+# SET IN PROJECT ROOT ANSIBLE.CFG
 # The line above should read SET IN ADJACENT ANSIBLE.CFG

api bug

Most helpful comment

Turns outâ„¢, this is a bug in the Ansible Tower docs, not a bug in Ansible Tower (that's a nice way of me saying PEBKAC). The docs state:

You can also install your own copy in ~/.ansible.cfg or keep a copy in a directory relative to your playbook named as ansible.cfg.

They _should_ state the ansible.cfg has to be at the root of the project because ansible-playbook is executed from there and Ansible is looking for ansible.cfg in the current working directory, _not_ adjacent to playbooks.

I'll submit a docs PR to clarify this.

All 2 comments

Talked w/ @samdoran; not an actual bug, just poor Tower documentation (he's working on a fix).

Turns outâ„¢, this is a bug in the Ansible Tower docs, not a bug in Ansible Tower (that's a nice way of me saying PEBKAC). The docs state:

You can also install your own copy in ~/.ansible.cfg or keep a copy in a directory relative to your playbook named as ansible.cfg.

They _should_ state the ansible.cfg has to be at the root of the project because ansible-playbook is executed from there and Ansible is looking for ansible.cfg in the current working directory, _not_ adjacent to playbooks.

I'll submit a docs PR to clarify this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marshmalien picture marshmalien  Â·  3Comments

Gui13 picture Gui13  Â·  3Comments

pebbledavec picture pebbledavec  Â·  3Comments

astraios picture astraios  Â·  3Comments

augabet picture augabet  Â·  3Comments