Advertisement
Guest User

ansible

a guest
Oct 28th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #!/bin/sh
  2. #Generate Random 6 char password
  3. clearpass=`openssl rand -base64 4`
  4. #Use sed to remove the user line to clear last password update
  5. sed -i '/user/d' /etc/ansible/changepasswd1.yml
  6. #Use crypt to make a hash of your 6 char password
  7. HASH=`echo $clearpass | openssl passwd -1 -stdin`
  8. #Add the User line back into the file with your new hash
  9. #echo user: name=root update_password=always password=${HASH}' >> /etc/ansible/changepasswd1.yml
  10. echo ' - user: name=root password='$HASH >> /etc/ansible/changepasswd1.yml
  11.  
  12. #Email me my new password
  13.  
  14.  
  15. #Launch playbook
  16. ansible-playbook -s /etc/ansible/changepasswd1.yml
  17. echo \
  18.  
  19. echo 'Your new PASSWORD' $clearpass
  20.  
  21.  
  22. cat /etc/ansible/changepasswd1.yml
  23.  
  24. - hosts: tserver
  25. vars:
  26. # created with:
  27. # python -c 'import crypt; print crypt.crypt("This is my Password", "$1$SomeSalt$")'
  28. #password: $1$SomeSalt$UqddPX3r4kH3UL5jq5/ZI.
  29.  
  30. tasks:
  31. - user: name=root password=$1$lALdxwUI$n0BbiDt7upBy0usLzxPks.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement