Commit 73ab93e9 by Ned Batchelder

Put the password generator into a real .sh file

(cherry picked from commit b2beddb4d35c12537d17454e543363201c578cd8)
parent 5e8b26bb
#!/usr/bin/env bash
#
# Read a list of Ansible variables that should have generated values, and make
# a new file just like it, with the generated values.
TARGET=${OPENEDX_RELEASE-master}
wget -q https://raw.githubusercontent.com/edx/configuration/$TARGET/playbooks/sample_vars/passwords.yml -O passwords-template.yml
while IFS= read line; do
# Make a random string. SECRET_KEY's should be longer.
length=35
if [[ $line == *SECRET_KEY* ]]; then
length=100
fi
REPLACE=$(LC_ALL=C < /dev/urandom tr -dc 'A-Za-z0-9' | head -c$length)
# Change "!!null"-to-end-of-line to the password.
echo "$line" | sed "s/\!\!null.*/\'$REPLACE\'/"
done < passwords-template.yml > my-passwords.yml
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment