Can I use sudo in Ansible with a "local" connection?
I give up, I just can't figure out how to use Ansible with "connection: local" + "sudo: yes". I have something like:
ansible-playbook ansible/desktop.yml
- hosts: localhost
connection: local
...
tasks:
- apt_repository: repo='ppa:alexey-smirnov/deadbeef'
sudo: yes
I have also tried sudo_user: ...
param, sudo
before the command ansible-playbook --sudo
and--ask-sudo-pass
Currently
failed: [localhost] => {"failed": true}
msg: [Errno 13] Permission denied
How should this be done?
ansible --version
ansible 1.7.2
Try
ansible-playbook -i <inventory> ansible/desktop.yml -u <local user who can sudo with password> --ask-sudo-pass
This will make it possible to use the remote user specified in -u
. And when he uses that user for sudo, he will ask you for the sudo password.
Here's another method (also works with parsing syntax become:
):
sudo su -c "ansible-playbook <your playbook name and options>"