Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions 03-install_microshift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
# Copyright Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

- name: Load stack outputs and add hosts to inventory
hosts: localhost
gather_facts: false
tasks:
- name: Load stack output vars from file
ansible.builtin.include_vars:
file: "{{ hotstack_work_dir | default(playbook_dir) }}/{{ stack_name }}-outputs.yaml"
name: stack_outputs

- name: Add controller-0 to the Ansible inventory
ansible.builtin.add_host: "{{ stack_outputs.controller_ansible_host }}"

- name: Add microshift-0 to the Ansible inventory
ansible.builtin.add_host: "{{ stack_outputs.microshift_ansible_host }}"

- name: Store stack outputs for next play
ansible.builtin.set_fact:
stack_outputs: "{{ stack_outputs }}"
cacheable: true

- name: Install MicroShift
hosts: microshifts,controllers
gather_facts: true
strategy: linear
any_errors_fatal: true
roles:
- role: microshift_installer
vars:
microshift_config: "{{ hostvars['localhost']['stack_outputs']['microshift_config'] }}"
microshift_nmstate_config: "{{ hostvars['localhost']['stack_outputs']['microshift_nmstate_config'] }}"
30 changes: 30 additions & 0 deletions bootstrap_microshift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
# Copyright Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

- name: Bootstrap virtual infrastructure on Openstack cloud
ansible.builtin.import_playbook: 01-infra.yml

- name: Bootstrap controller node
ansible.builtin.import_playbook: 02-bootstrap_controller.yml

- name: Install MicroShift
ansible.builtin.import_playbook: 03-install_microshift.yml

# - name: Deploy RedFish Virtual BMC
# ansible.builtin.import_playbook: 04-redfish_virtual_bmc.yml

# - name: Deploy RHOSO
# ansible.builtin.import_playbook: 05_deploy_rhoso.yml
167 changes: 167 additions & 0 deletions roles/microshift_installer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# MicroShift Installer Role

This Ansible role installs and configures MicroShift on RHEL 9 systems.
It handles subscription management, package installation, network
configuration using nmstate, and initial cluster bootstrapping.

## Requirements

- RHEL 9.x system
- Valid Red Hat subscription with access to MicroShift repositories
- Network connectivity to Red Hat repositories
- Sufficient system resources (4GB RAM, 2 CPUs minimum recommended)

## Role Variables

### Required Variables

```yaml
# Subscription Manager credentials
subscription_manager_org_id: "your-org-id"
subscription_manager_activation_key: "your-activation-key"

# MicroShift configuration from Heat stack output (raw YAML for /etc/microshift/config.yaml)
microshift_config:
dns:
baseDomain: openstack.lab
node:
hostnameOverride: microshift-0
nodeIP: 192.168.32.10

# nmstate network configuration from Heat stack output
microshift_nmstate_config:
interfaces: [] # nmstate interface configuration
```

### Optional Variables

```yaml
# MicroShift version (default: "4.18")
microshift_installer_version: "4.18"

# Service configuration
microshift_installer_service_enable: true
microshift_installer_service_state: started

# Kubeconfig paths
microshift_installer_kubeconfig_path: "/var/lib/microshift/resources/kubeadmin/kubeconfig"

# Cluster ready timeout (seconds)
microshift_installer_wait_timeout: 600

# Packages to install on MicroShift node
microshift_installer_packages:
- microshift
- microshift-networking
- microshift-selinux
- nmstate
- containernetworking-plugins
```

## Dependencies

This role has no external dependencies beyond the built-in Ansible modules.

## Example Playbook

```yaml
- hosts: microshift_hosts
vars:
subscription_manager_org_id: "{{ lookup('env', 'RH_ORG_ID') }}"
subscription_manager_activation_key: "{{ lookup('env', 'RH_ACTIVATION_KEY') }}"
microshift_config: "{{ heat_stack_outputs.microshift_config }}"
microshift_nmstate_config: "{{ heat_stack_outputs.microshift_nmstate_config }}"
roles:
- microshift_installer
```

**Note**: The role handles privilege escalation internally using
`become: true` for tasks that require root access, so it's not
necessary to set `become: true` at the play level.

