rut-prod-ops/scripts/ansible_playbooks/set_root_password.yaml

22 lines
526 B
YAML
Raw Normal View History

---
- name: Set root password for hosts
hosts: all
become: yes
vars_prompt:
- name: "root_password"
prompt: "Enter the new root password"
private: yes
tasks:
- name: Hash the root password on localhost
delegate_to: localhost
run_once: true
become: false
set_fact:
hashed_password: "{{ root_password | password_hash('sha512') }}"
- name: Set root password on target hosts
ansible.builtin.user:
name: root
password: "{{ hashed_password }}"