Updated cluster creation playbook

This commit is contained in:
2025-07-26 01:06:44 -05:00
parent 0f4d2dcb7c
commit 5612932691
30 changed files with 533 additions and 237 deletions

View File

@@ -1,13 +0,0 @@
---
- name: Dnsmasq
hosts: localhost
become: yes
vars:
- additional_dhcp_hosts:
ethernet_switch:
desc: "SNO Hub Cluster"
mac: 98:b7:85:1e:c6:f1
ip: 10.1.71.10
roles:
- role: ricsanfre.dnsmasq

View File

@@ -1,24 +0,0 @@
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/rework-space-com/freeipa" {
version = "5.0.0"
constraints = "5.0.0"
hashes = [
"h1:6EquDv6GgQO2HjZUUoRIUVzYa951n+wb4Uk7ggD6XD0=",
"zh:098607e559c3b696401034ff494ba8068962b45059ee067a54b58334b6ee0f2c",
"zh:18b806a14bb9d9382213c6929af35f5a65f16c17ff526d475f1eab33d1470290",
"zh:2c8c74668844d256b7fdc503cd736a20b7e58db5b31880d1ad8090c1af04e24c",
"zh:3bba458b9a6df99c21da58750dd6586b93bdcc557e4a2d695e801ada39e8de1e",
"zh:58f728d9e98cc7aae3841c07318be64b6dcb2f51c041f04bba977e61104a2333",
"zh:597dfbefbfe111a31e9ff3c4fc14fc8e12c1e255454087d3eebd2ec6c7aa9bf3",
"zh:6093d6db13d834c23f5482efae80c8e1ae046028fccf24242f0f1c1935e6aa70",
"zh:87271fa234a57ce05d4166e444002bd66976f971b434f7add45c874c9587129d",
"zh:89f7f6be64b6bf9e708fbafd22f410cf3f50b1fcd4cd6c61e9ffffd6180ea839",
"zh:9bdd7a984f845ff6f4bc4df5cc41a9de019639fceca62e60fc7c0f098ad2695c",
"zh:a0551311c96b86050d15854b4fca2beaa06b2e1964f97945824567d0b90db580",
"zh:c3daa12021725883bd32d7d852a2de845bb7a5f18009a45be7c2c2d891631713",
"zh:d7871eb99683934a30b9d47508379e6d16978f3dcd73601af2204652668592aa",
"zh:e8f72fd7750e6c1f0f97d039fea66cb85f457cf22908b7c3f14c7d2cf990ee84",
]
}

View File

@@ -1,3 +0,0 @@
# DNS Provider Configuration
This directory contains the configuration to updateFreeIPA DNS for the Hub Cluster.

View File

@@ -1,39 +0,0 @@
resource "freeipa_dns_record" "ocp-hub" {
zone_name = "int.mk-labs.cloud."
name = "ocp-hub"
type = "A"
records = [
"10.1.71.10",
]
ttl = 60
}
resource "freeipa_dns_record" "api" {
zone_name = "int.mk-labs.cloud."
name = "api.hub"
type = "A"
records = [
"10.1.71.10",
]
ttl = 60
}
resource "freeipa_dns_record" "api-int" {
zone_name = "int.mk-labs.cloud."
name = "api-int.hub"
type = "A"
records = [
"10.1.71.10",
]
ttl = 60
}
resource "freeipa_dns_record" "wildcard-apps" {
zone_name = "int.mk-labs.cloud."
name = "*.apps.hub"
type = "A"
records = [
"10.1.71.10",
]
ttl = 60
}

View File

@@ -1,22 +0,0 @@
# Configure the DNS Provider
provider "freeipa" {
host = "infra01.int.mk-labs.cloud"
username = "admin"
password = var.freeipa_password
insecure = true
}
variable "freeipa_password" {
description = "The password for the FreeIPA provider"
type = string
sensitive = true
}
terraform {
required_providers {
freeipa = {
source = "rework-space-com/freeipa"
version = "5.0.0"
}
}
}

View File

@@ -1 +0,0 @@
# Add/modify entry in DNSmasq

View File

@@ -1,28 +0,0 @@
---
- name: Ensure dnsmasq is installed
ansible.builtin.apt:
name: dnsmasq
state: present
become: true
when: ansible_os_family == "Debian"
- name: Ensure dnsmasq is installed
ansible.builtin.dnf:
name: dnsmasq
state: present
become: true
when: ansible_os_family == "RedHat"
- name: Add host reservation to dnsmasq
ansible.builtin.lineinfile:
path: /etc/dnsmasq.d/hosts.conf
regexp: "^dhcp-host={{ hostvars['ocp-hub'].mac_address }}"
line: "dhcp-host={{ hostvars['ocp-hub'].mac_address }},{{ hostvars['ocp-hub'].ip_address }} #{{ hostvars['ocp-hub'].hostname }}"
state: present
become: true
- name: Restart dnsmasq service
ansible.builtin.service:
name: dnsmasq
state: restarted
become: true

View File

@@ -1,8 +0,0 @@
// Matcher group for OCP Internal machines
resource "matchbox_group" "{{ hostvars[groups['hub_cluster'][0]].cluster_name }}" {
name = "{{ hostvars['ocp-hub'].hostname }}" # Physical Server
profile = matchbox_profile.openshift-agent-install.name
selector = {
mac = "{{ hostvars['ocp-hub'].mac_address }}" # PXE boots and installs to 10GbE NIC
}
}

