From ce284f8f7e7a5257d8c10d3e025e95716d370170 Mon Sep 17 00:00:00 2001 From: rblundon Date: Sat, 22 Mar 2025 14:31:00 -0500 Subject: [PATCH] add dhcp reservation --- .../02-dhcp/ip-reservations.yml | 31 +++++++++++++++++++ 10-sno-hub-cluster/README.md | 18 +++++++++++ 10-sno-hub-cluster/install.yml | 24 +++++--------- 10-sno-hub-cluster/requirements.yml | 2 +- 4 files changed, 58 insertions(+), 17 deletions(-) create mode 100644 10-sno-hub-cluster/02-dhcp/ip-reservations.yml diff --git a/10-sno-hub-cluster/02-dhcp/ip-reservations.yml b/10-sno-hub-cluster/02-dhcp/ip-reservations.yml new file mode 100644 index 0000000..dd1b313 --- /dev/null +++ b/10-sno-hub-cluster/02-dhcp/ip-reservations.yml @@ -0,0 +1,31 @@ +--- +- name: Set dnsmasq host reservation + hosts: all + become: true + vars: + mac_address: "98:b7:85:1e:c6:f1" + ip_address: "10.1.71.10" + hostname: "ocp-hub" + tasks: + - name: Ensure dnsmasq is installed + ansible.builtin.apt: + name: dnsmasq + state: present + when: ansible_os_family == "Debian" + + - name: Ensure dnsmasq is installed + ansible.builtin.dnf: + name: dnsmasq + state: present + when: ansible_os_family == "RedHat" + + - name: Add host reservation to dnsmasq + ansible.builtin.lineinfile: + path: /etc/dnsmasq.d/hosts.conf + line: "dhcp-host={{ mac_address }},{{ ip_address }},{{ hostname }}" + state: present + + - name: Restart dnsmasq service + ansible.builtin.service: + name: dnsmasq + state: restarted diff --git a/10-sno-hub-cluster/README.md b/10-sno-hub-cluster/README.md index e69de29..0c04332 100644 --- a/10-sno-hub-cluster/README.md +++ b/10-sno-hub-cluster/README.md @@ -0,0 +1,18 @@ +# Prepare matchbox to install hub cluster + +## Modify config file for OpenShift Automated Installer + +- 03-matchbox/install-config +- 03-matchbox/agent-config + +## Install Ansible pre-requisites + +```bash +ansible-galaxy collection install -r +``` + +## Run installation playbook + +```bash +ansible-playbook install.yml +``` diff --git a/10-sno-hub-cluster/install.yml b/10-sno-hub-cluster/install.yml index e09c41f..0bd5c74 100644 --- a/10-sno-hub-cluster/install.yml +++ b/10-sno-hub-cluster/install.yml @@ -1,27 +1,19 @@ --- - name: Run all tasks necessary to configure matchbox to install the cluster - hosts: all + hosts: 127.0.0.1 + connection: local gather_facts: true vars_prompt: - name: freeipa_password prompt: FreeIPA password for admin user - pre_tasks: - - name: Install requirements - delegate_to: localhost - ansible.builtin.command: ansible-galaxy install -r requirements.yml - # Other tasks that you run BEFORE the roles - tasks: - - name: Set FreeIPA password - ansible.builtin.command: - cmd: export TF_VAR_freeipa_password="{{ freeipa_password }}" - - name: Deploy DNS entries for cluster via Terraform community.general.terraform: - project_path: 01-dns + project_path: 01-dns/ + variables: + freeipa_password: "{{ freeipa_password }}" state: present -# - name: Basic deploy of a service -# community.general.terraform: -# project_path: '{{ project_dir }}' -# state: present + force_init: true + + - include: 02-dhcp/ip-reservations.yml diff --git a/10-sno-hub-cluster/requirements.yml b/10-sno-hub-cluster/requirements.yml index ad004fc..9bda7f6 100644 --- a/10-sno-hub-cluster/requirements.yml +++ b/10-sno-hub-cluster/requirements.yml @@ -1,4 +1,4 @@ # requirements.yml collections: - - name: ommunity.general + - name: community.general version: 10.4.0