# AWX 20 and delegate\_to

**URL:** <https://forum.ansible.com/t/awx-20-and-delegate-to/36446>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [March 15, 2022, 8:07pm UTC](https://forum.ansible.com/t/awx-20-and-delegate-to/36446 "2022-03-15T20:07:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![karon](https://avatars.discourse-cdn.com/v4/letter/k/b9e5f3/32.png) [@karon](https://forum.ansible.com/u/karon)\
**Post date:** [March 15, 2022, 8:07pm UTC](https://forum.ansible.com/t/awx-20-and-delegate-to/36446/1 "2022-03-15T20:07:23Z")

</div>

Hello

I am desperately trying to run a command on the ansible controller.

Since I’m using AWX 20 I use “delegate\_to: cargo” cargo is the host (k3s) on which AWX is running. I read on this group that “delegate\_to:localhost” wouldn’t work.

everything works on my computer with Ansible 2.9 but not with AWX which returns this error:

{“reason”: “Could not find or access ‘/tmp/infra\_users.yml’ on the Ansible Controller.”}

if I check on the host, the file /tmp/infra\_users.yml does exist though:

root@cargo:/tmp#ls -l -rw-r–r-- 1 ansible ansible 1276 Mar 15 20:29 infra\_users.yml

This file is a playbook generated by a template. does anyone have any idea what is wrong? Thanks a lot for your help. Karim.

Here is the task :

- name: Creates infra users  
template:  
src: usertpl.yml.j2  
dest: /tmp/infra\_users.yml  
mode: ‘0644’  
delegate\_to: ‘cargo’  
become: no  
changed\_when: false

- include\_tasks: /tmp/infra\_users.yml

---

<div class="post-metadata">

**Author:** ![karon](https://avatars.discourse-cdn.com/v4/letter/k/b9e5f3/32.png) [@karon](https://forum.ansible.com/u/karon)\
**Post date:** [March 16, 2022, 8:57am UTC](https://forum.ansible.com/t/awx-20-and-delegate-to/36446/2 "2022-03-16T08:57:21Z")

</div>

I solved my problem by generating the file in the project directory

…

dest: ‘{{ role\_path }}/tasks/infra\_users.yml’

…  
and specifying delegate\_to: localhost

thank you 🙂

---

<div class="post-metadata">

**Author:** ![Vincent\_Rubiolo](https://avatars.discourse-cdn.com/v4/letter/v/a183cd/32.png) [@Vincent\_Rubiolo](https://forum.ansible.com/u/Vincent_Rubiolo)\
**Post date:** [March 16, 2022, 10:29am UTC](https://forum.ansible.com/t/awx-20-and-delegate-to/36446/3 "2022-03-16T10:29:32Z")

</div>

Hi Karon,

Thanks for mentioning, glad you could solve your issue.  
I was not aware there was a problem with ‘delegate\_to: localhost’ as you had mentioned: we are using it successfully in our playbooks with AWX here.

Vincent

---

<div class="post-metadata">

**Author:** ![karon](https://avatars.discourse-cdn.com/v4/letter/k/b9e5f3/32.png) [@karon](https://forum.ansible.com/u/karon)\
**Post date:** [March 16, 2022, 1:48pm UTC](https://forum.ansible.com/t/awx-20-and-delegate-to/36446/4 "2022-03-16T13:48:37Z")

</div>

Hello!

yes I have read some answers to that effect but I think it was just a path issue. If i remember, it said to add the AWX host to the inventory and to switch to delegate\_to: awx\_host

for my part I was using /tmp but replacing it with the project directory and again specifying delegate\_to: localhost it works fine

I was also surprised because I was using it without problems on an old AWX platform.

Karim.

---

<div class="post-metadata">

**Author:** ![Vincent\_Rubiolo](https://avatars.discourse-cdn.com/v4/letter/v/a183cd/32.png) [@Vincent\_Rubiolo](https://forum.ansible.com/u/Vincent_Rubiolo)\
**Post date:** [March 16, 2022, 2:57pm UTC](https://forum.ansible.com/t/awx-20-and-delegate-to/36446/5 "2022-03-16T14:57:58Z")

</div>

Hi Karim,

Thanks for the additional explanations. It might have been that /tmp was too volatile in a container environment, compared to the project directory.  
Interesting to see also it was working in a previous version, it might have been undocumented.

Vincent
