Skip to content

Commit

Permalink
👌(typo) updating code due to code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cchaudier committed Jul 11, 2018
1 parent 44104fe commit 7ee5e60
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 44 deletions.
4 changes: 2 additions & 2 deletions apps/_common/templates/route/main.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ metadata:
env_type: "{{ env_type }}"
customer: "{{ customer }}"
app: "{{ app.name }}"
version: "{{ item.0.tag | default('init', true) }}"
deployment_stamp: "{{ deployment_stamp | default('init', true) }}"
version: "{{ item.0.tag | default('null', true) }}"
deployment_stamp: "{{ deployment_stamp | default('null', true) }}"
annotations:
kubernetes.io/tls-acme: "true"
spec:
Expand Down
2 changes: 1 addition & 1 deletion deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# Patch all next routes of all apps after deploy
- include_tasks: tasks/run_tasks_for_apps.yml
vars:
prefixe: "next"
prefix: "next"
tasks:
- deploy_get_stamp_from_route
- deploy_patch_route
Expand Down
8 changes: 4 additions & 4 deletions docs/developer_guide/playbooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ The `deploy.yml` playbook defines a new `deployment_stamp` to create a whole new
stack by defining OpenShift objects with unique labels and names. This allows us
to initiate a blue/green deployment strategy.

https://framindmap.org/c/maps/507624/public

### Usage

