AWX 20 and delegate_to

333 views
Skip to first unread message

karon

unread,
Mar 15, 2022, 4:07:23 PM3/15/22
to AWX Project
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

karon

unread,
Mar 16, 2022, 4:57:21 AM3/16/22
to AWX Project
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 :)

Vincent Rubiolo

unread,
Mar 16, 2022, 6:29:32 AM3/16/22
to AWX Project
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

karon

unread,
Mar 16, 2022, 9:48:37 AM3/16/22
to AWX Project
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.

Vincent Rubiolo

unread,
Mar 16, 2022, 10:57:58 AM3/16/22
to AWX Project
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

Reply all
Reply to author
Forward
0 new messages