生成加密密碼:
安裝python passlib 庫
pip install passlib
如果系統中沒有pip命令,則先安裝pip:
下載epel yum repo文件(使用阿里雲鏡像):
wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install python-pip
之後就可以生成加密密碼了(這裏的root經測試沒有實際作用,可以把生成的加密密碼設置給任何用戶):
python -c 'import crypt; print(crypt.crypt("1234!@#$","root"))'
修改密碼:
ansible db -m user -a "name=tom shell=/bin/bash password=roPBH1WZmqUe. update_password=always"