-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.yaml
More file actions
132 lines (119 loc) · 4.53 KB
/
install.yaml
File metadata and controls
132 lines (119 loc) · 4.53 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
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
---
- name: Install crc {{ crc_version }}
hosts: localhost
connection: local
vars_files: vars.yaml
pre_tasks:
- name: Get pull-secret file infos
ansible.builtin.stat:
path: "{{ crc_pull_secret_file }}"
register: pull_secret_file
- name: Test existence of pull-secret file
ansible.builtin.assert:
that: pull_secret_file.stat.exists
success_msg: Found configured pull-secret file
fail_msg: >-
The mandatory pull-secret file doesn't exist at '{{ crc_pull_secret_file }}'.
Read the "Requirements" section in README.md on how to create it.
- name: Test for semver compatibility
ansible.builtin.assert:
# Regex comes from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
that: crc_version is regex("^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$")
success_msg: crc_version is semver compatible
fail_msg: >-
The specified crc_version ('{{ crc_version }}') is not semver compatible.
See https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/crc/
for a list of valid and available versions (exluding bundles/ and latest/).
tasks:
- name: Install required packages
become: true
tags: prerequisites
ansible.builtin.apt:
cache_valid_time: 3600
name:
- qemu-kvm
- libvirt-daemon
- libvirt-daemon-system
- network-manager
- name: Add user to 'libvirt' group
tags: prerequisites
become: true
ansible.builtin.user:
name: "{{ ansible_env.USER }}"
append: true
groups:
- libvirt
- name: Download crc {{ crc_version }}
tags: download
become: true
ansible.builtin.unarchive:
src: "https://developers.redhat.com/content-gateway/file/pub/openshift-v4/clients/crc/{{ crc_version }}/crc-linux-amd64.tar.xz"
remote_src: true
dest: /tmp
mode: "0755"
owner: "{{ ansible_env.USER }}"
group: root
creates: "/tmp/crc-linux-{{ crc_version }}-amd64"
register: crc_download
until: crc_download is succeeded
retries: 5
delay: 3
- name: Make crc executable
tags: download
become: true
ansible.builtin.copy:
src: "/tmp/crc-linux-{{ crc_version }}-amd64/crc"
remote_src: true
dest: /usr/local/bin/crc
mode: "0755"
owner: "{{ ansible_env.USER }}"
group: root
- name: Enable cluster monitoring
when: crc_cluster_monitoring
tags: setup
ansible.builtin.command: sg libvirt -c "crc config set enable-cluster-monitoring true"
- name: Print timestamp
tags: setup
ansible.builtin.debug:
msg: "Entered 'Setup and start crc' at {{ ansible_date_time.iso8601 }} UTC."
- name: Setup and start crc (this can take up to 1h)
tags: setup
loop:
- crc setup
- crc config set kubeadmin-password kubeadmin
- crc config set pull-secret-file {{ crc_pull_secret_file }}
- crc config set cpus {{ crc_cluster_cpus }}
- crc config set memory {{ crc_cluster_memory }}
- crc start
ansible.builtin.command: sg libvirt -c "{{ item }}"
- name: Make oc executable
tags: test
become: true
ansible.builtin.copy:
src: "{{ ansible_env.HOME }}/.crc/bin/oc/oc"
remote_src: true
dest: /usr/local/bin/oc
owner: "{{ ansible_env.USER }}"
group: root
mode: "0755"
force: true
- name: Test oc login as developer
tags: test
ansible.builtin.command: >-
oc login -u developer -p developer
https://api.crc.testing:6443 --insecure-skip-tls-verify
- name: Test project and pod creation as developer
tags: test
ansible.builtin.shell: |
set -o pipefail
oc new-project developer | true
oc run alpine --command sleep 300 --image alpine:3.18.3
oc wait --for=condition=Ready --timeout 15m pod/alpine
oc delete pod/alpine --force
args:
executable: /bin/bash
- name: Print webconsole info
ansible.builtin.debug:
msg: >-
You can now login at https://console-openshift-console.apps-crc.testing
with 'developer:developer' or 'kubeadmin:kubeadmin' credentials.