pldimitrov
pldimitrov

Reputation: 1727

Sudo does not work with Ansible AWX

I have set sudo_user in /etc/ansible/ansible.cfg.

In my playbook I have set remote_user, sudo_user and sudo:yes (also tried sudo:True) on the same level as hosts: I then use a role that does:

shell: cp -f src /usr/local/bin/dest

sudo: yes

and get

stderr: cp: cannot create regular file `/usr/local/bin/dest': Permission denied

The credentials in AWX are set correctly - I am able to manually log in as the desired user on the remote machine and copy the file with sudo cp. I have no idea what I'm doing wrong.

Upvotes: 0

Views: 1067

Answers (1)

Rico
Rico

Reputation: 61669

What's your sudo user? Your base playbook should look something like this:

# Base System: this is my base playbook
- name: Base Playbook
  hosts: all
  user: myuser
  sudo: True

Upvotes: 0

Related Questions