-
Notifications
You must be signed in to change notification settings - Fork 3
/
openshift4-installer.yaml
83 lines (68 loc) · 2.8 KB
/
openshift4-installer.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
---
- name: Install OpenShift 4 with CRC
hosts: all
tasks:
- include_tasks: ./crc-versions.yaml
- include_tasks: ./install-rpm-requirements.yaml
- name: Set variable crc_tar_name
set_fact:
crc_tar_name: "{{ ansible_env.HOME}}/crc-{{ arch_name }}-amd64.tar.xz"
- name: Set variable crc_dir_name
set_fact:
crc_dir_name: "{{ ansible_env.HOME }}/crc-{{ arch_name }}-{{ version }}-amd64"
- name: Check for presence pull-secret file
stat:
path: "{{ pull_secret }}"
register: pull_secret_exist
- fail:
msg: "'pull-secret' does not exists. Download it from https://cloud.redhat.com/openshift/install/metal/user-provisioned"
when: pull_secret_exist.stat.exists == false
- name: Check if the latest CRC software exists
stat:
path: '{{ crc_tar_name }}'
register: file_details
- name: Check if directory with CRC software exists.
stat:
path: '{{ crc_dir_name }}'
register: dir_details
- name: Get the latest CRC software
get_url:
url: 'https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/crc-{{ arch_name }}-amd64.tar.xz'
dest: '{{ crc_tar_name }}'
when: dir_details.stat.exists == false
- name: Check for presence ~/.crc directory
stat:
path: "{{ ansible_env.HOME }}/.crc"
register: crc_details
- name: Create ~/.crc directory
file:
path: "{{ ansible_env.HOME }}/.crc"
state: directory
when: crc_details.stat.exists == false
- name: Check for CRC Bundle presence
stat:
path: "{{ ansible_env.HOME }}/.crc/{{ crc_file_name.stdout }}"
register: crc_present
- name: Get VirtualBox CRC bundle
get_url:
url: "https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/{{ crc_file_name.stdout }}"
dest: "{{ ansible_env.HOME }}/.crc/"
when: crc_present.stat.exists == false
- name: Untar CRC code
unarchive:
src: '{{ crc_tar_name }}'
dest: '{{ ansible_env.HOME }}'
when: ansible_os_family == "RedHat" and dir_details.stat.exists == false
- name: Gunzip CRC code
command: "gunzip -v {{ ansible_env.HOME }}/crc-{{ arch_name }}-amd64.tar.xz"
when: ansible_os_family == "Darwin" and dir_details.stat.exists == false
- name: Untar CRC code
command: "tar -xvf {{ ansible_env.HOME }}/crc-{{ arch_name }}-amd64.tar -C {{ ansible_env.HOME }}"
when: ansible_os_family == "Darwin" and dir_details.stat.exists == false
- name: Delete CRC tar source
file:
state: absent
path: "{{ ansible_env.HOME }}/crc-{{ arch_name }}-amd64.tar"
when: dir_details.stat.exists == false
- name: CRC setup
command: "{{ ansible_env.HOME }}/crc-{{ arch_name }}-{{ version }}-amd64/crc setup"