AWX 20 and delegate_to

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

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 :slight_smile:

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

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.

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