创建用户配置密码通过哈希加密的方式 [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 ...
password: "{{ redhat | password_hash('sha512') }}" # 删除一个用户 - name: Remove a user ansible.builtin.user: name: johndoe state: absent # 创建一个系统用户 - name: Create a system user ansible.builtin.user: name: sysuser system: yes # 创建一个用户并添加到多个组 - name: Creat...
我们可以通过`user`模块提供的参数来修改用户密码,例如`update_password`和`password`。下面是一个示例的playbook: ```yaml - hosts: servers tasks: - name: Change user password user: name: testuser update_password: always password: "{{ 'newpassword' | password_hash('sha512') }}" ``` 在上面的...
tasks: - name: Update user password user: name: username password: "{{ 'new_password' | password_hash('sha512', 'my_salt') }}" ``` 在上面的示例中,我们首先指定了要更改密码的用户名,并将新密码指定为“new_password”。密码要使用`password_hash` 过滤器来生成哈希值,确保密码安全性。在这种...
- name: Change password user: name={{ name1 }} password={{ chpass | password_hash('sha512') }} update_password=always 执行ansible-playbook, 使用-e参数传递用户名和密码给剧本,其中root为用户名,admin#123就是修改后的root密码 [root@ansible-server ~]# ansible-playbook /opt/root_passwd2.yaml...
利用ansible的user 模块修改 1,编写yml文件 vim usePassword.yml # 组名 或 all - hosts: ziji gather_facts: false tasks: - name: change user passwd user: name={{ item.name }} password={{ item.chpass | password_hash('sha512') }} update_password=always ...
可以用{{'accasdfasdfas234ddFaa'|password_hash('sha512')}} - name: useradd bb user ...
# 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"信息 ...
user: name={{ name1 }} password={{ chpass | password_hash('sha512') }} update_password=always 创建hosts文件: vim hosts [chgpwd] 192.168.3.99 192.168.3.98 执行ansible-playbook命令: name1传入用户名,chpass传入要设置的密码 ansible-playbook chgpwd.yml-i hosts-e" name1=ansible_test chpass=...
- name: Change password user: name={{ item }} password={{ new_pass | password_hash('sha512') }} with_items: users 1.2 执行,214就是要设置密码 1 ansible-playbook testuser.yml -e"hosts=jump users=testuser new_pass=*(214)"