Skip to content

Commit

Permalink
Set default version to 4.15; add feature to install olm via rpm
Browse files Browse the repository at this point in the history
This commit provides few features related to that project:
- added workaround when the version file does not exists,
  so clean setup of the MicroShift  4.15 was not possible
- added a feature to setup the OLM via MicroShift RPM package [1]

[1] https://access.redhat.com/documentation/en-us/red_hat_build_of_microshift/4.15/html-single/installing/index#microshift-adding-olm-to-blueprint_microshift-embed-in-rpm-ostree
  • Loading branch information
danpawlik committed Jun 18, 2024
1 parent 0de2566 commit f5542c5
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 24 deletions.
11 changes: 7 additions & 4 deletions defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ firewalld_rules_permament: true
use_copr_microshift: false

# The Microshift version that is available in the repository.
microshift_version: 4.14
microshift_version: 4.15

# Default settings from /etc/microshift/config.yaml.default
# https://github.com/openshift/microshift/blob/release-4.14/packaging/microshift/config.yaml
# https://github.com/openshift/microshift/blob/release-4.15/packaging/microshift/config.yaml
microshift_config:
apiServer:
subjectAltNames:
Expand Down Expand Up @@ -72,7 +72,7 @@ microshift_config:
# nodeIP: ""

# Default settings from /etc/microshift/lvmd.yaml.default
# https://github.com/openshift/microshift/blob/release-4.14/packaging/microshift/lvmd.yaml
# https://github.com/openshift/microshift/blob/release-4.15/packaging/microshift/lvmd.yaml
microshift_lmvd:
# socket-name: /run/lvmd/lvmd.socket
device-classes:
Expand All @@ -86,7 +86,7 @@ microshift_lmvd:
# - ""

# Default settings from /etc/microshift/ovn.yaml.default
# https://github.com/openshift/microshift/blob/release-4.14/packaging/microshift/ovn.yaml
# https://github.com/openshift/microshift/blob/release-4.15/packaging/microshift/ovn.yaml
microshift_ovn: {}
# mtu: 1500

Expand All @@ -96,7 +96,10 @@ microshift_ovn: {}

# Install the OLM - https://olm.operatorframework.io/
setup_olm: false
# Install the OLM via microshift-olm rpm package.
microshift_olm_package: false
# https://github.com/operator-framework/operator-lifecycle-manager/releases
# NOTE: the olm_version is not working when microshift_olm_package is set to true.
olm_version: "v0.28.0"

# Version of the Operator SDK
Expand Down
14 changes: 14 additions & 0 deletions tasks/microshift.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@
notify: Restart Microshift
when: not use_copr_microshift

- name: Check if version file exists
become: true
ansible.builtin.stat:
path: /var/lib/microshift/version
register: _microshift_version_file

- name: "Create a version file if does not exists with version {{ microshift_version }}.0"
become: true
when: not _microshift_version_file.stat.exists
ansible.builtin.copy:
content: |
{{ microshift_version }}.0
dest: /var/lib/microshift/version

- name: Change Microshift configuration files
become: true
ansible.builtin.copy:
Expand Down
57 changes: 37 additions & 20 deletions tasks/olm.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
---
- name: Fetch operator-sdk
become: true
ansible.builtin.uri:
url: https://github.com/operator-framework/operator-sdk/releases/download/{{ operator_sdk_version }}/operator-sdk_linux_amd64
dest: /usr/local/bin/operator-sdk
mode: "755"
status_code:
- 200
- 304
- name: Install OLM via rpm package
when: microshift_olm_package
block:
- name: Install OLM rpm
become: true
ansible.builtin.yum:
name: microshift-olm
state: present
enablerepo: microshift-rpms,microshift-deps-rpms
notify: Restart Microshift

- name: Check if OLM is installed
ansible.builtin.command: /usr/local/bin/operator-sdk olm status
register: olm_status
failed_when: olm_status.rc not in [0, 1]
changed_when: true
- name: Flush handlers
ansible.builtin.meta: flush_handlers

- name: Install OLM via OperatorSDK
when: not microshift_olm_package
block:
- name: Fetch operator-sdk
become: true
ansible.builtin.uri:
url: https://github.com/operator-framework/operator-sdk/releases/download/{{ operator_sdk_version }}/operator-sdk_linux_amd64
dest: /usr/local/bin/operator-sdk
mode: "755"
status_code:
- 200
- 304

- name: Check if OLM is installed
ansible.builtin.command: /usr/local/bin/operator-sdk olm status
register: olm_status
failed_when: olm_status.rc not in [0, 1]
changed_when: true

- name: Install OLM with SDK
ansible.builtin.command: |
/usr/local/bin/operator-sdk olm install --version {{ olm_version }}
when: olm_status.rc != 0
changed_when: true

# Set ns/user to SCC before we run the OLM installation
- name: Ensure privileged SCC for OLM
Expand All @@ -24,9 +47,3 @@
- "default"
- "operatorhubio-catalog"
- "olm-operator-serviceaccount"

- name: Install OLM with SDK
ansible.builtin.command: |
/usr/local/bin/operator-sdk olm install --version {{ olm_version }}
when: olm_status.rc != 0
changed_when: true

0 comments on commit f5542c5

Please sign in to comment.