diff options
author | Ismaël Bouya <ismael.bouya@fretlink.com> | 2019-03-15 18:44:39 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@fretlink.com> | 2019-03-15 18:44:39 +0100 |
commit | e7270a0e65cbbf398d999db98278114d809244dc (patch) | |
tree | fb78e1818202e145f07b4d56cd77c7d4d5d7f5c4 /roles/contexts/fretlink/templates/environment.j2 | |
parent | 4be9c7bbea39b7a9f5ea8381977fa2c8a162ed6b (diff) | |
download | Ansible-e7270a0e65cbbf398d999db98278114d809244dc.tar.gz Ansible-e7270a0e65cbbf398d999db98278114d809244dc.tar.zst Ansible-e7270a0e65cbbf398d999db98278114d809244dc.zip |
Lookup psql passwords at runtime
Diffstat (limited to 'roles/contexts/fretlink/templates/environment.j2')
-rw-r--r-- | roles/contexts/fretlink/templates/environment.j2 | 41 |
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 | ||
44 | function capitalize() { | ||
45 | echo "$1" | sed -e 's!\(^\|-\)\(.\)!\U\2!g' | ||
46 | } | ||
47 | |||
44 | APP=$(basename $(pwd)) | 48 | APP=$(basename $(pwd)) |
45 | 49 | ||
46 | FL_APPS_HOST="localhost" | 50 | FL_APPS_HOST="localhost" |
@@ -79,26 +83,10 @@ FL_PSQL_PORT="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Local subkey=Por | |||
79 | FL_PSQL_USER="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Local subkey=User') }}" | 83 | FL_PSQL_USER="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Local subkey=User') }}" |
80 | FL_PSQL_PASSWORD="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Local') }}" | 84 | FL_PSQL_PASSWORD="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Local') }}" |
81 | 85 | ||
82 | FL_CARRIER_DIRECTORY_DEV_PSQL_HOST="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/CarrierDirectory subkey=Host') }}" | ||
83 | FL_CARRIER_DIRECTORY_DEV_PSQL_PORT="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/CarrierDirectory subkey=Port') }}" | ||
84 | FL_CARRIER_DIRECTORY_DEV_PSQL_USER="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/CarrierDirectory subkey=User') }}" | ||
85 | FL_CARRIER_DIRECTORY_DEV_PSQL_PASSWORD="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/CarrierDirectory') }}" | ||
86 | FL_CARRIER_DIRECTORY_DEV_PSQL_DB="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/CarrierDirectory subkey=Database') }}" | ||
87 | |||
88 | FL_GEODATA_DEV_PSQL_HOST="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Geodata subkey=Host') }}" | ||
89 | FL_GEODATA_DEV_PSQL_PORT="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Geodata subkey=Port') }}" | ||
90 | FL_GEODATA_DEV_PSQL_USER="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Geodata subkey=User') }}" | ||
91 | FL_GEODATA_DEV_PSQL_PASSWORD="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Geodata') }}" | ||
92 | FL_GEODATA_DEV_PSQL_DB="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Geodata subkey=Database') }}" | ||
93 | |||
94 | FL_NOTIFIER_DEV_PSQL_HOST="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Notifier subkey=Host') }}" | ||
95 | FL_NOTIFIER_DEV_PSQL_PORT="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Notifier subkey=Port') }}" | ||
96 | FL_NOTIFIER_DEV_PSQL_USER="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Notifier subkey=User') }}" | ||
97 | FL_NOTIFIER_DEV_PSQL_PASSWORD="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Notifier') }}" | ||
98 | FL_NOTIFIER_DEV_PSQL_DB="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Notifier subkey=Database') }}" | ||
99 | |||
100 | FL_TOOLBOX_AGENT_MACAROON="{{ lookup('passwordstore', 'Travail/Fretlink/Macaroons/ToolboxAgent') }}" | 86 | FL_TOOLBOX_AGENT_MACAROON="{{ lookup('passwordstore', 'Travail/Fretlink/Macaroons/ToolboxAgent') }}" |
101 | 87 | ||
88 | export FRETLINK_ENV="$APP ${FL_ENV:-local}" | ||
89 | |||
102 | if [ -f "local.env.example" ]; then | 90 | if [ -f "local.env.example" ]; then |
103 | source local.env.example | 91 | source local.env.example |
104 | fi | 92 | fi |
@@ -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 |
140 | fi | 123 | fi |
141 | 124 | ||