1

I'm new with Ansible so hope to find answers here. I'm trying to run some playbook but getting an error:

fatal: [10.65.30.117]: FAILED! => {
  "msg": "Timeout (12s) waiting for privilege escalation prompt: "
}

Here are the steps which I performed:

  1. I installed Ansible 2.6.17 on RHEL 6.8 using root user.
  2. I update /etc/ansible/host with new group of IPs (with root user)
  3. I created playbook file (with some other user) with the following content:
  name: sample_playbook
  hosts: [ansible_clients]
  remote_user: ronenal
  become: true
  tasks:
     - name: create file
       file:
         path: /tmp/ansible.log
         state: touch
         mode: u=rw,g=r,o=r

When I execute ansible-playbook -sample_playbook.yml I'm getting the above error.

I set ANSIBLE_DEBUG=1 and it looks like it related to sudo command. The user which I use is not in the sudoers list.

My questions:

  1. Is it required to be a privileged user in order to execute Ansible playbook?
  2. if no, what am I doing wrong?
  3. if yes, is that mean that I need to add this user to the sudoers users list?

2 Answers 2

2

You don't need to be a privileged user (in your local machine) in order to execute Ansible playbook.

When using become, Ansible allows you to ‘become’ another user, different from the user that logged into the machine (remote user).

For more details see Understanding Privilege Escalation

In your inventory of hosts /etc/ansible/host you have specified a group of IPs with root user while you are specifying a remote_user: ronenal in your playbook.

So you need to run ansible-playbook with --ask-become-pass or -K.

1
  • Thanks. I added become_user to the playbook file and it resolved the issue.
    – Ronen
    Commented Aug 22, 2019 at 12:50
1

I agree with Fodil, but I would also recommend using psexec for working with windows. Ansible has a command "win_psexec" that helps to use escalated privileges without using Become.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.