Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #Generate Random 6 char password
- clearpass=`openssl rand -base64 4`
- #Use sed to remove the user line to clear last password update
- sed -i '/user/d' /etc/ansible/changepasswd1.yml
- #Use crypt to make a hash of your 6 char password
- HASH=`echo $clearpass | openssl passwd -1 -stdin`
- #Add the User line back into the file with your new hash
- #echo user: name=root update_password=always password=${HASH}' >> /etc/ansible/changepasswd1.yml
- echo ' - user: name=root password='$HASH >> /etc/ansible/changepasswd1.yml
- #Email me my new password
- #Launch playbook
- ansible-playbook -s /etc/ansible/changepasswd1.yml
- echo \
- echo 'Your new PASSWORD' $clearpass
- cat /etc/ansible/changepasswd1.yml
- - hosts: tserver
- vars:
- # created with:
- # python -c 'import crypt; print crypt.crypt("This is my Password", "$1$SomeSalt$")'
- #password: $1$SomeSalt$UqddPX3r4kH3UL5jq5/ZI.
- tasks:
- - user: name=root password=$1$lALdxwUI$n0BbiDt7upBy0usLzxPks.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement