Добавить ansible/change_password.yml
This commit is contained in:
24
ansible/change_password.yml
Normal file
24
ansible/change_password.yml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
- name: Utility - Change User Password
|
||||||
|
hosts: masters,workers
|
||||||
|
become: true
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
# Эта переменная придет из Semaphore Survey
|
||||||
|
target_user: "ubuntu"
|
||||||
|
tasks:
|
||||||
|
- name: Ensure passlib is installed on target (needed for hashing)
|
||||||
|
apt:
|
||||||
|
name: python3-passlib
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Update password for {{ target_user }}
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: "{{ target_user }}"
|
||||||
|
# Мы берем сырой пароль из переменной и хешируем его прямо здесь
|
||||||
|
password: "{{ requested_password | password_hash('sha512') }}"
|
||||||
|
update_password: always
|
||||||
|
|
||||||
|
- name: Success message
|
||||||
|
debug:
|
||||||
|
msg: "Password for {{ target_user }} has been updated!"
|
||||||
Reference in New Issue
Block a user