Cannot get sudo commands working with Ansible

I am trying to use Ansible to create a Vagrant window and an EC2 server. It works fine on the Vagrant box when using --connection = local, but seems to just ignore sudo: True line

When I do this:

---
- hosts: remote
  vars_files:
    - vars.yml
  gather_facts: false
  sudo: True
  remote_user: root

  tasks:
  - name: test
    file: state=directory path=~/test

It creates a directory in the regular home directory of a user owned by ordinary users. The user does not have a password, and I can use the commands with sudo without asking for them. What am I missing?

+4
source share
1 answer

You also need to add the option "sudo_user".

:
sudo sudo_user sudo_user root, root ( "remote_user" )
sudo su - root -c "mkdir ~/test"

http://docs.ansible.com/intro_configuration.html#sudo-user

, sudo_user home.

+5

All Articles