Initial submission

This commit is contained in:
randal 2024-11-24 02:26:31 -07:00
commit 9336f7ba2b
4 changed files with 221 additions and 0 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# OKD Single Node Install
This repository contains an ansible playbook to create an ISO used to deploy a single node OpenShift (OKD) node.

144
generate-iso.yaml Normal file
View File

@ -0,0 +1,144 @@
---
- name: Generate custom ISO file for deploying OKD to baremetal
hosts: all
connection: local
gather_facts: no
vars:
#okdVersion: "4.15.0-0.okd-2024-03-10-010116"
okdVersion: "4.16.0-okd-scos.1"
tempDir: "/tmp/ocp-baremetal-iso-staging"
machineNetwork: "10.1.14.0/24"
baseDomain: "endofday.com"
clusterName: "snoballs"
sshKey: "ssh-rsa "
bootDisk: "/dev/sda"
#binariesBaseUrl: "https://github.com/okd-project/okd/releases/download"
binariesBaseUrl: "https://github.com/okd-project/okd-scos/releases/download"
#binariesBaseUrl: "https://cdn.endofday.com/okd-project/okd-scos/releases/download"
#scosBaseUrl: "https://cdn.endofday.com/okd-project"
scosBaseUrl: ""
useCustomButaneTemplates: false
tasks:
- name: Ensure staging directory exists
ansible.builtin.file:
path: "{{ tempDir }}/{{ clusterName }}"
state: directory
- name: Check if binaries exist
ansible.builtin.stat:
path: "{{ tempDir }}/{{ item }}"
register: binaries
with_items:
- "openshift-install"
- "oc"
- name: Download and extract binaries
when: >
(binaries.results | map(attribute='stat.exists') | select('equalto', false) | list | length) > 0
block:
- name: Download OKD Binaries
ansible.builtin.get_url:
url: "{{ binariesBaseUrl }}/{{ okdVersion }}/{{ item }}-{{ okdVersion }}.tar.gz"
dest: "{{ tempDir }}/{{ item }}-{{ okdVersion }}.tar.gz"
with_items:
- "openshift-client-linux"
- "openshift-install-linux"
- name: Extract openshift binaries
ansible.builtin.unarchive:
src: "{{ tempDir }}/{{ item }}-{{okdVersion}}.tar.gz"
dest: "{{ tempDir }}"
with_items:
- "openshift-client-linux"
- "openshift-install-linux"
- name: Ensure the extracted binaries are executable
ansible.builtin.file:
path: "{{ tempDir }}/{{ item }}"
state: file
mode: '0755'
with_items:
- kubectl
- oc
- openshift-install
- name: Remove binary tarballs
ansible.builtin.file:
path: "{{ tempDir }}/{{ item }}-{{okdVersion}}.tar.gz"
state: absent
with_items:
- "openshift-client-linux"
- "openshift-install-linux"
- name: Create install-config.yaml file
ansible.builtin.template:
src: "templates/install-config.yaml.j2"
dest: "{{ tempDir }}/{{ clusterName }}/install-config.yaml"
mode: "0644"
- name: Generate the install manifests (if butane is required)
when: useCustomButaneTemplates == true
block:
- name: Generate stock manifests
ansible.builtin.shell: |
set -o pipefail
{{ tempDir }}/openshift-install create manifests --dir={{ tempDir }}/{{ clusterName }}
register: generate_ignition_manifests
changed_when: false
- name: Create butane templates
ansible.builtin.template:
src: "{{ item }}"
dest: "{{ tempDir }}/{{ item | basename | regex_replace('\\.j2$', '') }}"
with_fileglob:
- templates/*.bu.j2
- name: Render butane template to OpenShift manifest
ansible.builtin.shell: |
set -o pipefail
butane {{ tempDir }}/{{ item|basename }} -o {{ tempDir }}/{{ clusterName }}/openshift/{{ item | basename | regex_replace('\\.bu', '.yaml') }}
with_fileglob:
- "{{ tempDir }}/*.bu"
register: render_butane_template
changed_when: false
- name: Generate ignition config for single node
ansible.builtin.shell: |
set -o pipefail
{{ tempDir }}/openshift-install create single-node-ignition-config --dir={{ tempDir }}/{{ clusterName }}
register: generate_ignition_file
- name: Check if ISO image exists
ansible.builtin.stat:
path: "{{ tempDir }}/os.iso"
register: iso
- name: Download CoreOS ISO
when: iso.stat.exists == false
block:
- name: Get CentOS Stream CoreOS ISO download location from openshift-installer
ansible.builtin.shell: |
set -o pipefail
{{ tempDir }}/openshift-install coreos print-stream-json | grep location | grep x86_64 | grep iso | cut -d\" -f4
register: scos_image_url
- name: Download ISO
ansible.builtin.get_url:
url: "{{ (scosBaseUrl | d('') != '') | ternary( scos_image_url.stdout | regex_replace( 'https://builds.coreos.fedoraproject.org/prod/streams/stable/builds', scosBaseUrl), scos_image_url.stdout) }}"
dest: "{{ tempDir }}/os.iso"
- name: Embed the ignition bootstrap into the iso image
become: true
ansible.builtin.shell: |
set -o pipefail
alias coreos-installer='sudo podman run --privileged --pull always --rm -v /dev:/dev -v /run/udev:/run/udev -v {{ tempDir }}:/data -w /data quay.io/coreos/coreos-installer:release'
coreos-installer iso ignition embed -fi {{ clusterName }}/bootstrap-in-place-for-live-iso.ign os.iso
register: embed_ignition_in_iso

View File

@ -0,0 +1,49 @@
variant: openshift
version: {{ okdVersion }}
metadata:
name: 98-var-partition
labels:
machineconfiguration.openshift.io/role: master
boot_device:
mirror:
devices:
- /dev/disk/by-id/disk-identifier0
- /dev/disk/by-id/disk-identifier1
storage:
disks:
- device: /dev/disk/by-id/disk-identifier2
wipe_table: true
partitions:
- label: var-0
- device: /dev/disk/by-id/disk-identifier3
wipe_table: true
partitions:
- label: var-1
- device: /dev/disk/by-id/disk-identifier4
wipe_table: true
partitions:
- label: var-2
- device: /dev/disk/by-id/disk-identifier5
wipe_table: true
partitions:
- label: var-3
- device: /dev/disk/by-id/disk-identifier6
wipe_table: true
partitions:
- label: var-4
raid:
- name: md-var
level: raid5
devices:
- /dev/disk/by-partlabel/var-0
- /dev/disk/by-partlabel/var-1
- /dev/disk/by-partlabel/var-2
- /dev/disk/by-partlabel/var-3
- /dev/disk/by-partlabel/var-4
filesystems:
- device: /dev/md/md-var
path: /var
format: xfs
mount_options: [defaults, prjquota]
wipe_filesystem: true
with_mount_unit: true

View File

@ -0,0 +1,25 @@
apiVersion: v1
baseDomain: "{{baseDomain}}"
compute:
- name: worker
replicas: 0
controlPlane:
name: master
replicas: 1
metadata:
name: "{{clusterName}}"
networking:
clusterNetwork:
- cidr: 10.128.0.0/14
hostPrefix: 23
machineNetwork:
- cidr: "{{machineNetwork}}"
networkType: OVNKubernetes
serviceNetwork:
- 172.30.0.0/16
platform:
none: {}
bootstrapInPlace:
installationDisk: "{{bootDisk}}"
pullSecret: '{"auths":{"fake":{"auth":"aWQ6cGFzcwo="}}}'
sshKey: "{{sshKey}}"