-
Notifications
You must be signed in to change notification settings - Fork 39
/
15_bastion_workspace.yml
109 lines (97 loc) · 3.96 KB
/
15_bastion_workspace.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
---
- name: Creating a workspace on Bastion
hosts: bastion
vars_files:
- vars/cluster_vars.yml
tasks:
- name: Erasing dnsmasq lease
ansible.builtin.file:
path: /var/lib/dnsmasq/dnsmasq.leases
state: absent
become: true
- name: Creating workspace
ansible.builtin.file:
state: directory
path: "{{ item }}"
mode: "0755"
loop:
- "{{ workspace_directory.base_path }}/{{ cluster.name }}/{{ workspace_directory.config_dir }}"
- "~/.ssh"
- name: Creating ssh keys if it doens not exist
community.crypto.openssh_keypair:
path: "~/.ssh/id_rsa"
- name: Creating tftpboot and nginx workspace
ansible.builtin.file:
state: directory
path: "{{ item }}"
mode: "0755"
loop:
- "{{ tftp_boot_root }}/{{ tftp_workspace_dir }}"
- "{{ nginx_document_root }}/{{ nginx_workspace_dir }}"
become: true
- name: Downloading Openshift installer and CLI
ansible.builtin.unarchive:
src: "{{ item }}"
dest: /usr/bin
remote_src: true
become: true
loop:
- "{{ downloads.ocp.base_url }}/{{ cluster.version }}/openshift-client-linux-{{ cluster.version }}.tar.gz"
- "{{ downloads.ocp.base_url }}/{{ cluster.version }}/openshift-install-linux-{{ cluster.version }}.tar.gz"
when:
- not (skip_download | bool)
- cluster.version != "latest"
- cluster.version != "fast"
- cluster.version != "stable"
- cluster.version != "candidate"
- name: Downloading Openshift installer and CLI
ansible.builtin.unarchive:
src: "{{ item }}"
dest: /usr/bin
remote_src: true
become: true
loop:
- "{{ downloads.ocp.base_url }}/{{ cluster.version }}/openshift-client-linux.tar.gz"
- "{{ downloads.ocp.base_url }}/{{ cluster.version }}/openshift-install-linux.tar.gz"
when:
- not (skip_download | bool)
- cluster.version == "latest" or cluster.version == "fast" or cluster.version == "stable" or cluster.version == "candidate"
- name: Checking for openshift-install tool # noqa no-changed-when
ansible.builtin.command: openshift-install version
register: output
failed_when: output.rc != 0
- name: Checking for OCP cli tool # noqa no-changed-when
ansible.builtin.command: oc
register: output
failed_when: output.rc != 0
- name: Take care of retrieving packages for CoreOS
when: not (skip_download | bool)
become: true
block:
- name: Retrieve the minor version
ansible.builtin.set_fact:
version_check: "{{ cluster.version.split('.') }}"
when: cluster.version != "stable"
- name: Retrieve the minor version
ansible.builtin.set_fact:
version: "{{ (version_check.0 + '.' + version_check.1) | default('', true) }}"
when: version_check is defined
- name: Set fact for files
ansible.builtin.set_fact:
rhcos_kernel: "{{ downloads.rhcos.boot_files.kernel }}"
rhcos_initramfs: "{{ downloads.rhcos.boot_files.initramfs }}"
rhcos_os: "{{ downloads.rhcos.boot_files.rootfs }}"
rhcos_download_url: "{{ (downloads.rhcos.base_url + version + '/latest/') if cluster.version != 'stable' else (downloads.rhcos.base_url + 'latest/') }}" # noqa yaml[line-length]
- name: Download initramfs and kernel
ansible.builtin.get_url:
url: "{{ rhcos_download_url + item }}"
dest: "{{ tftp_boot_root }}/{{ tftp_workspace_dir }}/{{ item }}"
mode: "0755"
loop:
- "{{ rhcos_initramfs }}"
- "{{ rhcos_kernel }}"
- name: Download Red Hat CoreOS for bare metal
ansible.builtin.get_url:
url: "{{ rhcos_download_url + rhcos_os }}"
dest: "{{ nginx_document_root }}/{{ nginx_workspace_dir }}/{{ rhcos_os }}"
mode: "0755"