1、vi changpass.yml
-
hosts: lqtapi
gather_facts: falsetasks:
- name: chattr -i
shell: chattr -i /etc/shadow - name: copy ssh key
shell: echo 'xxxxxxxxx@123455' |passwd --stdin root - name: chattr +i
shell: chattr +i /etc/shadow
- name: chattr -i
2、ansible-playbook changpass.yml