Skip to content

Instantly share code, notes, and snippets.

@e30chris
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e30chris/79880828aefbf9b08da1 to your computer and use it in GitHub Desktop.
Save e30chris/79880828aefbf9b08da1 to your computer and use it in GitHub Desktop.
playbook to align root passwords
---
# find the root password, login then update password to align
- name: test possible passwords
local_action: shell sshpass -p {{ item }} ssh {{ user }}@{{ inventory_hostname }} date
register: pastpass
ignore_errors: true
with_items:
- "{{ past_password_01 }}"
- "{{ past_password_02 }}"
- "{{ past_password_03 }}"
- "{{ past_password_04 }}"
- set_fact: ansible_ssh_pass={{ item.item }}
with_items: pastpass.results
when: item.rc == 0
- name: set the right password
user: name={{ user }} password={{ new_password }} group={{ group }}
- name: set the right password for ansible too
set_fact: ansible_ssh_pass={{ new_password }}
********group_vars/all************
---
# common variables for Ansible-AlignPassword
# format for this file
# variable: fact
#
# User the test & align password for
user: root
# Group the User belongs to
group: root
# Possible Passwords to test
past_password_01: bmw325
past_password_02: bmw525
past_password_03: bmw750
past_password_04: bmw850
# New Password for all servers
# Created with
# python -c 'import crypt; print crypt.crypt("bmwm1", "$1$SomeSalt$")'
new_password: $15bBd21FawYY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment