-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨(route:switch) move current route to the next stack
We confirm a deployment by triggering a route switch: 1. point the previous route to the current stack 2. point the current route to the next stack 3. point the next route to the default stack (init) who don't exist 4. delete the previous stack
- Loading branch information
Showing
11 changed files
with
109 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
# shellcheck source=bin/_config.sh | ||
source "$(dirname "${BASH_SOURCE[0]}")/_config.sh" | ||
|
||
# Run ansible-playbook | ||
_docker_run ansible-playbook switch.yml "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
# This playbook switch all routes: | ||
# 1. point the "current" route to the stack that was pointed by the "next" route, | ||
# 2. point the "previous" route to the stack that was pointed by the "current" route just before we changed it in 1) | ||
# 3. delete the stack that was pointed by the "previous" route just before we changed it in 2) | ||
# 4. patch the next route to the init stamp | ||
|
||
- hosts: local | ||
gather_facts: False | ||
|
||
tasks: | ||
|
||
- import_tasks: tasks/set_vars.yml | ||
|
||
# Patch all apps dest routes with src stack | ||
- include_tasks: tasks/run_tasks_for_apps.yml | ||
vars: | ||
tasks: | ||
- switch_routes | ||
tags: | ||
- route | ||
- switch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
--- | ||
# Get deployment_stamp from a route | ||
|
||
- name: Print get details | ||
debug: msg="[{{ app.name }}] route.name[{{ app.name }}-{{ prefixe }}] " | ||
|
||
- name: Get deployment_stamp of route | ||
- name: Get deployment_stamp of route[{{ app.name }}-{{ prefixe }}] | ||
openshift_raw: | ||
definition: "{{ lookup('template', 'templates/openshift/common/utils/get_deployment_stamp_form_route.yml.j2') | from_yaml }}" | ||
register: my_route | ||
|
||
- name: set_fact deployment_stamp to delete | ||
- name: set_fact route_deployment_stamp | ||
set_fact: | ||
route_deployment_stamp: "{{ my_route.result.metadata.labels.deployment_stamp }}" | ||
# cacheable: true | ||
|
||
- name: Print old route_deployment_stamp | ||
debug: msg="[{{ app.name }}] route_deployment_stamp [{{ route_deployment_stamp }}]" | ||
- name: Print route_deployment_stamp | ||
debug: msg="[{{ app.name }}] route[{{ app.name }}-{{ prefixe }}] route_deployment_stamp[{{ route_deployment_stamp }}]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
# Patch all apps dest routes with src stack | ||
|
||
- name: Print switch details | ||
debug: msg="[{{ app.name }}] Switch routes from {{ prefixe_route_src }} to {{ prefixe_route_dest }}" | ||
tags: switch | ||
|
||
- include_tasks: deploy_get_stamp_from_route.yml | ||
vars: | ||
prefixe: "{{ prefixe_route_src }}" | ||
tags: switch | ||
|
||
- include_tasks: deploy_patch_route.yml | ||
vars: | ||
prefixe: "{{ prefixe_route_dest }}" | ||
deployment_stamp: "{{ route_deployment_stamp }}" | ||
tags: switch | ||
|
||
- include_tasks: deploy_patch_route.yml | ||
vars: | ||
prefixe: "{{ prefixe_route_src }}" | ||
tags: switch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
# Patch app dest routes with src stack | ||
|
||
- include_tasks: deploy_get_stamp_from_route.yml | ||
vars: | ||
prefixe: "previous" | ||
tags: switch | ||
|
||
- name: save previous_route_deployment_stamp | ||
set_fact: | ||
previous_route_deployment_stamp: "{{ route_deployment_stamp }}" | ||
|
||
- include_tasks: switch_route.yml | ||
vars: | ||
prefixe_route_src: "{{ prefixe_route.src }}" | ||
prefixe_route_dest: "{{ prefixe_route.dest }}" | ||
tasks: | ||
- switch_routes | ||
with_items: | ||
- src: current | ||
dest: previous | ||
- src: next | ||
dest: current | ||
loop_control: | ||
loop_var: prefixe_route | ||
|
||
- include_tasks: delete_app.yml | ||
vars: | ||
route_deployment_stamp: "{{ previous_route_deployment_stamp }}" |