在执行ansible创建用户指定密码的时候,直接passwd=xxx 不行,ansible不认明文的密码,我们需要用python进行加密处理。
# pip install passlib
# python -c "from passlib.hash import sha512_crypt; print sha512_crypt.encrypt('<password>')"
# passwd="PASSWD"
# python -c "from passlib.hash import sha512_crypt; print sha512_crypt.encrypt('"${passwd}"')"

参考
ansible创建用户时密码问题的踩坑记录
http://www.manongjc.com/detail/13-jjjcthuiddntddf.html
使用ansible-"password"添加新的sudo用户:"NOT_LOGGING_PASSWORD"信息
https://www.it1352.com/1930510.html
How to set default Ansible username/password for SSH connection?
https://serverfault.com/questions/628989/how-to-set-default-ansible-username-password-for-ssh-connection
How To Generate Linux User Encrypted Password for Ansible
https://computingforgeeks.com/generate-linux-user-encrypted-password-for-ansible/
Add user and set password using Ansible
https://unix.stackexchange.com/questions/273316/add-user-and-set-password-using-ansible
Creating a new user and password with Ansible
https://stackoverflow.com/questions/19292899/creating-a-new-user-and-password-with-ansible
网友评论