Files
IaC/ansible/change_password.yml

18 lines
778 B
YAML

---
- name: Utility - Change User Password
hosts: masters,workers
gather_facts: false
vars:
# Переменная requested_password придет из Survey в Semaphore
target_user: "ubuntu"
tasks:
- name: Update password for {{ target_user }} using chpasswd
become: true
# Мы передаем пароль через стандартный поток ввода (stdin) прямо в системную утилиту
shell: "echo '{{ target_user }}:{{ requested_password }}' | chpasswd"
# Чтобы пароль не светился в логах Semaphore даже в режиме Debug
no_log: true
- name: Confirm update
debug:
msg: "Password for {{ target_user }} has been updated successfully."