## Installation Process

The role performs the following steps on the MicroShift node:

1. **System Registration**: Registers the RHEL system with Red Hat
Subscription Manager using the provided organization ID and activation
key.

2. **Repository Enablement**: Enables the required repositories:
- `rhocp-<version>-for-rhel-9-x86_64-rpms`
- `fast-datapath-for-rhel-9-x86_64-rpms`

3. **Package Installation**: Installs MicroShift and dependencies:
- microshift
- microshift-networking
- microshift-selinux
- nmstate
- containernetworking-plugins

4. **Network Configuration**: Applies nmstate network configuration for:
- Physical interfaces
- VLAN interfaces
- Linux bridges
- IP addressing

5. **MicroShift Configuration**: Creates `/etc/microshift/config.yaml` with:
- Base domain
- Hostname override
- Node IP address

6. **Service Management**: Starts and enables the MicroShift service.

7. **Cluster Bootstrap**: Waits for the cluster to be ready and the
kubeconfig to be available.

The role also performs controller-specific tasks:

1. **OC Client Installation**: Downloads and installs the `oc` CLI on the
controller node.

2. **Kubeconfig Setup**: Fetches the kubeconfig from the MicroShift node
and sets it up on the controller at `~/.kube/config`.

## Network Configuration

The role uses nmstate to configure complex network topologies. The
`microshift_nmstate_config` should contain nmstate-compatible
configuration with interface definitions. This is typically generated from
the Heat stack output.

Example network configuration includes:

- Physical Ethernet interfaces
- VLAN-tagged interfaces for OpenStack networks
- Linux bridges for OVN and Ironic
- Static IP addressing

## MicroShift Cluster Access

After successful installation, the kubeconfig is available at:

- System location: `/var/lib/microshift/resources/kubeadmin/kubeconfig`
- User location: `~/.kube/config` (copied by the role)

Access the cluster:

```bash
export KUBECONFIG=~/.kube/config
oc get nodes
oc get pods -A
```

## Integration with Hotstack

This role is designed to be used with the Hotstack automation framework
as a replacement for `ocp_agent_installer` in MicroShift-based scenarios.
It expects the `microshift_config` variable to be populated from Heat
stack outputs.

## Troubleshooting

### Service Logs

```bash
journalctl -u microshift -f
```
53 changes: 53 additions & 0 deletions roles/microshift_installer/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
# Copyright Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

# Subscription Manager configuration
subscription_manager_org_id: ""
subscription_manager_activation_key: ""

# MicroShift configuration from heat stack output
microshift_config: {}

# MicroShift service configuration
microshift_installer_service_enable: true
microshift_installer_service_state: started

# Kubeconfig location on MicroShift node
microshift_installer_kubeconfig_path: "/var/lib/microshift/resources/kubeadmin/kubeconfig"

# Wait for cluster ready timeout (seconds)
microshift_installer_wait_timeout: 600

# Packages to install on MicroShift node
microshift_installer_packages:
- microshift
- microshift-networking
- microshift-selinux
- nmstate
- containernetworking-plugins

# MicroShift version for repository enablement and client download
microshift_installer_version: "4.18"

# OpenShift client download configuration (for controller)
microshift_installer_mirror_url: https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp
microshift_installer_client_url: "{{ microshift_installer_mirror_url }}/stable-{{ microshift_installer_version }}/openshift-client-linux.tar.gz"

# Controller paths
microshift_installer_base_dir: /home/zuul
microshift_installer_bin_dir: "{{ microshift_installer_base_dir }}/bin"
microshift_installer_kube_config_dir: "{{ microshift_installer_base_dir }}/.kube"
microshift_installer_download_dir: "{{ microshift_installer_base_dir }}/downloads"
33 changes: 33 additions & 0 deletions roles/microshift_installer/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
# Copyright Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

galaxy_info:
author: OpenStack K8s Operators
description: Install and configure MicroShift on RHEL 9
company: Red Hat
license: Apache-2.0
min_ansible_version: "2.9"
platforms:
- name: EL
versions:
- "9"
galaxy_tags:
- openshift
- microshift
- kubernetes
- edge

dependencies: []
Loading