Files
IaC/ansible/change_password.yml

24 lines
798 B
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
- 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!"