summaryrefslogtreecommitdiff
path: root/roles/contexts/fretlink/templates
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@fretlink.com>2019-03-15 18:44:39 +0100
committerIsmaël Bouya <ismael.bouya@fretlink.com>2019-03-15 18:44:39 +0100
commite7270a0e65cbbf398d999db98278114d809244dc (patch)
treefb78e1818202e145f07b4d56cd77c7d4d5d7f5c4 /roles/contexts/fretlink/templates
parent4be9c7bbea39b7a9f5ea8381977fa2c8a162ed6b (diff)
downloadAnsible-e7270a0e65cbbf398d999db98278114d809244dc.tar.gz
Ansible-e7270a0e65cbbf398d999db98278114d809244dc.tar.zst
Ansible-e7270a0e65cbbf398d999db98278114d809244dc.zip
Lookup psql passwords at runtime
Diffstat (limited to 'roles/contexts/fretlink/templates')
-rw-r--r--roles/contexts/fretlink/templates/environment.j241
1 files changed, 12 insertions, 29 deletions
diff --git a/roles/contexts/fretlink/templates/environment.j2 b/roles/contexts/fretlink/templates/environment.j2
index 91a6f6a..652fc8d 100644
--- a/roles/contexts/fretlink/templates/environment.j2
+++ b/roles/contexts/fretlink/templates/environment.j2
@@ -41,6 +41,10 @@ build_macaroon() {
41 popd 2>/dev/null >/dev/null 41 popd 2>/dev/null >/dev/null
42} 42}
43 43
44function capitalize() {
45 echo "$1" | sed -e 's!\(^\|-\)\(.\)!\U\2!g'
46}
47
44APP=$(basename $(pwd)) 48APP=$(basename $(pwd))
45 49
46FL_APPS_HOST="localhost" 50FL_APPS_HOST="localhost"
@@ -79,26 +83,10 @@ FL_PSQL_PORT="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Local subkey=Por
79FL_PSQL_USER="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Local subkey=User') }}" 83FL_PSQL_USER="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Local subkey=User') }}"
80FL_PSQL_PASSWORD="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Local') }}" 84FL_PSQL_PASSWORD="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Local') }}"
81 85
82FL_CARRIER_DIRECTORY_DEV_PSQL_HOST="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/CarrierDirectory subkey=Host') }}"
83FL_CARRIER_DIRECTORY_DEV_PSQL_PORT="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/CarrierDirectory subkey=Port') }}"
84FL_CARRIER_DIRECTORY_DEV_PSQL_USER="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/CarrierDirectory subkey=User') }}"
85FL_CARRIER_DIRECTORY_DEV_PSQL_PASSWORD="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/CarrierDirectory') }}"
86FL_CARRIER_DIRECTORY_DEV_PSQL_DB="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/CarrierDirectory subkey=Database') }}"
87
88FL_GEODATA_DEV_PSQL_HOST="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Geodata subkey=Host') }}"
89FL_GEODATA_DEV_PSQL_PORT="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Geodata subkey=Port') }}"
90FL_GEODATA_DEV_PSQL_USER="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Geodata subkey=User') }}"
91FL_GEODATA_DEV_PSQL_PASSWORD="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Geodata') }}"
92FL_GEODATA_DEV_PSQL_DB="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Geodata subkey=Database') }}"
93
94FL_NOTIFIER_DEV_PSQL_HOST="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Notifier subkey=Host') }}"
95FL_NOTIFIER_DEV_PSQL_PORT="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Notifier subkey=Port') }}"
96FL_NOTIFIER_DEV_PSQL_USER="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Notifier subkey=User') }}"
97FL_NOTIFIER_DEV_PSQL_PASSWORD="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Notifier') }}"
98FL_NOTIFIER_DEV_PSQL_DB="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Notifier subkey=Database') }}"
99
100FL_TOOLBOX_AGENT_MACAROON="{{ lookup('passwordstore', 'Travail/Fretlink/Macaroons/ToolboxAgent') }}" 86FL_TOOLBOX_AGENT_MACAROON="{{ lookup('passwordstore', 'Travail/Fretlink/Macaroons/ToolboxAgent') }}"
101 87
88export FRETLINK_ENV="$APP ${FL_ENV:-local}"
89
102if [ -f "local.env.example" ]; then 90if [ -f "local.env.example" ]; then
103 source local.env.example 91 source local.env.example
104fi 92fi
@@ -125,17 +113,12 @@ if [ "$APP" != "app" ]; then
125 export POSTGRESQL_ADDON_PASSWORD="$FL_PSQL_PASSWORD" 113 export POSTGRESQL_ADDON_PASSWORD="$FL_PSQL_PASSWORD"
126 export POSTGRESQL_ADDON_DB="$name" 114 export POSTGRESQL_ADDON_DB="$name"
127 else 115 else
128 postgresql_host="FL_${name^^}_${FL_ENV^^}_PSQL_HOST" 116 key=Psql/$(capitalize $FL_ENV)/$(capitalize $APP)
129 postgresql_port="FL_${name^^}_${FL_ENV^^}_PSQL_PORT" 117 export POSTGRESQL_ADDON_HOST=$(p $key Host)
130 postgresql_user="FL_${name^^}_${FL_ENV^^}_PSQL_USER" 118 export POSTGRESQL_ADDON_PORT=$(p $key Port)
131 postgresql_password="FL_${name^^}_${FL_ENV^^}_PSQL_PASSWORD" 119 export POSTGRESQL_ADDON_USER=$(p $key User)
132 postgresql_db="FL_${name^^}_${FL_ENV^^}_PSQL_DB" 120 export POSTGRESQL_ADDON_PASSWORD=$(p $key)
133 export FRETLINK_ENV="$FL_ENV" 121 export POSTGRESQL_ADDON_DB=$(p $key Database)
134 export POSTGRESQL_ADDON_HOST="${!postgresql_host}"
135 export POSTGRESQL_ADDON_PORT="${!postgresql_port}"
136 export POSTGRESQL_ADDON_USER="${!postgresql_user}"
137 export POSTGRESQL_ADDON_PASSWORD="${!postgresql_password}"
138 export POSTGRESQL_ADDON_DB="${!postgresql_db}"
139 fi 122 fi
140fi 123fi
141 124