I am trying to run an Ansible Tower Template with a task that requires root privileges on localhost. According to RedHat's knowledgebase:
It isn't possible to use Tower with local action to escalate to the root user. It will be necessary to alter your task to connect via SSH and then escalate to root using another user(not AWX).
I have already tried changing the ansible_connection host variable under localhost to ssh with no success. I also tried completely removing the variable hoping that it would default to an SSH connection which also did not work. I realize that the variable value is probably not defined correctly but I was unable to find listed options in the documentation.
The task in question:
- name: "Ansible Create directory if not exists"
file:
path: /etc/custom-switch
state: directory
mode: 0755
group: awx
owner: awx
when: exec_dir.stat.exists == false
delegate_to: localhost
become: yes
Job fails with the following error:
`sudo: effective uid is not 0, is sudo installed setuid root`