Jump to content

Recommended Posts

HI, 

I have been trying to create a passwordless user using Ansible. However it fails at the point where the SSH key is to be placed. 

Below is the playbook that I am using.

Text

---

- hosts: test1
  become: yes
  tasks:
    
  - name: Make sure we have a 'wheel' group
    group:
      name: wheel
      state: present

  - name: Allow 'wheel' group to have passwordless sudo
    lineinfile:
      dest: /etc/sudoers
      state: present
      regexp: '^%wheel'
      line: '%wheel ALL=(ALL) NOPASSWD: ALL'
      validate: 'visudo -cf %s'
  
  - name: Add sudoers users to wheel group
    user: 
      name: "adminn"
      groups: wheel 
      append: yes 
      state: present 
      createhome: yes
  
  - name: Set up authorized keys for the adminn user
    authorized_key: 
      user: adminn 
      key: "{{ item }}"
    with_file:
      - /home/vagrant/.ssh/id_rsa.pub

 

which ends giving the following error.

 

Quote

PLAY [test1] *************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************
ok: [test1]

TASK [Make sure we have a 'wheel' group] *********************************************************************************************
ok: [test1]

TASK [Allow 'wheel' group to have passwordless sudo] *********************************************************************************
changed: [test1]

TASK [Add sudoers users to wheel group] **********************************************************************************************
changed: [test1]

TASK [Set up authorized keys for the adminn user] ************************************************************************************
fatal: [test1]: FAILED! => {"changed": false, "msg": "Either user must exist or you must provide full path to key file in check mode"}
        to retry, use: --limit @/vagrant/ansible2/playbook.retry

PLAY RECAP ***************************************************************************************************************************
test1                      : ok=4    changed=2    unreachable=0    failed=1
 

I have set up the system using vagrant wherein i have a control and node server with default user vagrant that already has a passwordless access from control to the node. This is a new user that I wish to create.

I referred to this article .

Hoping that someone can help me resolve this error. 

Thanks all !

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.