Skip to content

Commit 7a22d82

Browse files
committed
Namespace stacks per deploy enviroment
Prefix stack name with stage name and get stage name from inventory file instead of variable
1 parent 15bb6a8 commit 7a22d82

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

ansible/deploy.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
set_fact:
4747
deploy_local_username: "{{ local_username_result.stdout }}"
4848

49+
- name: Set target deploy stage name
50+
set_fact:
51+
stage_name: "{{ inventory_file | splitext | first }}"
52+
4953
- name: Copy deploy .env file to server
5054
template:
5155
src: deploy_env.j2
@@ -57,21 +61,21 @@
5761
docker_stack:
5862
state: present
5963
with_registry_auth: yes
60-
name: gup
64+
name: "{{ 'gup_' ~ stage_name }}"
6165
compose:
6266
- /opt/gup-docker-deploy/docker-compose.yml
6367
- /opt/gup-docker-deploy/docker-compose.deploy.yml
6468
- version: '3.7'
6569
services:
6670
frontend:
6771
environment:
68-
- "EMBER_ENVIRONMENT={{ gup_environment }}"
72+
- "EMBER_ENVIRONMENT={{ stage_name }}"
6973
- "GUP_SERVICE_PORT={{ gup_backend_port }}"
7074
ports:
7175
- "{{ gup_frontend_port }}:8080"
7276
backend:
7377
environment:
74-
- "GUP_ENVIRONMENT={{ gup_environment }}"
78+
- "GUP_ENVIRONMENT={{ stage_name }}"
7579
- "GUP_DB={{ gup_db }}"
7680
- "GUP_DB_USER={{ gup_db_user }}"
7781
- "GUP_DB_PASSWORD={{ gup_db_password }}"
@@ -99,7 +103,7 @@
99103
image: "docker.ub.gu.se/gup-backend:{{ deploy_git_revision }}"
100104
command: "rake db:migrate"
101105
env:
102-
RAILS_ENV: "{{ gup_environment }}" # RAILS_ENV instead of GUP_ENVIRONMENT for rake
106+
RAILS_ENV: "{{ stage_name }}" # RAILS_ENV instead of GUP_ENVIRONMENT for rake
103107
GUP_DB: "{{ gup_db }}"
104108
GUP_DB_USER: "{{ gup_db_user }}"
105109
GUP_DB_PASSWORD: "{{ gup_db_password }}"

ansible/inventory/lab.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ all:
99
utv02:
1010
vars:
1111
deploy_git_revision: docker-friendly-config-v1
12-
gup_environment: lab
1312
gup_db: gup_db
1413
gup_db_user: gup_user
1514
gup_db_password: gup_pass
1615
gup_scopus_api_key: <scopus_key>
1716
gup_mq_api_key: <mq_key>
1817
gup_secret_key_base: 29f01727314845cd7351aace2c4453e28cb95089dadafb49e299e5750e382c303d483d25c2854832fe274d6d27e09442fce906c2621e311ff650fd79644c8ea8
19-

docker/docker-compose.deploy.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ services:
33
frontend:
44
ports:
55
- ${GUP_FRONTEND_PORT}:8080
6+
networks:
7+
- haproxy
8+
endpint_mode: dnsrr
69
backend:
10+
networks:
11+
- haproxy
712
endpoint_mode: dnsrr
813
db:
914
deploy:

0 commit comments

Comments
 (0)