使用ansible添加新的sudo用户 - "密码":" NOT_LOGGING_PASSWORD"消息

时间:2016-07-24 22:39:20

标签: vagrant ansible ansible-playbook

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

最初,我正在尝试按照ansible文档创建新用户。

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

当我运行剧本时,我收到了这条消息:

  

播放[主节点] ****************************************** ******************

     

收集事实********************************************* ******************   好的:[127.0.0.1]

     

任务:[添加用户] ***************************************** *********   已更改:[127.0.0.1] => {"改变":是,"评论":"","创建家庭":> true,"组&#34 ;:1001,"群组":" root"," home":" / home / nikolas"," name&#34 ;:>" nikolas","密码":" NOT_LOGGING_PASSWORD"," shell":" / bin / bash&#34 ;,>"州":"现在","系统":false," uid":1001}

     

任务:[放置RSA密钥] **************************************** ***************   已更改:[127.0.0.1] => {"更改":true,"键":" ssh-rsa> AAAAB3N .... public_rsa_key"," key_options":null ,>"密钥文件":" /home/desmotes/.ssh/authorized_keys"," manage_dir":true,>"路径" :null," state":" present"," unique":false," user":" nikolas"}

     

回放********************************************* ***********************   127.0.0.1:ok = 4 changed = 2 unreachable = 0> failed = 0

"密码":" NOT_LOGGING_PASSWORD" 因此,当我尝试以虚拟机中的nikolas身份登录以获取身份验证错误时。

你知道我的错误在哪里吗?

谢谢

1 个答案:

答案 0 :(得分:1)

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

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

希望能帮助你。