创建具有Ansible一个新的用户名和密码 [英] Creating a new user and password with Ansible
问题描述
我有创建在Ubuntu 12.04新用户的ansible任务;
I have an ansible task which creates a new user on ubuntu 12.04;
- name: Add deployment user
action: user name=deployer password=mypassword
在完成如预期,但是当我登录的用户,并尝试以我设置密码须藤总是说,这是不正确。我在做什么错了?
it completes as expected but when I login as that user and try to sudo with the password I set it always says it's incorrect. What am I doing wrong?
推荐答案
如果你读Ansible对 用户手册
模块,它会引导您到Ansible-例子 github上回购了详细说明如何使用<一个href=\"https://github.com/ansible/ansible-examples/blob/master/language_features/user_commands.yml\"><$c$c>password$c$c>参数。
If you read Ansible's manual for user
module, it'll direct you to the Ansible-examples github repo for details how to use password
parameter.
有,你会看到你的口令都必须要。
There you'll see that your password must be hashed.
- hosts: all
user: root
vars:
# created with:
# python -c 'import crypt; print crypt.crypt("This is my Password", "$1$SomeSalt$")'
password: $1$SomeSalt$UqddPX3r4kH3UL5jq5/ZI.
tasks:
- user: name=tset password={{password}}
如果您的剧本或ansible命令行有您的密码,在纯文本,这意味着记录在你的影子密码哈希值的文件是错误的。这意味着,当你尝试用你的密码哈希将不会匹配进行身份验证。
If your playbook or ansible command line has your password as-is in plain text, this means your password hash recorded in your shadow file is wrong. That means when you try to authenticate with your password its hash will never match.
此外,看到Ansible <一个href=\"http://docs.ansible.com/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module\">FAQ关于密码参数的一些细微以及如何正确使用它。
Additionally, see Ansible FAQ regarding some nuances of password parameter and how to correctly use it.
这篇关于创建具有Ansible一个新的用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!