How to automate the password changes using Ansible
Ansible is an open-source automation engine that automates software provisioning, configuration management, and application deployment. Playbooks are Ansible’s configuration, deployment, and orchestration language. Playbooks are expressed in YAML format (see YAML Syntax) and have a minimum of syntax, which intentionally tries to not be a programming language or script, but rather a model of a configuration or a process.
This article explains the steps for automating the password changes using Ansible.
Step1: Install the password hashing library
#pip install passlib
Step2: Generate the password
#python -c "from passlib.hash import sha512_crypt; import getpass; print sha512_crypt.encrypt(getpass.getpass())"
Step3: Open a yaml file in the Ansible installation folder and save the below content to it.
- hosts: all
tasks:
- name: Change root password
user: name=root update_password=always password=HASHEDSTRING