Adding new sudo user using ansible - “password”: “NOT_LOGGING_PASSWORD” message

旧巷老猫 提交于 2019-12-25 06:44:50

问题


I'm using Vagrant (Virtual Box provider) to setup a local Virtual Machine. I'm also using ansible and more specific ansible_local (Vagrant plugin) to deploy some tools into the VM.

Initially I'm trying to create a new user following the ansible documentation.

---
- name: Master Node
hosts: 127.0.0.1
connection: local
user: root
vars_files:
    - vars/vars.yml
vars:
    username: nikolas

tasks:
- name: Adding user
  user: name={{username}} shell=/bin/bash groups=root append=yes password={{pass}}
  sudo: yes

- name: Placing RSA key
  authorized_key: user={{username}} key="{{ lookup('file', 'id_rsa.pub') }}"
  sudo: yes

When I run the playbook, I get this message:

PLAY [Master Node] ************************************************************

GATHERING FACTS *************************************************************** ok: [127.0.0.1]

TASK: [Adding user] ************************************************** changed: [127.0.0.1] => {"changed": true, "comment": "", "createhome": >true, "group": 1001, "groups": "root", "home": "/home/nikolas", "name": >"nikolas", "password": "NOT_LOGGING_PASSWORD", "shell": "/bin/bash", >"state": "present", "system": false, "uid": 1001}

TASK: [Placing RSA key] ******************************************************* changed: [127.0.0.1] => {"changed": true, "key": "ssh-rsa >AAAAB3N....public_rsa_key", "key_options": null, >"keyfile": "/home/desmotes/.ssh/authorized_keys", "manage_dir": true, >"path": null, "state": "present", "unique": false, "user": "nikolas"}

PLAY RECAP ******************************************************************** 127.0.0.1 : ok=4 changed=2 unreachable=0 >failed=0

"password": "NOT_LOGGING_PASSWORD" As a result, when i am trying to logged in as nikolas in the VM to get authentication error.

Do you know where is my mistake ?

Thank you


回答1:


I think you need to modified your user creation task like this:

- name: Adding user
  user: name={{username}} shell=/bin/bash groups=root append=yes password={{ pass | password_hash('sha512') }}
  sudo: yes

Hope that help you.



来源:https://stackoverflow.com/questions/38557537/adding-new-sudo-user-using-ansible-password-not-logging-password-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!