-
Notifications
You must be signed in to change notification settings - Fork 8
/
create_redirect.yml
76 lines (62 loc) · 2.5 KB
/
create_redirect.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
# This playbook creates the redirection core app objects.
- name: Create HTTP redirections
hosts: local
gather_facts: false
pre_tasks:
- name: Check configuration
ansible.builtin.import_tasks: tasks/check_configuration.yml
tasks:
- name: Display playbook name
ansible.builtin.debug: msg="==== Starting create_redirect playbook ===="
tags: deploy
# Set the deployment stamp value that will be used to make created objects
# unique.
- name: Set deployment stamp
ansible.builtin.set_fact: deployment_stamp="d-{{ lookup('pipe', 'date +%y%m%d-%Hh%Mm%Ss') }}"
- name: Set vars
ansible.builtin.import_tasks: tasks/set_vars.yml
- name: Lookup available core applications
ansible.builtin.set_fact:
core_apps: "{{ lookup('apps', core_apps_paths) }}"
- name: Set app to point to the redirect app
ansible.builtin.set_fact:
app: '{{ core_apps | json_query("[?name==`redirect`] | [0]") }}'
- name: Include "all" type vars for redirect app
ansible.builtin.include_tasks: tasks/load_app_defaults.yml
vars:
file: "{{ item.path }}"
with_items: '{{ app | json_query("vars[?type==`all`]") }}'
- name: Get objects for app
ansible.builtin.import_tasks: tasks/get_objects_for_app.yml
- name: Create app config
ansible.builtin.import_tasks: tasks/create_app_config.yml
- name: Create redirect deployments
kubernetes.core.k8s:
force: true
namespace: "{{ namespace_name }}"
definition: "{{ lookup('template', deployment) | from_yaml_all }}"
state: present
loop: "{{ deployments }}"
loop_control:
loop_var: deployment
# Check if the nginx service already exists and recreate it only if not
# (parts of an k8s Service definition are immutable).
- name: Check if the redirect nginx service already exists
kubernetes.core.k8s_info:
api_version: "v1"
namespace: "{{ namespace_name }}"
kind: "Service"
name: "redirect-nginx"
register: redirect_nginx_service
- name: Create redirect services
kubernetes.core.k8s:
namespace: "{{ namespace_name }}"
definition: "{{ lookup('template', service) | from_yaml_all }}"
state: present
loop: "{{ services }}"
loop_control:
loop_var: service
when: redirect_nginx_service.resources | length == 0
- name: Create redirection ingresses
ansible.builtin.import_tasks: tasks/create_redirection_ingresses.yml