Unify deploy secret keys for the main server

We were using `server` on staging but `server1` and `server2` on
preproduction and production.

The reason behind it is we've always used one server on staging but
sometimes we've used several servers on preproduction and production.

However, this is a bit of a mess on installations which have only one
server on preproduction or production and need to use the `server` key
for the staging environments but `server1` for other environments.

So, in order to keep compatibility with existing Consul installations,
we're now allowing either `server` or `server1` on any environment.
This commit is contained in:
Javi Martín
2023-03-21 19:01:26 +01:00
parent b115b0cc8d
commit 8aa113a47c
5 changed files with 14 additions and 6 deletions

View File

@@ -3,7 +3,15 @@ lock "~> 3.17.1"
def deploysecret(key)
@deploy_secrets_yml ||= YAML.load_file("config/deploy-secrets.yml")[fetch(:stage).to_s]
@deploy_secrets_yml.fetch(key.to_s, "undefined")
@deploy_secrets_yml.fetch(key.to_s, "")
end
def main_deploy_server
if deploysecret(:server1) && !deploysecret(:server1).empty?
deploysecret(:server1)
else
deploysecret(:server)
end
end
set :rails_env, fetch(:stage)