Skip to content

Commit 6a75aee

Browse files
danpawlikopenshift-merge-bot[bot]
authored andcommitted
[multiple] Add role for deploying devscript as SNO
The new role is simply - it just deploy SNO (Single Node OpenShift) without additional changes. That role might be useful for developers in daily usage, that might replace CRC deployment. Signed-off-by: Daniel Pawlik <dpawlik@redhat.com>
1 parent 00943b0 commit 6a75aee

16 files changed

Lines changed: 436 additions & 0 deletions

File tree

docs/dictionary/en-custom.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
ACL
12
AES
23
APIs
34
Amartya
@@ -18,6 +19,7 @@ LDAP
1819
LLM
1920
MachineConfig
2021
Marjanovic
22+
MiB
2123
Nemanja
2224
NICs
2325
NodeHealthCheck

roles/devscripts/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ networks.
5959
* `cifmw_devscripts_cpu_passthrough` (bool) Enable host-passthrough cpu model
6060
to virtual machine instead of using QEMU on nested environment. Defaults
6161
to `false`.
62+
* `cifmw_devscripts_sno` (bool) Enable Single Node OpenShift. Defaults to `false`.
6263

6364
### Secrets management
6465

roles/devscripts/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,4 @@ cifmw_devscripts_installer_timeout: 7200 # 2 hours
7575
cifmw_devscripts_etcd_slow_profile: true
7676
cifmw_devscripts_disable_console: false
7777
cifmw_devscripts_cpu_passthrough: false
78+
cifmw_devscripts_sno: false

roles/devscripts/templates/conf_ciuser.j2

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ set +x
77
export CI_TOKEN=$(cat {{ cifmw_devscripts_repo_dir }}/ci_token)
88
set -x
99

10+
11+
{% if cifmw_devscripts_sno %}
12+
# SNO configuration
13+
# https://github.com/openshift-metal3/dev-scripts/blob/master/AGENTS.md
14+
{% for item in ['working_dir', 'assets_extra_folder', 'openshift_release_type',
15+
'openshift_version', 'cluster_name', 'base_domain', 'ntp_servers',
16+
'external_subnet_v4', 'ip_stack', 'agent_e2e_test_scenario',
17+
'agent_platform_type'] %}
18+
export {{ item.upper() }}="{{ cifmw_devscripts_config[item] }}"
19+
{% endfor %}
20+
export NUM_MASTERS=1
21+
export NUM_WORKERS=0
22+
{% else %}
23+
1024
{% for item in cifmw_devscripts_config %}
1125
export {{ item.upper() }}="{{ cifmw_devscripts_config[item] }}"
1226
{% endfor %}
27+
28+
{% endif %}

