Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for root_device_hints #553

Merged
merged 3 commits into from
Feb 11, 2025
Merged
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
45 changes: 43 additions & 2 deletions roles/generate_manifests/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
# generate_manifests
# generate_manifests role

Generates the manifests required for openshift_installer's agent sub-command
Generates the manifests required for openshift_installer's agent sub-command

## Variables

All of the variables have sane defaults which you can override to force things, but you shouldn't need to

| Variable | Default | Required | Description |
| ----------------------------- | --------------------------------- | --------- | --------------------- |
| generated_dir | $REPO_ROOT_PATH/generated | No | Base path for all generated files |
| manifests_dir | $GENERATED_DIR/$CLUSTER_NAME | No | Path to store all rendered manifests |
| cluster_manifest_dir | $MANIFESTS_DIR/cluster-manifests | No | Path for cluster manifests |
| extra_manifest_dir | $MANIFESTS_DIR/openshift | No | Path for extra manifests |
| static_network_config | {} | No | Static network config for every node |
| installation_disk_path | | No | Disk to use for install if you don't want the first found disk |
| root_device_hints | {} | No | Install device hints [^1] per node, in case installation_disk_path is not enough |
| use_local_mirror_registry | true | No | Use the configured mirror registry |
| mirror_registry | $REGISTRY_HOST_FQDN:5000 | No | Local container image mirror |
| ocp_registry_namespace | ocp4 | No | Namespace for image mirror |
| ocp_registry_image | openshift4 | No | Name for image in the image mirror |
| single_node_openshift_enabled | false | No | Install OCP in single-node mode |

## Usage Examples

```yaml
- name: "Generate manifests"
vars:
static_network_config: # if you want to specify static configuration
mynode-1:
mac_interface_map:
- logical_nic_name: enp0s0
mac_address: DE:AD:BE:EF:00:11
network_yaml:
# valid nmstate configuration in here
installation_disk_path: /dev/sdb # this maps to rootDeviceHints.deviceName
root_device_hints: # you can also use more specific device hints. This overrides installation_disk_path
hctl: 0:0:0:1
wwn: '0x5000000000' # remember to quote hex values
ansible.builtin.include_role:
name: redhatci.ocp.generate_manifests
```

[^1]: As per the [OCP 4.17 docs](https://docs.redhat.com/en/documentation/openshift_container_platform/4.17/html-single/installing_an_on-premise_cluster_with_the_agent-based_installer/index#root-device-hints_preparing-to-install-with-agent-based-installer)
1 change: 1 addition & 0 deletions roles/generate_manifests/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ cluster_manifest_dir: "{{ manifests_dir }}/cluster-manifests"
extra_manifest_dir: "{{ manifests_dir }}/openshift"
mac_interface_default_mapping: "interfaces[?(name != null && mac != null)].{logical_nic_name: name, mac_address: mac}"
static_network_config: {}
root_device_hints: {}
arch: x86_64
version_filter: "[?(openshift_version == '{{ openshift_version }}') && (cpu_architecture == '{{ arch }}')]"
release_image: "{{ (assisted_installer_release_images | json_query(version_filter))[0].url }}"
Expand Down
18 changes: 13 additions & 5 deletions roles/generate_manifests/templates/agent-config.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@ rendezvousIP: {{ hostvars[agent_based_installer_bootstrap_node][host_ip_keyword]
additionalNTPSources:
- {{ hostvars[agent_based_installer_bootstrap_node]['ntp_server'] }}
hosts:
{% for hostname, network_config in static_network_config.items() %}
{% for hostname in groups['masters'] + (groups['workers'] | default([])) | sort %}
tonyskapunk marked this conversation as resolved.
Show resolved Hide resolved
- role: {{ hostvars[hostname]['role'] }}
hostname: {{ hostname }}
{% if hostname in static_network_config %}
interfaces:
- name: {{ network_config.mac_interface_map[0].logical_nic_name }}
macAddress: {{ network_config.mac_interface_map[0].mac_address }}
- name: {{ static_network_config[hostname].mac_interface_map[0].logical_nic_name }}
macAddress: {{ static_network_config[hostname].mac_interface_map[0].mac_address }}
networkConfig:
nocturnalastro marked this conversation as resolved.
Show resolved Hide resolved
{{ network_config.network_yaml | indent(6) }}
{% if hostvars[hostname]['installation_disk_path'] is defined %}
{{ static_network_config[hostname].network_yaml | indent(6) }}
{% endif %}
{% if hostvars[hostname]['root_device_hints'] | default({}) | length > 0 or hostvars[hostname]['installation_disk_path'] is defined %}
rootDeviceHints:
{% if hostvars[hostname]['installation_disk_path'] is defined %}
deviceName: {{ hostvars[hostname]['installation_disk_path'] }}
{% else %}
{% for key, rdh in (hostvars[hostname]['root_device_hints'] | default({})).items() %}
{{ key }}: {{ rdh | to_yaml }}
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}