View File

@@ -1,16 +0,0 @@
// Fedora CoreOS profile
resource "matchbox_profile" "openshift-agent-install" {
name = "{{ hostvars[groups['hub_cluster'][0]].cluster_name }}"
kernel = "/assets/{{ hostvars[groups['hub_cluster'][0]].cluster_name }}/agent.x86_64-vmlinuz"
initrd = [
"--name initrd /assets/{{ hostvars[groups['hub_cluster'][0]].cluster_name }}/agent.x86_64-initrd.img"
]
args = [
"initrd=initrd",
"coreos.live.rootfs_url={{ hostvars[groups['matchbox'][0]].http_endpoint }}/assets/{{ hostvars[groups['hub_cluster'][0]].cluster_name }}/agent.x86_64-rootfs.img",
"rw",
"ignition.firstboot",
"ignition.platform.id=metal",
]
}

View File

@@ -1,20 +0,0 @@
// Configure the matchbox provider
provider "matchbox" {
endpoint = "{{ hostvars[groups['matchbox'][0]].rpc_endpoint }}"
client_cert = file("/etc/matchbox/client.crt")
client_key = file("/etc/matchbox/client.key")
ca = file("/etc/matchbox/ca.crt")
}
terraform {
required_providers {
ct = {
source = "poseidon/ct"
version = "0.13.0"
}
matchbox = {
source = "poseidon/matchbox"
version = "0.5.4"
}
}
}

View File

@@ -5,58 +5,58 @@
gather_facts: true
tasks:
- name: Deploy DNS entries for cluster via Terraform
community.general.terraform:
project_path: 01-dns/
variables:
freeipa_password: "{{ vault_freeipa_password }}"
state: present
force_init: true
# - name: Deploy DNS entries for cluster via Terraform
# community.general.terraform:
# project_path: 01-dns/
# variables:
# freeipa_password: "{{ vault_freeipa_password }}"
# state: present
# force_init: true
- name: Deploy DHCP entries for cluster via Terraform
ansible.builtin.include_tasks:
file: 02-dhcp/ip-reservations.yml
# - name: Deploy DHCP entries for cluster via Terraform
# ansible.builtin.include_tasks:
# file: 02-dhcp/ip-reservations.yml
- name: OpenShift Installer install-config.yaml
ansible.builtin.template:
src: 03-openshift-image/templates/install-config.yaml.j2
dest: 03-openshift-image/install-config.yaml
mode: '0644'
# - name: OpenShift Installer install-config.yaml
# ansible.builtin.template:
# src: 03-openshift-image/templates/install-config.yaml.j2
# dest: 03-openshift-image/install-config.yaml
# mode: '0644'
- name: OpenShift Installer agent-config.yaml
ansible.builtin.template:
src: 03-openshift-image/templates/agent-config.yaml.j2
dest: 03-openshift-image/agent-config.yaml
mode: '0644'
# - name: OpenShift Installer agent-config.yaml
# ansible.builtin.template:
# src: 03-openshift-image/templates/agent-config.yaml.j2
# dest: 03-openshift-image/agent-config.yaml
# mode: '0644'
- name: Create OpenShift image
ansible.builtin.include_tasks:
file: 03-openshift-image/create-openshift-image.yml
# - name: Create OpenShift image
# ansible.builtin.include_tasks:
# file: 03-openshift-image/create-openshift-image.yml
- name: Move PXE assets to matchbox
ansible.builtin.include_tasks:
file: 03-openshift-image/move-pxe-assets.yml
# - name: Move PXE assets to matchbox
# ansible.builtin.include_tasks:
# file: 03-openshift-image/move-pxe-assets.yml
- name: Terraform matchbox groups file
ansible.builtin.template:
src: 04-matchbox/templates/groups.tf.j2
dest: 04-matchbox/groups.tf
mode: '0644'
# - name: Terraform matchbox groups file
# ansible.builtin.template:
# src: 04-matchbox/templates/groups.tf.j2
# dest: 04-matchbox/groups.tf
# mode: '0644'
- name: Terraform matchbox profiles file
ansible.builtin.template:
src: 04-matchbox/templates/profiles.tf.j2
dest: 04-matchbox/profiles.tf
mode: '0644'
# - name: Terraform matchbox profiles file
# ansible.builtin.template:
# src: 04-matchbox/templates/profiles.tf.j2
# dest: 04-matchbox/profiles.tf
# mode: '0644'
- name: Terraform matchbox provider file
ansible.builtin.template:
src: 04-matchbox/templates/provider.tf.j2
dest: 04-matchbox/provider.tf
mode: '0644'
# - name: Terraform matchbox provider file
# ansible.builtin.template:
# src: 04-matchbox/templates/provider.tf.j2
# dest: 04-matchbox/provider.tf
# mode: '0644'
- name: Configure Matchbox via Terraform
community.general.terraform:
project_path: 04-matchbox/
state: present
force_init: true
# - name: Configure Matchbox via Terraform
# community.general.terraform:
# project_path: 04-matchbox/
# state: present
# force_init: true