Repository navigation
Expand file tree
/
Copy pathplaybook_osac_create_hosted_cluster.yml
More file actions
89 lines (76 loc) · 2.86 KB
/
Copy pathplaybook_osac_create_hosted_cluster.yml
File metadata and controls
89 lines (76 loc) · 2.86 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
---
- name: Create a hosted control plane cluster from a ClusterOrder
hosts: localhost
gather_facts: false
vars:
cluster_order: "{{ ansible_eda.event.payload }}"
pre_tasks:
- name: Write SSH keys from env vars to files
ansible.builtin.include_role:
name: osac.service.write_ssh_keys
when:
- network_class | default('') == 'netris'
- lookup('env', 'SERVER_SSH_KEY') | length > 0
- name: Set cluster order name
ansible.builtin.set_fact:
cluster_order_name: "{{ cluster_order.metadata.name }}"
- name: Set lock holder identity
ansible.builtin.set_fact:
cluster_order_holder_id: >-
{{ cluster_order_name }}-{{ awx_job_id | default("unknown") }}-{{
lookup('community.general.random_string', special=false, numbers=false, upper=false)
}}
- name: Cluster order before defaults
ansible.builtin.debug:
var: cluster_order
- name: Apply default settings
ansible.builtin.include_role:
name: osac.service.cluster_settings
- name: Cluster order after defaults
ansible.builtin.debug:
var: cluster_order
- name: Extract template info
ansible.builtin.include_role:
name: osac.service.extract_template_info
- name: Determine working namespace
ansible.builtin.include_role:
name: osac.service.cluster_working_namespace
vars:
cluster_working_namespace_cluster_order_name: "{{ cluster_order_name }}"
tasks:
- name: Acquire cluster lock
ansible.builtin.include_role:
name: osac.service.lease
vars:
lease_state: present
lease_holder: "{{ cluster_order_holder_id }}"
lease_name: "cluster-{{ cluster_order_name }}-lock"
- name: Add infrastructure finalizer
ansible.builtin.include_role:
name: osac.service.finalizer
vars:
finalizer_state: present
finalizer_name: "{{ cluster_order_infrastructure_finalizer }}"
finalizer_target:
api_version: "{{ item.api_version }}"
kind: "{{ item.kind }}"
namespace: "{{ item.namespace | default(omit) }}"
name: "{{ item.name }}"
loop:
- api_version: osac.openshift.io/v1alpha1
kind: ClusterOrder
namespace: "{{ lookup('env', 'POD_NAMESPACE') }}"
name: "{{ cluster_order.metadata.name }}"
- api_version: v1
kind: Namespace
name: "{{ cluster_working_namespace }}"
- name: Display cluster order information
ansible.builtin.debug:
msg:
- "Cluster order: {{ cluster_order.metadata.name }}"
- "Cluster working namespace: {{ cluster_working_namespace }}"
- "Template ID: {{ template_id }}"
- name: Call the selected template
ansible.builtin.include_role:
name: "{{ template_id }}"
tasks_from: "install"