Guest User

Untitled

a guest
Oct 26th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. ---
  2. # File: /etc/ansible/playbooks/prod/update_root_pw.yml
  3. # Authors: bgstack15
  4. # Startdate: 2017-10-24
  5. # Title: Playbook that updates the local root password
  6. # Purpose: Makes it easy to update the root password
  7. # Usage:
  8. # time ansible-playbook /etc/ansible/playbooks/prod/update_root_pw.yml -i /etc/ansible/dc3.inv -l el7test14 -v --ask-vault-pass
  9. # Make file /home/ansible/rootpw.yml with the contents:
  10. # ---
  11. # password: "super$ecretpa5swOrdmy"
  12. # ...
  13. # Encrypt with:
  14. # ansible-vault encrypt /home/ansible/rootpw.yml
  15. # Reference:
  16. # Version: 2017-10-24a
  17. # Notes:
  18.  
  19. - hosts: all
  20. vars_files:
  21. - /home/ansible/rootpw.yml
  22. tasks:
  23.  
  24. - block:
  25.  
  26. # alternatives include yum: package=expect state=present
  27. - name: Move pexpect-3.3 to server and untar
  28. unarchive:
  29. src: /etc/ansible/templates/pexpect-3.3.tar.gz
  30. dest: /usr/
  31. owner: root
  32. group: root
  33. mode: 0770
  34.  
  35. - name: Install pexpect
  36. command: /usr/bin/python setup.py install
  37. args:
  38. chdir: /usr/pexpect-3.3/
  39.  
  40. # for some reason this does not work: user: name=root password="{{ password }}"
  41. - name: Set password to permanent password
  42. expect:
  43. command: passwd root
  44. responses:
  45. (?i)password: "{{ password }}"
  46.  
  47. - name: Password last set on today, with minimum password life of 0 days
  48. command: chage -d "{{ ansible_date_time.date }}" -m 0 -E -1 -M -1 root
  49.  
  50. - name: Set expiration date of never
  51. command: usermod -e -1 root
  52. register: usermod
  53. changed_when: 'usermod.stderr != "usermod: no changes"'
  54.  
  55. become: yes
  56. ...
Add Comment
Please, Sign In to add comment