forked from agonzalezrh/install_openshift
-
Notifications
You must be signed in to change notification settings - Fork 2
/
sno_kubevirt.yaml
165 lines (148 loc) · 5.62 KB
/
sno_kubevirt.yaml
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
---
- hosts: localhost
gather_facts: false
become: false
vars_files:
- vars/config.yaml
vars_prompt:
- name: cluster_name
prompt: Specify cluster name
private: false
tasks:
- name: Destroy SNO cluster
when: action == "delete" or action == "destroy"
block:
- name: Delete the service (type LoadBalancer) for SNO
kubernetes.core.k8s:
state: absent
api_version: v1
kind: Service
namespace: "{{ ocp_namespace }}"
name: "{{ ocp_vmname_sno }}"
- name: Delete A dns record
amazon.aws.route53:
state: absent
zone: "{{ dns_zone }}"
record: "{{ item }}.{{ cluster_name}}.{{ cluster_domain }}"
type: A
loop:
- "api"
- "*.apps"
- name: Delete a SNO VM
kubevirt.core.kubevirt_vm:
name: "{{ ocp_vmname_sno }}"
namespace: "{{ namespace }}"
state: absent
- name: Remove Assisted Installer Cluster
agonzalezrh.install_openshift.delete_cluster:
cluster_id: "{{ cluster_id }}"
offline_token: "{{ offline_token }}"
- name: Create SNO cluster
when: action == "create"
block:
- name: Add the service (type LoadBalancer) for SNO
kubernetes.core.k8s:
definition: "{{ lookup('ansible.builtin.template', 'templates/sno_svc.yaml') }}"
wait: true
wait_timeout: 300
vars:
vmname: "{{ ocp_vmname_sno }}"
svcname: "{{ ocp_vmname_sno }}-svc"
namespace: "{{ ocp_namespace }}"
- name: Wait for the LoadBalancer value
register: sno_svc
kubernetes.core.k8s_info:
api_version: v1
kind: Service
name: "{{ ocp_vmname_sno }}-svc"
namespace: "{{ ocp_namespace }}"
until: sno_svc.resources[0].status.loadBalancer.ingress[0].ip | default('') != ''
retries: 10
delay: 6
- name: Add A dns record
amazon.aws.route53:
state: present
zone: "{{ dns_zone }}"
record: "{{ item }}.{{ cluster_name}}.{{ cluster_domain }}"
type: A
value: "{{ sno_svc.resources[0].status.loadBalancer.ingress[0].ip }}"
ttl: 30
overwrite: "{{ overwrite_dns }}"
loop:
- "api"
- "*.apps"
- name: Create Assisted Installer Cluster
agonzalezrh.install_openshift.create_cluster:
name: "{{ cluster_name }}"
openshift_version: "{{ cluster_version }}"
base_dns_domain: "{{ cluster_domain }}"
offline_token: "{{ offline_token }}"
pull_secret: "{{ pull_secret }}"
high_availability_mode: "None"
service_networks:
- cidr: "172.31.0.0/16"
register: newcluster
- name: Create Infrastructure environment
agonzalezrh.install_openshift.create_infra_env:
name: "{{ cluster_name }}-infra-env"
image_type: "{{ cluster_iso_type }}"
cluster_id: "{{ newcluster.result.id }}"
ssh_authorized_key: "{{ ssh_authorized_key }}"
offline_token: "{{ offline_token }}"
pull_secret: "{{ pull_secret }}"
register: newinfraenv
- name: Create a SNO VM
include_tasks: tasks/kubevirt/create_sno.yaml
vars:
image_url: "{{ newinfraenv.result.download_url }}"
vmname: "{{ ocp_vmname_sno }}"
namespace: "{{ ocp_namespace }}"
storageclass: "{{ storage_class }}"
- name: Wait for the hosts to be ready
agonzalezrh.install_openshift.wait_for_hosts:
cluster_id: "{{ newcluster.result.id }}"
offline_token: "{{ offline_token }}"
expected_hosts: 1
wait_timeout: 600
- name: Start cluster installation
agonzalezrh.install_openshift.install_cluster:
cluster_id: "{{ newcluster.result.id }}"
offline_token: "{{ offline_token }}"
wait_timeout: 1200
- name: Obtain OpenShift cluster credentials
register: credentials
agonzalezrh.install_openshift.get_credentials:
cluster_id: "{{ newcluster.result.id }}"
offline_token: "{{ offline_token }}"
- name: Display credentials
debug:
var: credentials.result
- name: Create directory for downloaded credential files
ansible.builtin.file:
state: directory
path: "{{ output_dir }}/{{ cluster_name }}"
recurse: true
- name: Downloads OpenShift cluster credentials
agonzalezrh.install_openshift.download_credentials:
cluster_id: "{{ newcluster.result.id }}"
offline_token: "{{ offline_token }}"
file_name: "{{ item }}"
dest: "{{ output_dir }}/{{ cluster_name }}/{{ item }}"
loop:
- kubeadmin-password
- kubeconfig
- kubeconfig-noingress
- name: Downloads OpenShift cluster files
agonzalezrh.install_openshift.download_files:
cluster_id: "{{ newcluster.result.id }}"
offline_token: "{{ offline_token }}"
file_name: "{{ item }}"
dest: "{{ output_dir }}/{{ cluster_name }}/{{ item }}"
loop:
- bootstrap.ign
- master.ign
- metadata.json
- worker.ign
- install-config.yaml
- custom_manifests.json
- custom_manifests.yaml