```bash
Expand All @@ -108,8 +106,10 @@ $ docker run --rm -it \

## `switch.yml`

The `switch.yml` playbook move the current stack to the previous route
and move the next stack to the current route.
The `switch.yml` playbook moves:
1. the *current* stack to the *previous* route
2. the *next* stack to the *current* route.


### Usage

Expand Down
2 changes: 1 addition & 1 deletion get_route.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Patch all current routes of all apps after deploy
- include_tasks: tasks/run_tasks_for_apps.yml
vars:
prefixe: "current"
prefix: "current"
tasks:
- deploy_get_stamp_from_route
- deploy_patch_route
Expand Down
8 changes: 5 additions & 3 deletions plugins/callback/anstomlog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# coding=utf-8
# pylint: disable=I0011,E0401,C0103,C0111,W0212
# https://github.com/octplane/ansible_stdout_compact_logger


from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
Expand Down Expand Up @@ -128,7 +130,7 @@ def test_hash_array(self):
def test_hash_array2(self):
hs = {u'cmd': ['one', 'two']}
expected_result = """{
- cmd: [
- cmd: [
- one
- two
]
Expand All @@ -144,7 +146,7 @@ def test_nested(self):
hs = {u'cmd': {'bar': ['one', 'two']}}
expected_result = """{
- cmd: {
- bar: [
- bar: [
- one
- two
]
Expand All @@ -155,7 +157,7 @@ def test_nested(self):
def test_multiline_single(self):
# pylint: disable=I0011,C0303
hs = [["foo", "bar"]]
expected_result = """[ [
expected_result = """[ [
- foo
- bar
] ]"""
Expand Down
7 changes: 3 additions & 4 deletions switch.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
# 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)
# 1. point the "previous" route to the stack that was pointed by the "current" route,
# 2. point the "current" route to the stack that was pointed by the "next" route,
# 3. delete the stack that was pointed by the "previous" route,
# 4. patch the next route to the init stamp

- hosts: local
Expand All @@ -12,7 +12,6 @@

- import_tasks: tasks/set_vars.yml

# Patch all apps dest routes with src stack
- include_tasks: tasks/run_tasks_for_apps.yml
vars:
tasks:
Expand Down
2 changes: 1 addition & 1 deletion tasks/delete_app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- include_tasks: deploy_apps.yml
vars:
deployment_state: "absent"
deployment_stamp: "{{ route_deployment_stamp }}"
deployment_stamp: "{{ app_route_deployment_stamp }}"
tags:
- delete
- deploy
9 changes: 5 additions & 4 deletions tasks/deploy_apps.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
# tasks for managing apps
# Task set to manage apps
#
# Args:
# deployment_state:
# - present : default value, all objects are created
# - 'absent': all objects are deleted
# deployment_stamp : the stamp of the object we going to creat or delete
# - "present": default value, all objects are created
# - "absent": all objects are deleted
# deployment_stamp: the stamp of the object we are going to create or delete

- name: "OpenShift objects with deployment_stamp[{{ deployment_stamp }}] must be {{ deployment_state | default('present') }}"
openshift_raw:
Expand Down
14 changes: 7 additions & 7 deletions tasks/deploy_get_stamp_from_route.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
# Get deployment_stamp from a route

- name: Get deployment_stamp of route[{{ app.name }}-{{ prefixe }}]
- name: Get deployment_stamp from route[{{ app.name }}-{{ prefix }}]
openshift_raw:
definition: "{{ lookup('template', 'templates/openshift/common/utils/get_deployment_stamp_form_route.yml.j2') | from_yaml }}"
register: my_route
definition: "{{ lookup('template', 'templates/openshift/common/utils/get_deployment_stamp_from_route.yml.j2') | from_yaml }}"
register: app_route

- name: set_fact route_deployment_stamp
- name: set_fact app_route_deployment_stamp
set_fact:
route_deployment_stamp: "{{ my_route.result.metadata.labels.deployment_stamp }}"
app_route_deployment_stamp: "{{ app_route.result.metadata.labels.deployment_stamp }}"

- name: Print route_deployment_stamp
debug: msg="[{{ app.name }}] route[{{ app.name }}-{{ prefixe }}] route_deployment_stamp[{{ route_deployment_stamp }}]"
- name: Print app_route_deployment_stamp
debug: msg="[{{ app.name }}] route[{{ app.name }}-{{ prefix }}] app_route_deployment_stamp[{{ app_route_deployment_stamp }}]"
6 changes: 3 additions & 3 deletions tasks/deploy_patch_route.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
# Patch routes of all services of one app to the new deployment_stamp
# Patch routes of all services from a single app to the new deployment_stamp

- name: "[{{ app.name }}] Patch route[{{ app.name }}-{{ prefixe }}] with deployment_stamp[{{ deployment_stamp }}]"
- name: "[{{ app.name }}] Patch route[{{ app.name }}-{{ prefix }}] with deployment_stamp[{{ deployment_stamp }}]"
openshift_raw:
force: true
definition: "{{ lookup('template', 'templates/openshift/common/route/main.yml.j2') | from_yaml }}"
state: present
with_nested:
- "{{ app.services }}"
- "{{ prefixe }}"
- "{{ prefix }}"
when: item.0.host is defined
12 changes: 6 additions & 6 deletions tasks/switch_route.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---
# Patch all apps dest routes with src stack
# Patch app dest route with src stack

- name: Print switch details
debug: msg="[{{ app.name }}] Switch routes from {{ prefixe_route_src }} to {{ prefixe_route_dest }}"
debug: msg="[{{ app.name }}] Switch routes from {{ prefix_route_src }} to {{ prefix_route_dest }}"
tags: switch

- include_tasks: deploy_get_stamp_from_route.yml
vars:
prefixe: "{{ prefixe_route_src }}"
prefix: "{{ prefix_route_src }}"
tags: switch

- include_tasks: deploy_patch_route.yml
vars:
prefixe: "{{ prefixe_route_dest }}"
deployment_stamp: "{{ route_deployment_stamp }}"
prefix: "{{ prefix_route_dest }}"
deployment_stamp: "{{ app_route_deployment_stamp }}"
tags: switch

- include_tasks: deploy_patch_route.yml
vars:
prefixe: "{{ prefixe_route_src }}"
prefix: "{{ prefix_route_src }}"
tags: switch
14 changes: 7 additions & 7 deletions tasks/switch_routes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

- include_tasks: deploy_get_stamp_from_route.yml
vars:
prefixe: "previous"
prefix: "previous"
tags: switch

- name: save previous_route_deployment_stamp
- name: Save previous_app_route_deployment_stamp
set_fact:
previous_route_deployment_stamp: "{{ route_deployment_stamp }}"
previous_app_route_deployment_stamp: "{{ app_route_deployment_stamp }}"

- include_tasks: switch_route.yml
vars:
prefixe_route_src: "{{ prefixe_route.src }}"
prefixe_route_dest: "{{ prefixe_route.dest }}"
prefix_route_src: "{{ prefix_route.src }}"
prefix_route_dest: "{{ prefix_route.dest }}"
tasks:
- switch_routes
with_items:
Expand All @@ -22,8 +22,8 @@
- src: next
dest: current
loop_control:
loop_var: prefixe_route
loop_var: prefix_route

- include_tasks: delete_app.yml
vars:
route_deployment_stamp: "{{ previous_route_deployment_stamp }}"
app_route_deployment_stamp: "{{ previous_app_route_deployment_stamp }}"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: Route
metadata:
name: "{{ app.name }}-{{ prefixe }}"
name: "{{ app.name }}-{{ prefix }}"
namespace: "{{ project_name }}"
labels:
env_type: {{ env_type }}
Expand Down

0 comments on commit 7ee5e60

Please sign in to comment.