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