try to reuse quagga password
authorJustin Wind <j.wind@partner.samsung.com>
Mon, 24 Apr 2017 20:33:18 +0000 (13:33 -0700)
committerJustin Wind <j.wind@partner.samsung.com>
Mon, 24 Apr 2017 20:33:18 +0000 (13:33 -0700)
ansible.cfg
generate-ansible-vpcaccess-vars.sh

index de5f2b3f67680b5792d72ff36ec71e7255dfc01f..03122cf1b30e0262623de5aa73c459f9d4fcbe3c 100644 (file)
@@ -3,4 +3,4 @@ retry_files_enabled = False
 host_key_checking = False
 inventory = inventory
 remote_user = ec2-user
-private_key_file = keys/management.pem
+private_key_file = keys/management
index 0a5d14a62aedf2a732c02ba1da3a4906c0481086..e951308859f2f51f9cf8158f3fea1e62a9c00349 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 set -e
+set -o pipefail
 
 if [ $# -ne 2 ]
 then
@@ -14,6 +15,20 @@ cert="${1}_ca/pki/issued/${2}.${1}.crt"
 key="${1}_ca/pki/private/${2}.${1}.key"
 ta_secret="${1}_ca/pki/ta.key"
 
+# reuse any extant quagga password
+for v in "${1}"/group_vars/*vpcaccess*
+do
+       if [ -n "${quagga_password}" ]
+       then
+               echo "found multiple potential quagga passwords; the chosen one may not be correct" 1>&2
+       fi
+       quagga_password=$(awk '/QUAGGA_PASSWORD:/{print $2}' "${v}")
+done
+if [ -z "${quagga_password}" ]
+then
+       quagga_password=$(pwgen -y 16)
+fi
+
 function onlycert(){
        sed -n '/-----BEGIN /,/-----END /p' "$@"
 }
@@ -23,7 +38,7 @@ function indent(){
 
 cat<<EOF
 ---
-QUAGGA_PASSWORD: $(pwgen -y 16)
+QUAGGA_PASSWORD: "${quagga_password}"
 ca_name: $1
 ca_cert: |
 $(indent "${ca_cert}")