ansible user模块添加用户、密码问题
生活随笔
收集整理的這篇文章主要介紹了
ansible user模块添加用户、密码问题
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
基本用法
ansible 10.0.0.11 -m user -a "name=sky01"
指定用戶uid信息
anisble 10.0.0.11 -m user -a "name=sky02 uid=666"
指定用戶組信息
ansible 10.0.0.11 -m user -a "name=sky03 group=sky02" ansible 10.0.0.11 -m user -a "name=sky04 groups=sky02"
批量創(chuàng)建虛擬用戶
ansible 10.0.0.11 -m user -a "name=rsync create_home=no shell=/sbin/nologin"
給指定用戶創(chuàng)建密碼
ps:利用ansbile程序user模塊設(shè)置用戶密碼信息,需要將明文信息轉(zhuǎn)為密文信息進行設(shè)置
生成密文密碼
ansible all -i localhost, -m debug -a "msg={{ '密碼信息(123456)' | password_hash('sha512','加密效驗信息(隨便寫)') }}"
-i localhost 在本地生成信息
-m debug 調(diào)試模塊
sha512 加密方式
# ansible all -i localhost, -m debug -a "msg={{ '123456' | password_hash('sha512','sky01') }}"
localhost | SUCCESS => {
"msg": "$6$sky01$Ppe22caGxlbHwCR5biZ0oCcMa63McBIBgXD3RIkO080MckocOdUl2/SpKWUgPCdAOOE1Yjzyb5Oir2vgOjVwL/"
}
再去修改創(chuàng)建密碼(-a 后面請使用單引號'')
# ansible 10.0.0.11 -m user -a 'name=sky01 password=$6$sky01$Ppe22caGxlbHwCR5biZ0oCcMa63McBIBgXD3RIkO080MckocOdUl2/SpKWUgPCdAOOE1Yjzyb5Oir2vgOjVwL/'
[WARNING]: The input password appears not to have been hashed. The 'password' argument must be encrypted for this module to work properly.
10.0.0.11 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"append": false,
"changed": true,
"comment": "",
"group": 1001,
"home": "/home/sky01",
"move_home": false,
"name": "sky01",
"password": "NOT_LOGGING_PASSWORD",
"shell": "/bin/bash",
"state": "present",
"uid": 1001
}
總結(jié)
以上是生活随笔為你收集整理的ansible user模块添加用户、密码问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用node-webkit(NW.js)创
- 下一篇: Java实现发邮件功能---网易邮箱