本文介绍了使用ansible-"password"添加新的sudo用户:"NOT_LOGGING_PASSWORD"信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Vagrant(Virtual Box提供程序)设置本地虚拟机.我还使用ansible和更具体的ansible_local(Vagrant插件)将一些工具部署到VM中.

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.

最初,我尝试根据Ansible文档创建一个新用户.

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:

汇总事实************************************************* ****************** 好的:[127.0.0.1]

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

任务:[添加用户] ********************************************* ********* 更改:[127.0.0.1] => {更改":true,评论":","createhome":> true,组":1001,组":"root","home":"/home/nikolas",名称":>"nikolas","password":"NOT_LOGGING_PASSWORD","shell":"/bin/bash",>"state":"present","system":false,"uid :1001}

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}

任务:[放置RSA密钥] ******************************************** *************** 已更改:[127.0.0.1] => {已更改":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"}

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更改= 2不可达= 0>失败= 0

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

密码":"NOT_LOGGING_PASSWORD"结果,当我尝试在虚拟机中以nikolas身份登录以获取身份验证错误时.

"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 ?

谢谢

推荐答案

我认为您需要像这样修改user创建任务:

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

希望对您有帮助.

这篇关于使用ansible-"password"添加新的sudo用户:"NOT_LOGGING_PASSWORD"信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 01:54