- name: Change user password user: name: username password: "{{ new_password | password_hash('sha512') }}" ``` 在这个Playbook中,我们定义了一个名为“Change user password”的任务,它将在所有主机上执行。然后我们使用user模块来更改用户的密码。需要注意的是,我们使用了一个变量“new_password”,这...
`user`模块是Ansible内置的一个模块,用于管理用户账户。我们可以通过`user`模块提供的参数来修改用户密码,例如`update_password`和`password`。下面是一个示例的playbook: ```yaml - hosts: servers tasks: - name: Change user password user: name: testuser update_password: always password: "{{ 'newpassword...
- 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...
3. 编写playbook 批量修改多用户密码 - hosts: test gather_facts: false tasks: - name: change user passwd user: name={{ item.name }} password={{ item.chpass | password_hash('sha512') }} update_password=always with_items: - { name: 'root', chpass: '123456' } - { name: 'liutao...
- name: change the user root password shell: 'echo "{{kel}}"|passwd --stdin root > /dev/null 2>&1' 此内容主要是用kel变量的值作为root用户的密码 [root@ansibleserver kel]# cat site.yml --- - include: staging.yml - include: production.yml ...
创建playbook脚本 vim change_passwd.yml ---hosts:a备注:ip组配置在hosts文件中sudo:yesremote_user:root备注:远程的用户gather_facts:falsetasks:-name:changeuserpasswduser:name={{item.user}}password={{item.password|password_hash('sha512')}}update_password=alwayswith_items:-{user:'version',password...
- name: Change 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传入要设置的密码 ...
false tasks: - 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...
ansible-playbook 批量修改密码 创建playbook脚本 vim change_passwd.yml ---hosts:a备注:ip组配置在hosts文件中sudo:yesremote_user:root备注:远程的用户gather_facts:falsetasks:-name:changeuserpasswduser:name={{item.user}}password={{item.password|password_hash('sha512')}}update_password=alwayswith_items...
local-user huaweiuser level 3 local-user huaweiuser service-type ssh undo local-user policy password change quit ssh user huaweiuser ssh user huaweiuser authentication-type password ssh user huaweiuser service-type all stelnet server enable