ansible-community / ara

ARA Records Ansible and makes it easier to understand and troubleshoot.

Home Page:https://ara.recordsansible.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

callback plugin creates broken folder in the current working directory

nlvw opened this issue · comments

What is the issue ?

When running any playbook with ARA callback plugin enabled a malformed directory is created in the same folder as ansible.cfg. This only happens when ARA (1.6.0) is enabled.

$ ls -1
ansible.cfg
'{{ ANSIBLE_HOME ~ "'
bootstrap.sh
collections
container.def
inventory
playbooks
README.md
requirements.txt
roles
web_services

$ tree \{\{\ ANSIBLE_HOME\ ~\ \"/
{{ ANSIBLE_HOME ~ "/
└── tmp" }}

If I delete the directory, disable ARA, and run playbook again it isn't recreated. Then when I enable ARA the same playbook will create that strange directory.

playbook

---

- name: "Test Ansible Connection"
  hosts: "{{ cplay_hosts | default('all') }}"
  become: false
  strategy: linear
  gather_facts: no
  tasks:
    - name: connection test
      ping:
  post_tasks:
    - name: stop ssh client persistant connection
      meta: reset_connection

What should be happening ?

Additional directories should not be created in the same folder as ansible.cfg as this can make git mad.

Software Versions

Ansible = 7.1.0 (Core = 2.14)
OS = Fedora 37
Python = 3.11
ARA = 1.6.0
Install Source = pip

I've also recently noticed this and was wondering where that came from, certainly an odd bug.

I will try to find out where it comes from.

Also realized this issue. I already found out that if the environment variable ANSIBLE_LOCAL_TEMP is set, the problem does not appear. So seems to be related.

ok, problem is following line:

tmpdir_config = os.path.dirname(C.config.get_config_value("DEFAULT_LOCAL_TMP"))

>>> from ansible import constants
>>> constants.config.get_config_value("DEFAULT_LOCAL_TMP")
'/home/hille/gitrepos/plminfra_ansible/{{ ANSIBLE_HOME ~ "/tmp" }}/ansible-local-13618e_lqr8ew'

Thus it seems to be really an error from Ansible itself. The only thing with ara is, that ara ensures that this directory will be created, thus it became visible.
Will test with some different Ansible versions

this is not an issue with ansible-core 2.13 (Ansible 6), but just appears with ansible-core 2.14 (Ansible 7).

There was a change of the default for DEFAULT_LOCAL_TMP: ansible/ansible#76114
(Compare: https://docs.ansible.com/ansible/7/reference_appendices/config.html#default-local-tmp vs https://docs.ansible.com/ansible/6/reference_appendices/config.html#default-local-tmp.)

Seems to be that this has also side effects to other tools: ansible/ansible#77523

Solution to fix is pretty simple:

Instead of using C.config.get_config_value("DEFAULT_LOCAL_TMP") in line

tmpdir_config = os.path.dirname(C.config.get_config_value("DEFAULT_LOCAL_TMP"))

we can simply use: C.DEFAULT_LOCAL_TMP, which will render the variable correctly.

@hille721 I expected it was something along those lines but you beat me to it, thanks for investigating AND providing the fix!

This is likely worth including in a 1.6.1 hotfix release.

Thanks @hille721 and @dmsimard ! I really appreciate the quick fix on this!