roles/devscripts_sno/README.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# devscripts_sno
2+
3+
Deploy a Single Node OpenShift (SNO) cluster on libvirt/KVM using the
4+
[dev-scripts](https://github.com/openshift-metal3/dev-scripts) agent installer
5+
(`make agent`).
6+
7+
This role is a thin wrapper around the `devscripts` role: it prepares secrets
8+
and host prerequisites, runs the dev-scripts configuration and host-prep steps,
9+
executes `make agent`, and copies the resulting kubeconfig to `~/.kube/config`.
10+
11+
It complements the full `devscripts` deployment path (baremetal/libvirt with
12+
`make all`) and the physical bare metal path documented in
13+
[bm_sno](../bm_sno/README.md) (`cifmw_bm_sno: true`).
14+
15+
When used from the reproducer, set `cifmw_devscripts_sno: true` so the
16+
`devscripts` configuration template exports SNO-specific variables (see
17+
[dev-scripts AGENTS.md](https://github.com/openshift-metal3/dev-scripts/blob/master/AGENTS.md)).
18+
That flag is separate from including this role by name; reproducer scenarios
19+
such as `scenarios/reproducers/va-hci-minimal-sno.yml` combine the flag with
20+
`cifmw_devscripts_config_overrides` for a one-master layout.
21+
22+
## Parameters
23+
24+
### Role-specific
25+
26+
| Parameter | Type | Default | Description |
27+
| --- | --- | --- | --- |
28+
| `cifmw_devscripts_sno_installer_timeout` | int | `7200` | Seconds before `make agent` is killed by `timeout` (2 hours) |
29+
| `cifmw_devscripts_sno_repo_dir` | str | `~/src/github.com/openshift-metal3/dev-scripts` | Path to the dev-scripts repository |
30+
| `cifmw_devscripts_sno_data_dir` | str | `~/ci-framework-data` | Base directory for CI Framework data on the host |
31+
| `cifmw_devscripts_sno_artifacts_dir` | str | `{{ cifmw_devscripts_sno_data_dir }}/artifacts` | Directory for role script artifacts and logs |
32+
33+
### Required for standalone use
34+
35+
When running this role outside the reproducer playbook, provide secret content
36+
(the role writes files from these variables in `pre.yml`):
37+
38+
| Parameter | Description |
39+
| --- | --- |
40+
| `cifmw_manage_secrets_citoken_content` | CI token string written to `cifmw_manage_secrets_citoken_file` |
41+
| `cifmw_manage_secrets_pullsecret_content` | Pull secret JSON written to `cifmw_manage_secrets_pullsecret_file` |
42+
43+
Default secret file paths (from `defaults/main.yml`):
44+
45+
| Parameter | Default |
46+
| --- | --- |
47+
| `cifmw_manage_secrets_citoken_file` | `{{ ansible_user_dir }}/secrets/ci_token` |
48+
| `cifmw_manage_secrets_pullsecret_file` | `{{ ansible_user_dir }}/secrets/pull_secret.json` |
49+
50+
Alternatively, use the file-based variables documented in the
51+
[devscripts role README](../devscripts/README.md#secrets-management) if you
52+
integrate with `manage_secrets` directly.
53+
54+
### SNO and dev-scripts configuration
55+
56+
Set `cifmw_devscripts_sno: true` so `conf_ciuser.j2` exports the reduced SNO
57+
variable set (`NUM_MASTERS=1`, `NUM_WORKERS=0`, and agent-related keys).
58+
59+
Cluster version, networking, and VM sizing are controlled through
60+
`cifmw_devscripts_config_overrides` (and optional
61+
`cifmw_devscripts_config_overrides_patch.*` keys), same as the `devscripts`
62+
role. See [devscripts README](../devscripts/README.md#parameters) and
63+
[Supported keys in cifmw_devscripts_config_overrides](../devscripts/README.md#supported-keys-in-cifmw_devscripts_config_overrides).
64+
65+
Common SNO overrides (also used in `scenarios/reproducers/va-hci-minimal-sno.yml`):
66+
67+
| Key | Example | Description |
68+
| --- | --- | --- |
69+
| `num_masters` | `1` | Single control-plane node |
70+
| `master_memory` | `16384` | Memory (MiB) for the master VM |
71+
| `master_disk` | `120` | Root disk size (GiB) |
72+
| `master_vcpu` | `12` | vCPUs for the master VM |
73+
| `agent_e2e_test_scenario` | `SNO_IPV4` | Agent installer test scenario |
74+
| `agent_platform_type` | `none` | Agent platform type |
75+
| `openshift_version` | `stable-4.18` | OpenShift version (minor or `stable-X.Y`) |
76+
| `openshift_release_type` | `ga` | Release type (`nightly`, `ga`, `okd`) |
77+
| `external_subnet_v4` | `192.168.111.0/24` | External network for the cluster |
78+
| `ip_stack` | `v4` | IP stack (`v4`, `v6`, `v6v4`) |
79+
80+
Additional dev-scripts variables (for example `cifmw_devscripts_cpu_passthrough`,
81+
`cifmw_devscripts_host_bm_net_ip_addr`) follow the `devscripts` role
82+
documentation.
83+
84+
## Task files
85+
86+
| Task file | Description |
87+
| --- | --- |
88+
| `main.yml` | Orchestrates pre, QEMU ACL, setup, and post phases |
89+
| `pre.yml` | Maps role vars to `devscripts`, writes secrets, installs packages |
90+
| `prepare_qemu_home_access.yml` | Installs `acl`/`qemu-kvm` and grants `qemu` traverse on the user home |
91+
| `setup.yml` | Runs `devscripts` `build_config.yml` and `100_pre.yml`, then `make agent` |
92+
| `post.yml` | Copies cluster kubeconfig to `~/.kube/config` |
93+
94+
## Examples
95+
96+
### Standalone playbook
97+
98+
See `example-playbook.yaml` in this role directory:
99+
100+
```bash
101+
ansible-playbook \
102+
-e @secrets.yaml \
103+
-e @scenarios/reproducers/va-hci-minimal-sno.yml \
104+
-i inventory.yaml \
105+
roles/devscripts_sno/example-playbook.yaml
106+
```
107+
108+
Minimal `secrets.yaml` for standalone runs:
109+
110+
```yaml
111+
cifmw_devscripts_sno: true
112+
cifmw_manage_secrets_citoken_content: "{{ lookup('env', 'CI_TOKEN') }}"
113+
cifmw_manage_secrets_pullsecret_content: |
114+
{{ lookup('file', lookup('env', 'HOME') ~ '/pull-secret') }}
115+
116+
cifmw_devscripts_config_overrides:
117+
openshift_version: "stable-4.18"
118+
openshift_release_type: ga
119+
num_masters: 1
120+
master_memory: 16384
121+
master_disk: 120
122+
master_vcpu: 12
123+
external_subnet_v4: 192.168.111.0/24
124+
ip_stack: v4
125+
agent_e2e_test_scenario: SNO_IPV4
126+
agent_platform_type: none
127+
```
128+
129+
### Reproducer scenario (libvirt SNO)
130+
131+
From `scenarios/reproducers/va-hci-minimal-sno.yml`:
132+
133+
```yaml
134+
cifmw_devscripts_sno: true
135+
cifmw_reproducer_allow_one_ocp: true
136+
cifmw_devscripts_cpu_passthrough: true
137+
cifmw_devscripts_host_bm_net_ip_addr: "192.168.111.1"
138+
139+
cifmw_devscripts_config_overrides:
140+
num_masters: 1
141+
master_memory: 16384
142+
master_disk: 120
143+
master_vcpu: 12
144+
external_subnet_v4: 192.168.111.0/24
145+
ip_stack: v4
146+
agent_e2e_test_scenario: SNO_IPV4
147+
agent_platform_type: none
148+
openshift_release_type: ga
149+
openshift_version: stable-4.18
150+
```
151+
152+
After deployment, credentials are under the dev-scripts auth directory:
153+
154+
```bash
155+
export KUBECONFIG=~/src/github.com/openshift-metal3/dev-scripts/ocp/ocp/auth/kubeconfig
156+
oc login -u kubeadmin \
157+
-p "$(cat ~/src/github.com/openshift-metal3/dev-scripts/ocp/ocp/auth/kubeadmin-password)"
158+
```
159+
160+
## SNO deployment methods in CI Framework
161+
162+
| Flag | Role / method | Environment |
163+
| --- | --- | --- |
164+
| `cifmw_devscripts_sno: true` | dev-scripts agent (`make agent`) on libvirt/KVM | Virtual machine on the hypervisor |
165+
| `cifmw_bm_sno: true` | `bm_sno` (agent-based, iDRAC Redfish) | Physical bare metal host |
166+
167+
See [reproducer README](../reproducer/README.md#sno-deployment-methods) for how
168+
these paths fit into full reproducer jobs.
169+
170+
## References
171+
172+
* [devscripts role](../devscripts/README.md)
173+
* [bm_sno role](../bm_sno/README.md)
174+
* [dev-scripts](https://github.com/openshift-metal3/dev-scripts)
175+
* [dev-scripts agent installer](https://github.com/openshift-metal3/dev-scripts/tree/master/agent)
176+
* [dev-scripts AGENTS.md](https://github.com/openshift-metal3/dev-scripts/blob/master/AGENTS.md)
177+
* [dev-scripts config_example.sh](https://github.com/openshift-metal3/dev-scripts/blob/master/config_example.sh)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
18+
# All variables intended for modification should be placed in this file.
19+
# All variables within this role should have a prefix of "cifmw_devscripts_sno"
20+
#
21+
cifmw_manage_secrets_citoken_file: "{{ ansible_user_dir }}/secrets/ci_token"
22+
cifmw_manage_secrets_pullsecret_file: "{{ ansible_user_dir }}/secrets/pull_secret.json"
23+
openshift_version: "4.18.41"
24+
25+
cifmw_devscripts_sno_installer_timeout: 7200
26+
cifmw_devscripts_sno_repo_dir: "{{ ansible_user_dir }}/src/github.com/openshift-metal3/dev-scripts"
27+
cifmw_devscripts_sno_data_dir: "{{ ansible_user_dir }}/ci-framework-data"
28+
cifmw_devscripts_sno_artifacts_dir: "{{ cifmw_devscripts_sno_data_dir }}/artifacts"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
# Example usage:
3+
# ansible-playbook \
4+
# -e @secrets.yaml -e @scenarios/reproducers/va-hci-minimal-sno.yml \
5+
# -i inventory.yaml \
6+
# example-playbook.yaml
7+
- name: Deploying SNO host
8+
hosts: sno.dev
9+
gather_facts: true
10+
tasks:
11+
- name: Run devscript sno
12+
ansible.builtin.include_role:
13+
name: devscripts_sno

roles/devscripts_sno/meta/main.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
18+
galaxy_info:
19+
author: CI Framework
20+
description: CI Framework Role -- devscripts_sno
21+
company: Red Hat
22+
license: Apache-2.0
23+
min_ansible_version: "2.14"
24+
namespace: cifmw
25+
galaxy_tags:
26+
- cifmw
27+
28+
dependencies: []
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
18+
- name: Configure secrets and install required packages
19+
ansible.builtin.include_tasks: pre.yml
20+
21+
- name: Allow libvirt qemu user to access files under the user home directory
22+
ansible.builtin.include_role:
23+
name: libvirt_manager
24+
tasks_from: prepare_qemu_home_access.yml
25+
26+
- name: Configure devscripts and run make agent command
27+
ansible.builtin.include_tasks: setup.yml
28+
29+
- name: Make post actions
30+
ansible.builtin.include_tasks: post.yml
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
- name: Create .kube directory
3+
ansible.builtin.file:
4+
path: "{{ ansible_user_dir }}/.kube"
5+
state: directory
6+
mode: "0750"
7+
8+
- name: Copy devscripts kubeconfig to .kube
9+
ansible.builtin.copy:
10+
src: "{{ cifmw_devscripts_sno_repo_dir }}/ocp/ocp/auth/kubeconfig"
11+
dest: "{{ ansible_user_dir }}/.kube/config"
12+
remote_src: true
13+
mode: "0640"

0 commit comments

Comments
 (0)