Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hi,
- I was trying to deploy user and sudo privileges by ansible palybooks and for changing a particular line in sudoer file I've used "lineinfile" module but when ever I execute it throws me any error. can any one explain me what is the error and how to troubleshoot it.
- here is my yaml file
- - name: update yum cache
- yum:
- update_cache: yes
- update_only: yes
- use_backend: yum
- become: yes
- # when: ansible_facts['os_family'] == "RedHat"
- - name: creating user on target nodes webR1
- user:
- name: "{{ remote_user }}"
- password: '$6$rounds=656000$nKmf6WS3KcQUYvql$RYKVpfwn8abFQnxXvDatcen.2c0RrUHVihG2yMXeNPrCgMup5azfeILb4Hf7p8VtszOLmAlAVoOG3TvP0fRz31'
- shell: /bin/bash
- state: present
- home: /home/ "{{ remote_user }}"
- become: yes
- - name: create wheel group
- group:
- name: wheel
- state: present
- - name: granting the sudo previliges to remote user
- lineinfile:
- path: /etc/sudoers
- regexp: "{{ remote_user }} ALL"
- line: "{{ remote_user }} ALL=(ALL) NOPASSWD: ALL"
- state: present
- #- name: copying the public key of control to traget
- # command: sshpass -p password ssh-copy-id -i /home/ansadmctrl/.ssh/id_rsa.pub -o StrictHostKeyChecking=no "{{ remote_user }}"@172.31.19.69
- - name: Deploying the public key in the target machine
- authorized_key:
- user: "{{ remote_user }}"
- state: present
- This is the error
- [ansadmctrl@ip-XXX-XX-XX-XX ex2]$ ansible-playbook -i inven-dev user.yml -K
- SUDO password:
- [WARNING]: Found variable using reserved name: remote_user
- PLAY [creating a user with sudo pervilges on target machine webR1] ***********************************************************************************
- TASK [update yum cache] ******************************************************************************************************************************
- ok: [webR1]
- TASK [creating user on target nodes webR1] ***********************************************************************************************************
- ok: [webR1]
- TASK [create wheel group] ****************************************************************************************************************************
- ok: [webR1]
- TASK [granting the sudo previliges to remote user] ***************************************************************************************************
- fatal: [webR1]: FAILED! => {"changed": false, "module_stderr": "Shared connection to 172.31.19.69 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/.ansible-ansadm2/tmp/ansible-tmp-1551931429.95-102542624704258/AnsiballZ_lineinfile.py\", line 113, in <module>\r\n _ansiballz_main()\r\n File \"/tmp/.ansible-ansadm2/tmp/ansible-tmp-1551931429.95-102542624704258/AnsiballZ_lineinfile.py\", line 105, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File \"/tmp/.ansible-ansadm2/tmp/ansible-tmp-1551931429.95-102542624704258/AnsiballZ_lineinfile.py\", line 48, in invoke_module\r\n imp.load_module('__main__', mod, module, MOD_DESC)\r\n File \"/tmp/ansible_lineinfile_payload_xhYrIb/__main__.py\", line 524, in <module>\r\n File \"/tmp/ansible_lineinfile_payload_xhYrIb/__main__.py\", line 515, in main\r\n File \"/tmp/ansible_lineinfile_payload_xhYrIb/__main__.py\", line 257, in present\r\nIOError: [Errno 13] Permission denied: '/etc/sudoers'\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
- to retry, use: --limit @/home/ansadmctrl/ansible/ex2/user.retry
- PLAY RECAP *******************************************************************************************************************************************
- webR1 : ok=3 changed=0 unreachable=0 failed=1
Add Comment
Please, Sign In to add comment