# sudo not working on remote server

**URL:** <https://forum.ansible.com/t/sudo-not-working-on-remote-server/36307>\
**Category:** Ansible Project\
**Created:** [February 8, 2022, 8:48pm UTC](https://forum.ansible.com/t/sudo-not-working-on-remote-server/36307 "2022-02-08T20:48:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ralph\_Hershkowitz](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@Ralph\_Hershkowitz](https://forum.ansible.com/u/Ralph_Hershkowitz)\
**Post date:** [February 8, 2022, 8:48pm UTC](https://forum.ansible.com/t/sudo-not-working-on-remote-server/36307/1 "2022-02-08T20:48:10Z")

</div>

I am on server A logged in as user A with sudo permissions. I am attempting to run a privileged command on server b as user A. User A on server b also has sudo permissions. However I am getting permission errors:

- **Inventory File**

[rhershkow@if21d0002 ansible]$ more inventory if21d0001 ansible\_ssh\_user=rhershkow

- **Config File**

[rhershkow@if21d0002 ansible]$ more ansible.cfg [defaults]

inventory = /home/rhershkow/demo/ansible/inventory

[privilege\_escalation]

become=true

become\_method=sudo

become\_user=rhershkow

become\_ask\_pass=False

- **Example.yml**  
[rhershkow@if21d0002 ansible]$ more example.yml- name: New user is created

hosts: if21d0001

become: true

tasks:

- name: User gets created user: name: test state: present- **Execution Errors**

[rhershkow@if21d0002 ansible]$ ansible-playbook example.yml

PLAY [New user is created] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* ok: [if21d0001]

TASK [User gets created] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* fatal: [if21d0001]: FAILED! =\> {“changed”: false, “msg”: “useradd: Permission denied.\nuseradd: cannot lock /etc/passwd; try again later.\n”, “name”: “test”, “rc”: 1} to retry, use: --limit @/home/rhershkow/demo/ansible/example.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* if21d0001 : ok=1 changed=0 unreachable=0 failed=1
