Writing out a rendered j2 template to my roles directory fails; works when executing Playbook via CLI
#5,818 opened on Feb 3, 2020
Repository metrics
- Stars
- (13,071 stars)
- PR merge metrics
- (Avg merge 24d 6h) (30 merged PRs in 30d)
Description
ISSUE TYPE
- Bug Report
SUMMARY
When executing a j2 template rendering Playbook role from AWX, the Playbook runs without error, but the rendered file is never written out to the directory. If you run the Playbook from the CLI, it runs without error and will write out the file correctly.
ENVIRONMENT
- AWX version: 9.1.1
- AWX install method: Docker Compose
- Ansible version: AWX v2.8.5; CLI environment 2.9.4; have downgraded the CLI to 2.8.5 and no change in behavior.
- Operating System: Ubuntu 18.04.4 LTS
- Web Browser: Chrome
STEPS TO REPRODUCE
Simply execute the Playbook role from CLI - successful. Execute within AWX - successful but no rendered template file is written.
EXPECTED RESULTS
Expect the template to render and show Change=1 as the completed status. Running the job once more should result in Change=0 due to idempotency.
ACTUAL RESULTS
No matter how many times the Playbook is ran in AWX, it still shows Change=1 (idempotency is indicating that the rendered file and existing file don't match).
ADDITIONAL INFORMATION
Job output:
ansible-playbook 2.8.5 config file = /etc/ansible/ansible.cfg configured module search path = ['/var/lib/awx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3.6/site-packages/ansible executable location = /usr/bin/ansible-playbook python version = 3.6.8 (default, Oct 7 2019, 17:58:22) [GCC 8.2.1 20180905 (Red Hat 8.2.1-3)] Using /etc/ansible/ansible.cfg as config file host_list declined parsing /tmp/awx_84_bala34n2/tmp0xedd_js as it did not pass it's verify_file() method Parsed /tmp/awx_84_bala34n2/tmp0xedd_js inventory source with script plugin
PLAYBOOK: render-config-template.yaml ****************************************** 1 plays in render-config-template.yaml skipping vars_file 'roles/ansible-role_leaf-spine-demo/vars/{{ inventory_hostname }}.yaml' due to an undefined variable skipping vars_file 'roles/ansible-role_leaf-spine-demo/vars/{{ inventory_hostname }}.yaml' due to an undefined variable skipping vars_file 'roles/ansible-role_leaf-spine-demo/vars/{{ inventory_hostname }}.yaml' due to an undefined variable
PLAY [Render device configuration from Jinja2 template] ************************ META: ran handlers Read vars_file 'roles/ansible-role_leaf-spine-demo/vars/{{ inventory_hostname }}.yaml'
TASK [include_role : ansible-role_leaf-spine-demo] ***************************** task path: /tmp/awx_84_bala34n2/project/render-config-template.yaml:21 Read vars_file 'roles/ansible-role_leaf-spine-demo/vars/{{ inventory_hostname }}.yaml' skipping vars_file 'roles/ansible-role_leaf-spine-demo/vars/{{ inventory_hostname }}.yaml' due to an undefined variable skipping vars_file 'roles/ansible-role_leaf-spine-demo/vars/{{ inventory_hostname }}.yaml' due to an undefined variable Read vars_file 'roles/ansible-role_leaf-spine-demo/vars/{{ inventory_hostname }}.yaml' Read vars_file 'roles/ansible-role_leaf-spine-demo/vars/{{ inventory_hostname }}.yaml'
TASK [ansible-role_leaf-spine-demo : Render L3 configuration from Jinja2 template] *** task path: /tmp/awx_84_bala34n2/project/roles/ansible-role_leaf-spine-demo/tasks/main.yaml:2 skipping: [as1-lsdemo] => { "changed": false, "skip_reason": "Conditional result was False" } Read vars_file 'roles/ansible-role_leaf-spine-demo/vars/{{ inventory_hostname }}.yaml' Read vars_file 'roles/ansible-role_leaf-spine-demo/vars/{{ inventory_hostname }}.yaml'
TASK [ansible-role_leaf-spine-demo : Render L2 configuration from Jinja2 template] ***
task path: /tmp/awx_84_bala34n2/project/roles/ansible-role_leaf-spine-demo/tasks/main.yaml:9
ESTABLISH LOCAL CONNECTION FOR USER: root
EXEC /bin/sh -c 'echo ~root && sleep 0'
EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /root/.ansible/tmp/ansible-tmp-1580760189.131988-38741190511676" && echo ansible-tmp-1580760189.131988-38741190511676="echo /root/.ansible/tmp/ansible-tmp-1580760189.131988-38741190511676" ) && sleep 0'
Using module file /usr/lib/python3.6/site-packages/ansible/modules/files/stat.py
PUT /var/lib/awx/.ansible/tmp/ansible-local-31196m1gfm4/tmpgkos3sf8 TO /root/.ansible/tmp/ansible-tmp-1580760189.131988-38741190511676/AnsiballZ_stat.py
EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1580760189.131988-38741190511676/ /root/.ansible/tmp/ansible-tmp-1580760189.131988-38741190511676/AnsiballZ_stat.py && sleep 0'
EXEC /bin/sh -c '/usr/libexec/platform-python /root/.ansible/tmp/ansible-tmp-1580760189.131988-38741190511676/AnsiballZ_stat.py && sleep 0'
PUT /var/lib/awx/.ansible/tmp/ansible-local-31196m1gfm4/tmpmrdlc_xr/as1-lsdemo.j2 TO /root/.ansible/tmp/ansible-tmp-1580760189.131988-38741190511676/source
EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1580760189.131988-38741190511676/ /root/.ansible/tmp/ansible-tmp-1580760189.131988-38741190511676/source && sleep 0'
Using module file /usr/lib/python3.6/site-packages/ansible/modules/files/copy.py
PUT /var/lib/awx/.ansible/tmp/ansible-local-31196m1gfm4/tmpdki9jp7_ TO /root/.ansible/tmp/ansible-tmp-1580760189.131988-38741190511676/AnsiballZ_copy.py
EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1580760189.131988-38741190511676/ /root/.ansible/tmp/ansible-tmp-1580760189.131988-38741190511676/AnsiballZ_copy.py && sleep 0'
EXEC /bin/sh -c '/usr/libexec/platform-python /root/.ansible/tmp/ansible-tmp-1580760189.131988-38741190511676/AnsiballZ_copy.py && sleep 0'
EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1580760189.131988-38741190511676/ > /dev/null 2>&1 && sleep 0'
changed: [as1-lsdemo -> localhost] => {
"changed": true,
"checksum": "99c96d22daace5401612c85791e2c0d066bee316",
"dest": "roles/ansible-role_leaf-spine-demo/compiled/as1-lsdemo.confg",
"diff": [],
"gid": 0,
"group": "root",
"invocation": {
"module_args": {
"_original_basename": "as1-lsdemo.j2",
"attributes": null,
"backup": false,
"checksum": "99c96d22daace5401612c85791e2c0d066bee316",
"content": null,
"delimiter": null,
"dest": "roles/ansible-role_leaf-spine-demo/compiled/as1-lsdemo.confg",
"directory_mode": null,
"follow": false,
"force": true,
"group": null,
"local_follow": null,
"mode": null,
"owner": null,
"regexp": null,
"remote_src": null,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": "/root/.ansible/tmp/ansible-tmp-1580760189.131988-38741190511676/source",
"unsafe_writes": null,
"validate": null
}
},
"md5sum": "6ebf870727c6671d2f2daa4902353960",
"mode": "0644",
"owner": "root",
"size": 1283,
"src": "/root/.ansible/tmp/ansible-tmp-1580760189.131988-38741190511676/source",
"state": "file",
"uid": 0
}
META: ran handlers
META: ran handlers
PLAY RECAP ********************************************************************* as1-lsdemo : ok=1 changed=1 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0