From 28f91350c5cf53855c1e9791c87a1040fa4d145c Mon Sep 17 00:00:00 2001 From: ogrechko Date: Sun, 28 Dec 2025 15:34:23 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20ansible/change=5Fpassword.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ansible/change_password.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 ansible/change_password.yml diff --git a/ansible/change_password.yml b/ansible/change_password.yml new file mode 100644 index 0000000..33e3ab8 --- /dev/null +++ b/ansible/change_password.yml @@ -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!" \ No newline at end of file