Claude assisted cleanup
This commit is contained in:
@@ -63,50 +63,27 @@
|
||||
ssl_verify: "{{ opnsense_ssl_verify | default(false) }}"
|
||||
api_port: "{{ opnsense_api_port | default(omit) }}"
|
||||
|
||||
vars:
|
||||
__deploy_ocp_cluster_name: "{{ hostvars['sno.openshift.toal.ca']['ocp_cluster_name'] }}"
|
||||
__deploy_ocp_base_domain: "{{ hostvars['sno.openshift.toal.ca']['ocp_base_domain'] }}"
|
||||
__deploy_sno_ip: "{{ hostvars['sno.openshift.toal.ca']['sno_ip'] }}"
|
||||
|
||||
tags: opnsense
|
||||
|
||||
tasks:
|
||||
|
||||
- name: Add Unbound host override for OCP API
|
||||
oxlorg.opnsense.unbound_host:
|
||||
hostname: "api.{{ ocp_cluster_name }}"
|
||||
domain: "{{ ocp_base_domain }}"
|
||||
value: "{{ sno_ip }}"
|
||||
match_fields:
|
||||
- hostname
|
||||
- domain
|
||||
state: present
|
||||
delegate_to: localhost
|
||||
vars:
|
||||
ocp_cluster_name: "{{ hostvars['sno.openshift.toal.ca']['ocp_cluster_name'] }}"
|
||||
ocp_base_domain: "{{ hostvars['sno.openshift.toal.ca']['ocp_base_domain'] }}"
|
||||
sno_ip: "{{ hostvars['sno.openshift.toal.ca']['sno_ip'] }}"
|
||||
|
||||
- name: Add Unbound host override for OCP API internal
|
||||
oxlorg.opnsense.unbound_host:
|
||||
hostname: "api-int.{{ ocp_cluster_name }}"
|
||||
domain: "{{ ocp_base_domain }}"
|
||||
value: "{{ sno_ip }}"
|
||||
match_fields:
|
||||
- hostname
|
||||
- domain
|
||||
state: present
|
||||
delegate_to: localhost
|
||||
vars:
|
||||
ocp_cluster_name: "{{ hostvars['sno.openshift.toal.ca']['ocp_cluster_name'] }}"
|
||||
ocp_base_domain: "{{ hostvars['sno.openshift.toal.ca']['ocp_base_domain'] }}"
|
||||
sno_ip: "{{ hostvars['sno.openshift.toal.ca']['sno_ip'] }}"
|
||||
|
||||
- name: Forward apps wildcard domain to SNO ingress
|
||||
oxlorg.opnsense.unbound_forward:
|
||||
domain: "apps.{{ ocp_cluster_name }}.{{ ocp_base_domain }}"
|
||||
target: "{{ sno_ip }}"
|
||||
state: present
|
||||
delegate_to: localhost
|
||||
vars:
|
||||
ocp_cluster_name: "{{ hostvars['sno.openshift.toal.ca']['ocp_cluster_name'] }}"
|
||||
ocp_base_domain: "{{ hostvars['sno.openshift.toal.ca']['ocp_base_domain'] }}"
|
||||
sno_ip: "{{ hostvars['sno.openshift.toal.ca']['sno_ip'] }}"
|
||||
roles:
|
||||
- role: opnsense_dns_override
|
||||
opnsense_dns_override_entries:
|
||||
- hostname: "api.{{ __deploy_ocp_cluster_name }}"
|
||||
domain: "{{ __deploy_ocp_base_domain }}"
|
||||
value: "{{ __deploy_sno_ip }}"
|
||||
type: host
|
||||
- hostname: "api-int.{{ __deploy_ocp_cluster_name }}"
|
||||
domain: "{{ __deploy_ocp_base_domain }}"
|
||||
value: "{{ __deploy_sno_ip }}"
|
||||
type: host
|
||||
- domain: "apps.{{ __deploy_ocp_cluster_name }}.{{ __deploy_ocp_base_domain }}"
|
||||
value: "{{ __deploy_sno_ip }}"
|
||||
type: forward
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Play 3: Configure Public DNS Records in DNS Made Easy
|
||||
@@ -116,35 +93,26 @@
|
||||
gather_facts: false
|
||||
connection: local
|
||||
|
||||
vars:
|
||||
__deploy_public_ip: "{{ hostvars['gate.toal.ca']['haproxy_public_ip'] }}"
|
||||
|
||||
tags: dns
|
||||
|
||||
tasks:
|
||||
|
||||
- name: Create A record for OpenShift API endpoint
|
||||
community.general.dnsmadeeasy:
|
||||
account_key: "{{ dme_account_key }}"
|
||||
account_secret: "{{ dme_account_secret }}"
|
||||
domain: "{{ ocp_base_domain }}"
|
||||
record_name: "api.{{ ocp_cluster_name }}"
|
||||
record_type: A
|
||||
record_value: "{{ hostvars['gate.toal.ca']['haproxy_public_ip'] }}"
|
||||
record_ttl: "{{ ocp_dns_ttl }}"
|
||||
port: 443
|
||||
protocol: HTTPS
|
||||
state: present
|
||||
|
||||
- name: Create A record for OpenShift apps wildcard
|
||||
community.general.dnsmadeeasy:
|
||||
account_key: "{{ dme_account_key }}"
|
||||
account_secret: "{{ dme_account_secret }}"
|
||||
domain: "{{ ocp_base_domain }}"
|
||||
record_name: "*.apps.{{ ocp_cluster_name }}"
|
||||
record_type: A
|
||||
record_value: "{{ hostvars['gate.toal.ca']['haproxy_public_ip'] }}"
|
||||
record_ttl: "{{ ocp_dns_ttl }}"
|
||||
port: 443
|
||||
protocol: HTTPS
|
||||
state: present
|
||||
roles:
|
||||
- role: dnsmadeeasy_record
|
||||
dnsmadeeasy_record_account_key: "{{ dme_account_key }}"
|
||||
dnsmadeeasy_record_account_secret: "{{ dme_account_secret }}"
|
||||
dnsmadeeasy_record_entries:
|
||||
- domain: "{{ ocp_base_domain }}"
|
||||
record_name: "api.{{ ocp_cluster_name }}"
|
||||
record_type: A
|
||||
record_value: "{{ __deploy_public_ip }}"
|
||||
record_ttl: "{{ ocp_dns_ttl }}"
|
||||
- domain: "{{ ocp_base_domain }}"
|
||||
record_name: "*.apps.{{ ocp_cluster_name }}"
|
||||
record_type: A
|
||||
record_value: "{{ __deploy_public_ip }}"
|
||||
record_ttl: "{{ ocp_dns_ttl }}"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Play 4: Generate Agent ISO and deploy SNO (agent-based installer)
|
||||
@@ -184,18 +152,18 @@
|
||||
name: "{{ sno_vm_name }}"
|
||||
type: qemu
|
||||
config: current
|
||||
register: _sno_vm_info
|
||||
register: __sno_vm_info
|
||||
when: (sno_vm_id | default('')) == '' or (sno_mac | default('')) == ''
|
||||
|
||||
- name: Set sno_vm_id and sno_mac from live Proxmox query
|
||||
ansible.builtin.set_fact:
|
||||
sno_vm_id: "{{ _sno_vm_info.proxmox_vms[0].vmid }}"
|
||||
sno_vm_id: "{{ __sno_vm_info.proxmox_vms[0].vmid }}"
|
||||
sno_mac: >-
|
||||
{{ _sno_vm_info.proxmox_vms[0].config.net0
|
||||
{{ __sno_vm_info.proxmox_vms[0].config.net0
|
||||
| regex_search('([0-9A-Fa-f]{2}(?::[0-9A-Fa-f]{2}){5})', '\1')
|
||||
| first }}
|
||||
cacheable: true
|
||||
when: _sno_vm_info is not skipped
|
||||
when: __sno_vm_info is not skipped
|
||||
|
||||
- name: Ensure local install directories exist
|
||||
ansible.builtin.file:
|
||||
@@ -217,27 +185,27 @@
|
||||
path: "{{ proxmox_iso_dir }}/{{ sno_iso_filename }}"
|
||||
get_checksum: false
|
||||
delegate_to: proxmox_host
|
||||
register: proxmox_iso_stat
|
||||
register: __proxmox_iso_stat
|
||||
|
||||
- name: Check if local openshift-install state directory exists
|
||||
ansible.builtin.stat:
|
||||
path: "{{ sno_install_dir }}/.openshift_install_state"
|
||||
get_checksum: false
|
||||
register: install_state_stat
|
||||
register: __install_state_stat
|
||||
|
||||
- name: Set fact - skip ISO build if recent ISO exists on Proxmox and local state is intact
|
||||
ansible.builtin.set_fact:
|
||||
sno_iso_fresh: >-
|
||||
__sno_iso_fresh: >-
|
||||
{{
|
||||
proxmox_iso_stat.stat.exists and
|
||||
(now(utc=true).timestamp() | int - proxmox_iso_stat.stat.mtime | int) < 86400 and
|
||||
install_state_stat.stat.exists
|
||||
__proxmox_iso_stat.stat.exists and
|
||||
(now(utc=true).timestamp() | int - __proxmox_iso_stat.stat.mtime | int) < 86400 and
|
||||
__install_state_stat.stat.exists
|
||||
}}
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Step 2: Get openshift-install binary
|
||||
# Always ensure the binary is present — needed for both ISO generation
|
||||
# and wait-for-install-complete regardless of sno_iso_fresh.
|
||||
# and wait-for-install-complete regardless of __sno_iso_fresh.
|
||||
# Binaries are stored in sno_install_dir so they survive across runs
|
||||
# when sno_install_dir is a mounted volume in an EE.
|
||||
# ------------------------------------------------------------------
|
||||
@@ -247,7 +215,7 @@
|
||||
dest: "{{ sno_install_dir }}/openshift-install-{{ ocp_version }}.tar.gz"
|
||||
mode: "0644"
|
||||
checksum: "{{ ocp_install_checksum | default(omit) }}"
|
||||
register: ocp_install_tarball
|
||||
register: __ocp_install_tarball
|
||||
|
||||
- name: Extract openshift-install binary
|
||||
ansible.builtin.unarchive:
|
||||
@@ -256,7 +224,7 @@
|
||||
remote_src: false
|
||||
include:
|
||||
- openshift-install
|
||||
when: ocp_install_tarball.changed or not (sno_install_dir ~ '/openshift-install') is file
|
||||
when: __ocp_install_tarball.changed or not (sno_install_dir ~ '/openshift-install') is file
|
||||
|
||||
- name: Download openshift-client tarball
|
||||
ansible.builtin.get_url:
|
||||
@@ -264,7 +232,7 @@
|
||||
dest: "{{ sno_install_dir }}/openshift-client-{{ ocp_version }}.tar.gz"
|
||||
mode: "0644"
|
||||
checksum: "{{ ocp_client_checksum | default(omit) }}"
|
||||
register: ocp_client_tarball
|
||||
register: __ocp_client_tarball
|
||||
|
||||
- name: Extract oc binary
|
||||
ansible.builtin.unarchive:
|
||||
@@ -273,7 +241,7 @@
|
||||
remote_src: false
|
||||
include:
|
||||
- oc
|
||||
when: ocp_client_tarball.changed or not (sno_install_dir ~ '/oc') is file
|
||||
when: __ocp_client_tarball.changed or not (sno_install_dir ~ '/oc') is file
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Step 3: Template agent installer config files (skipped if ISO is fresh)
|
||||
@@ -283,14 +251,15 @@
|
||||
src: templates/install-config.yaml.j2
|
||||
dest: "{{ sno_install_dir }}/install-config.yaml"
|
||||
mode: "0640"
|
||||
when: not sno_iso_fresh
|
||||
when: not __sno_iso_fresh
|
||||
no_log: true
|
||||
|
||||
- name: Template agent-config.yaml
|
||||
ansible.builtin.template:
|
||||
src: templates/agent-config.yaml.j2
|
||||
dest: "{{ sno_install_dir }}/agent-config.yaml"
|
||||
mode: "0640"
|
||||
when: not sno_iso_fresh
|
||||
when: not __sno_iso_fresh
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Step 4: Generate discovery ISO (skipped if ISO is fresh)
|
||||
@@ -300,7 +269,7 @@
|
||||
- name: Generate agent-based installer ISO
|
||||
ansible.builtin.command:
|
||||
cmd: "{{ sno_install_dir }}/openshift-install agent create image --dir {{ sno_install_dir }}"
|
||||
when: not sno_iso_fresh
|
||||
when: not __sno_iso_fresh
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Step 5: Upload ISO to Proxmox and attach to VM
|
||||
@@ -311,7 +280,7 @@
|
||||
dest: "{{ proxmox_iso_dir }}/{{ sno_iso_filename }}"
|
||||
mode: "0644"
|
||||
delegate_to: proxmox_host
|
||||
when: not sno_iso_fresh
|
||||
when: not __sno_iso_fresh
|
||||
|
||||
- name: Attach ISO to VM as CDROM
|
||||
ansible.builtin.command:
|
||||
@@ -403,3 +372,4 @@
|
||||
- "Console : https://console-openshift-console.apps.{{ ocp_cluster_name }}.{{ ocp_base_domain }}"
|
||||
- "Kubeconfig : {{ sno_credentials_dir }}/kubeconfig (on proxmox_host)"
|
||||
- "kubeadmin pass : {{ sno_credentials_dir }}/kubeadmin-password (on proxmox_host)"
|
||||
verbosity: 1
|
||||
|
||||
Reference in New Issue
Block a user