6

I give up, just can't understand 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've 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 it be executed?

ansible --version
ansible 1.7.2
Sergey
  • 19,487
  • 13
  • 44
  • 68

2 Answers2

3

Try

ansible-playbook -i <inventory> ansible/desktop.yml -u <local user who can sudo with password> --ask-sudo-pass

This will make ansible use the remote user you mentioned in -u. And when it uses that user to sudo, it will ask you for sudo password.

Zasz
  • 12,330
  • 9
  • 43
  • 63
0

Here's another method (also works with ansible become: syntax):

sudo su -c "ansible-playbook <your playbook name and options>"

Jordan
  • 261
  • 3
  • 9