-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_prerequisite_okd_infrastructure.yml
159 lines (159 loc) · 6.83 KB
/
install_prerequisite_okd_infrastructure.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
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
---
- name: Install prerequisite okd infrastructure
vars:
fedora_coreos_version: "31.20200406.20.0"
okd_version: "4.4.0-0.okd-2020-04-07-175212-beta2"
images_path: "/home/{{ ansible_user_id }}/.okd/images"
installer_path: "/home/{{ ansible_user_id }}/.okd"
fedora_coreos_cloud_image_name: "fedora-coreos-{{ fedora_coreos_version }}-qemu.x86_64.qcow2"
fedora_coreos_cloud_image_name_archive: "fedora-coreos-{{ fedora_coreos_version }}-qemu.x86_64.qcow2.xz"
fedora_coreos_cloud_image_name_archive_sha256: "4594182133375ce0cca180ef42506492da79adff79db655a4cc5fc94fb708f92"
vms_path: "/home/{{ ansible_user_id }}/.okd/vms"
ssh_public_key: "/home/{{ ansible_user_id }}/.ssh/id_rsa.pub"
domain_crt: "{{ installer_path }}/domain.crt"
pull_secret: "/home/damien/Téléchargements/pull-secret" # FIXME
block:
- name: Delete previous installation
include: uninstall_prerequisite_okd_infrastructure.yml
- name: Update / Install needed package for qemu following fail to use fw_cfg https://www.spinics.net/lists/centos/msg166715.html
yum:
name: "{{ packages }}"
vars:
packages:
- centos-release-qemu-ev
- qemu-kvm-ev
- python3
- name: Download okd client
get_url:
url: https://github.com/openshift/okd/releases/download/{{ okd_version }}/openshift-client-linux-{{ okd_version }}.tar.gz
dest: "{{ installer_path }}"
- name: Extract okd client
unarchive:
src: "{{ installer_path }}/openshift-client-linux-{{ okd_version }}.tar.gz"
dest: "{{ installer_path }}"
- name: Copy kubectl and oc to /usr/bin
copy:
src: "{{ installer_path }}/{{ item }}"
dest: "/usr/bin/{{ item }}"
with_items:
["kubectl","oc"]
become: true
become_user: root
mode: u+rwx,g+rwx,o+rwx
- name: Add KUBECONFIG environment variable to avoid referencing it using --kubeconfig= when doing oc command
lineinfile:
path: "/home/{{ ansible_user_id }}/.bashrc"
insertafter: EOF
line: "export KUBECONFIG=/home/{{ ansible_user_id }}/.okd/auth/kubeconfig"
backup: yes
- name: Download okd installer
get_url:
url: https://github.com/openshift/okd/releases/download/{{ okd_version }}/openshift-install-linux-{{ okd_version }}.tar.gz
dest: "{{ installer_path }}"
- name: Extract okd installer
unarchive:
src: "{{ installer_path }}/openshift-install-linux-{{ okd_version }}.tar.gz"
dest: "{{ installer_path }}"
- name: Check if fedora coreos cloud image is present
stat:
path: "{{ images_path }}/{{ fedora_coreos_cloud_image_name }}"
register: fedora_coreos_cloud_image
- name: Download fedora coreos cloud image
become: no
get_url:
url: "https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/{{ fedora_coreos_version }}/x86_64/{{ fedora_coreos_cloud_image_name_archive }}"
dest: "{{ images_path }}"
sha256sum: "{{ fedora_coreos_cloud_image_name_archive_sha256 }}"
when: fedora_coreos_cloud_image.stat.exists == False
- name: Unarchive fedora cloud image
shell:
cmd: xz -v -d {{ images_path }}/{{ fedora_coreos_cloud_image_name_archive }}
when: fedora_coreos_cloud_image.stat.exists == False
- name: |
Create install-config.yaml
Documentation can be found here: https://github.com/openshift/installer/blob/master/docs/user/customization.md
copy:
dest: "{{ installer_path }}/{{ item }}"
content: |
---
apiVersion: v1
baseDomain: okd.local
compute:
- hyperthreading: Enabled
name: worker
platform: {}
replicas: 0
controlPlane:
hyperthreading: Enabled
name: master
platform: {}
replicas: 3
metadata:
creationTimestamp: null
name: sandbox
networking:
clusterNetwork:
- cidr: 10.128.0.0/14
hostPrefix: 23
networkType: OpenShiftSDN
serviceNetwork:
- 172.30.0.0/16
platform:
none: {}
pullSecret: '{{ lookup('file', pull_secret) }}'
sshKey: '{{ lookup('file', ssh_public_key) }}'
additionalTrustBundle: |
{{ lookup('file', domain_crt) | indent(width=2, indentfirst=False) }}
imageContentSources:
- mirrors:
- container-registry.sandbox.okd.local/openshift
source: quay.io/openshift
with_items:
["install-config.yaml","install-config.yaml.bak"]
- name: Create manifests
shell:
cmd: "{{ installer_path }}/openshift-install create manifests --dir {{ installer_path }}"
args:
executable: /bin/bash
- name: Disable master schedulable
lineinfile:
path: "{{ installer_path }}/manifests/cluster-scheduler-02-config.yml"
regexp: " mastersSchedulable"
line: " mastersSchedulable: false"
- name: Create ignition configs files
shell:
cmd: "{{ installer_path }}/openshift-install create ignition-configs --dir {{ installer_path }}"
args:
executable: /bin/bash
- name: Update ignitions file to add users
block:
- name: Define additional configuration fcc file to inject
copy:
dest: "{{ installer_path }}/additional_configurations.fcc"
content: |
variant: fcos
version: 1.0.0
passwd:
users:
- name: {{ ansible_user_id }}
ssh_authorized_keys:
- "{{ lookup('file', ssh_public_key) }}"
groups: [ sudo, docker ]
- name: Generate additional configuration ignition file
shell: "/bin/podman run -i --rm quay.io/coreos/fcct:release --pretty --strict < {{ installer_path }}/additional_configurations.fcc > {{ installer_path }}/additional_configurations.ign"
- name: Create backup before updating them using additional configuration
copy:
src: "{{ installer_path }}/{{ item }}"
dest: "{{ installer_path }}/{{ item }}.original"
with_items:
["bootstrap.ign","worker.ign","master.ign"]
- name: Update ignition file to add configuration from additional_configurations.ign (which is a json file)
shell: "./run_update_ignition.py --ign-created-file='{{ installer_path }}/{{ item }}' --additional-configuration-file='{{ installer_path }}/additional_configurations.ign'"
with_items:
["bootstrap.ign","worker.ign","master.ign"]
- name: Copy ignitions files to be accessible to KVM virtual machines
copy:
src: "{{ installer_path }}/{{ item }}"
dest: "/tmp/{{ item }}"
with_items:
["bootstrap.ign","worker.ign","master.ign"]