tasks: - name: Set user password shell: echo "username:new_password" | chpasswd ``` 在这个示例中,我们使用了"become"关键字来表示我们需要以管理员权限执行任务。然后,我们使用了一个名为"shell"的模块来执行远程主机上的命令。在这个任务中,我们使用了"echo"命令和"chpasswd"命令来设置指定用户名的密码。
Optionally set the user's password to this crypted value. On macOS systems, this value has to be cleartext. Beware of security issues. To create a disabled account on Linux systems, set this to `'!'' or `'*''. See https://docs.ansible.com/ansible/faq.html#how-do-i-generate-crypt...
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
创建用户配置密码通过哈希加密的方式 [libin@libin ansible]$ vim rhca447-26.yaml --- - name: create user and set hosts: web tasks: - name: create user user: name: alex01 password: "{{ 'helloworld' | password_hash('sha512') }}" state: present [libin@libin ansible]$ ansible-playbook ...
# 1.获取密码的加密结果$ python -c"from passlib.hash import sha512_crypt; import getpass; print(sha512_crypt.using(rounds=5000).hash(getpass.getpass()))"# 2.把加密后的结果set进去,并记得转义$ ansible dev -m user -a"name=Nick password=\$6\$oCdGPgCR9sbikR36\$IhTedtlBZTVUoLrtn8T5D...
password 指定用户密码 state 指定用户状态absent 删除用户 remove 如果是yes删除用户家目录 expires 指定用户的过期时间 date -d 2020-05-20 +%s(获取对应日期的unix时间戳) ansible yu -m user -a "name=test group=test1 shell=/sbin/nologin"
ansible-doc -s user常用的参数:name :用户名,必选参数state=present|absent:创建账号或者删除账号,present表示创建,absent 表示删除system=yes|no:是否为系统账号uid: 用户uidgroup:用户基本组groups:附加组shell:默认使用的shellmove_home=yse|no:如果设置的家日录已经存在,是否将已经存在的家日录进行移动password:...
/usr/bin/expectsettimeout10sethostname[lindex $argv0]setusername[lindex $argv1]setpassword[lindex $argv2]spawn ssh-copy-id $username@$hostname expect{"Are you sure you want to continue connecting (yes/no)?"{send"yes\r"expect"*password:"send"$password\r"}"*password:"{send"$password\r...
根用户已被'root'@'localhost'充分覆盖,其他本地根用户需要删除。
1. Set up configuration for a MySQL/MariaDB database 2. Set up a path for your playbooks (auto-created) 3. Run database Migrations 4. Set up initial semaphore user & password > DB Hostname (default 127.0.0.1:3306):127.0.0.1:3306 ...