add group-based variables
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
---
|
||||
- name: Create a directory if it does not exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ matchbox_assets }}/{{ hostvars['ocp-hub'].cluster_name }}"
|
||||
path: "{{ hostvars[groups['matchbox'][0]].matchbox_assets }}/{{ hostvars[groups['hub-cluster'][0]].cluster_name }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
become: true
|
||||
@@ -9,7 +9,8 @@
|
||||
- name: Copy file with owner and permissions
|
||||
ansible.builtin.copy:
|
||||
src: 03-openshift-image/boot-artifacts/
|
||||
dest: "{{ matchbox_assets }}/{{ hostvars['ocp-hub'].cluster_name }}/"
|
||||
dest: "{{ hostvars[groups['matchbox'][0]].matchbox_assets }}/{{ hostvars[groups['hub-cluster'][0]].cluster_name }}/"
|
||||
owner: matchbox
|
||||
group: matchbox
|
||||
mode: '0644'
|
||||
become: true
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
apiVersion: v1alpha1
|
||||
kind: AgentConfig
|
||||
metadata:
|
||||
name: {{ hostvars['ocp-hub'].cluster_name }}
|
||||
name: {{ hostvars[groups['hub-cluster'][0]].cluster_name }}
|
||||
rendezvousIP: {{ hostvars['ocp-hub'].ip_address }}
|
||||
bootArtifactsBaseURL: https://matchbox.int.mk-labs.cloud:8080/assets/hub/
|
||||
bootArtifactsBaseURL: {{ hostvars['matchbox'].http_endpoint }}/assets/hub/
|
||||
hosts:
|
||||
- hostname: {{ hostvars['ocp-hub'].hostname }}
|
||||
role: master
|
||||
@@ -0,0 +1,25 @@
|
||||
apiVersion: v1
|
||||
baseDomain: {{ hostvars[groups['hub-cluster'][0]].base_domain }}
|
||||
compute:
|
||||
- name: worker
|
||||
replicas: {{ hostvars[groups['hub-cluster'][0]].worker_node_count }}
|
||||
controlPlane:
|
||||
hyperthreading: Enabled
|
||||
name: master
|
||||
replicas: {{ hostvars[groups['hub-cluster'][0]].master_node_count }}
|
||||
metadata:
|
||||
name: {{ hostvars[groups['hub-cluster'][0]].cluster_name }}
|
||||
networking:
|
||||
clusterNetwork:
|
||||
- cidr: {{ hostvars[groups['hub-cluster'][0]].cluster_network }}
|
||||
hostPrefix: {{ hostvars[groups['hub-cluster'][0]].cluster_network_host_prefix }}
|
||||
machineNetwork:
|
||||
- cidr: {{ hostvars[groups['hub-cluster'][0]].machine_network }}
|
||||
networkType: OVNKubernetes
|
||||
serviceNetwork:
|
||||
- {{ hostvars[groups['hub-cluster'][0]].service_network }}
|
||||
platform:
|
||||
{{ hostvars[groups['hub-cluster'][0]].platform_type }}: {}
|
||||
fips: false
|
||||
pullSecret: '{{ vault_pull_secret }}'
|
||||
sshKey: '{{ vault_ssh_key }}'
|
||||
8
10-sno-hub-cluster/04-matchbox/templates/groups.tf.j2
Normal file
8
10-sno-hub-cluster/04-matchbox/templates/groups.tf.j2
Normal file
@@ -0,0 +1,8 @@
|
||||
// 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
|
||||
}
|
||||
}
|
||||
16
10-sno-hub-cluster/04-matchbox/templates/profiles.tf.j2
Normal file
16
10-sno-hub-cluster/04-matchbox/templates/profiles.tf.j2
Normal file
@@ -0,0 +1,16 @@
|
||||
// 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['matchbox'].http_endpoint }}/assets/{{ hostvars[groups['hub-cluster'][0]].cluster_name }}/agent.x86_64-rootfs.img",
|
||||
"rw",
|
||||
"ignition.firstboot",
|
||||
"ignition.platform.id=metal",
|
||||
]
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// Configure the matchbox provider
|
||||
provider "matchbox" {
|
||||
endpoint = "{{ matchbox_rpc_endpoint }}"
|
||||
endpoint = "{{ hostvars['matchbox'].rpc_endpoint }}"
|
||||
client_cert = file("/etc/matchbox/client.crt")
|
||||
client_key = file("/etc/matchbox/client.key")
|
||||
ca = file("/etc/matchbox/ca.crt")
|
||||
@@ -9,43 +9,51 @@
|
||||
community.general.terraform:
|
||||
project_path: 01-dns/
|
||||
variables:
|
||||
freeipa_password: "{{ freeipa_password }}"
|
||||
freeipa_password: "{{ vault_freeipa_password }}"
|
||||
state: present
|
||||
force_init: true
|
||||
|
||||
- ansible.builtin.include_tasks:
|
||||
- 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: templates/openshift-installer/install-config.yaml.j2
|
||||
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: templates/openshift-installer/agent-config.yaml.j2
|
||||
src: 03-openshift-image/templates/agent-config.yaml.j2
|
||||
dest: 03-openshift-image/agent-config.yaml
|
||||
mode: '0644'
|
||||
|
||||
- ansible.builtin.include_tasks:
|
||||
- name: Create OpenShift image
|
||||
ansible.builtin.include_tasks:
|
||||
file: 03-openshift-image/create-openshift-image.yml
|
||||
|
||||
- ansible.builtin.include_tasks:
|
||||
- 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: templates/matchbox/groups.tf.j2
|
||||
src: matchbox/templates/groups.tf.j2
|
||||
dest: 04-matchbox/groups.tf
|
||||
mode: '0644'
|
||||
|
||||
- name: Terraform matchbox profiles file
|
||||
ansible.builtin.template:
|
||||
src: templates/matchbox/profiles.tf.j2
|
||||
src: matchbox/templates/profiles.tf.j2
|
||||
dest: 04-matchbox/profiles.tf
|
||||
mode: '0644'
|
||||
|
||||
- name: Terraform matchbox provider file
|
||||
ansible.builtin.template:
|
||||
src: templates/matchbox/provider.tf.j2
|
||||
src: matchbox/templates/provider.tf.j2
|
||||
dest: 04-matchbox/provider.tf
|
||||
mode: '0644'
|
||||
|
||||
- name: Configure Matchbox via Terraform
|
||||
community.general.terraform:
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// Matcher group for OCP Internal machines
|
||||
resource "matchbox_group" "{{hub_cluster_name}}" {
|
||||
name = "{{hub_cluster_hostname}}" # Physical Server
|
||||
profile = matchbox_profile.openshift-agent-install.name
|
||||
selector = {
|
||||
mac = "{{hub_cluster_mac_address}}" # PXE boots and installs to 10GbE NIC
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
// Fedora CoreOS profile
|
||||
resource "matchbox_profile" "openshift-agent-install" {
|
||||
name = "{{ hub_cluster_name }}"
|
||||
kernel = "/assets/{{ hub_cluster_name }}/agent.x86_64-vmlinuz"
|
||||
initrd = [
|
||||
"--name initrd /assets/{{ hub_cluster_name }}/agent.x86_64-initrd.img"
|
||||
]
|
||||
|
||||
args = [
|
||||
"initrd=initrd",
|
||||
"coreos.live.rootfs_url={{ matchbox_http_endpoint }}/assets/{{ hub_cluster_name }}/agent.x86_64-rootfs.img",
|
||||
"rw",
|
||||
"ignition.firstboot",
|
||||
"ignition.platform.id=metal",
|
||||
]
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
apiVersion: v1
|
||||
baseDomain: {{ hostvars['ocp-hub'].base_domain }}
|
||||
compute:
|
||||
- name: worker
|
||||
replicas: {{ hostvars['ocp-hub'].worker_node_count }}
|
||||
controlPlane:
|
||||
hyperthreading: Enabled
|
||||
name: master
|
||||
replicas: {{ hostvars['ocp-hub'].master_node_count }}
|
||||
metadata:
|
||||
name: {{ hostvars['ocp-hub'].cluster_name }}
|
||||
networking:
|
||||
clusterNetwork:
|
||||
- cidr: {{ hostvars['ocp-hub'].cluster_network }}
|
||||
hostPrefix: {{ hostvars['ocp-hub'].cluster_network_host_prefix }}
|
||||
machineNetwork:
|
||||
- cidr: {{ hostvars['ocp-hub'].machine_network }}
|
||||
networkType: OVNKubernetes
|
||||
serviceNetwork:
|
||||
- {{ hostvars['ocp-hub'].service_network }}
|
||||
platform:
|
||||
{{ hostvars['ocp-hub'].platform_type }}: {}
|
||||
fips: false
|
||||
pullSecret: '{{ vault_pull_secret }}'
|
||||
sshKey: '{{ vault_ssh_key }}'
|
||||
@@ -1,3 +1,3 @@
|
||||
---
|
||||
freeipa_user: "admin"
|
||||
freeipa_password: "{{ vault_freeipa_password }}"
|
||||
#freeipa_password: "{{ vault_freeipa_password }}"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
# Variables for Matchbox
|
||||
matchbox_assets: "/var/lib/matchbox/assets"
|
||||
matchbox_http_endpoint: "http://matchbox.int.mk-labs.cloud:8080"
|
||||
matchbox_rpc_endpoint: "matchbox.int.mk-labs.cloud:8081"
|
||||
assets: "/var/lib/matchbox/assets"
|
||||
http_endpoint: "http://matchbox.int.mk-labs.cloud:8080"
|
||||
rpc_endpoint: "matchbox.int.mk-labs.cloud:8081"
|
||||
|
||||
# Variables for OpenShift Installer
|
||||
openshift_installer_pull_secret: "{{ vault_pull_secret }}"
|
||||
openshift_installer_ssh_key: "{{ vault_ssh_key }}"
|
||||
#openshift_installer_pull_secret: "{{ vault_pull_secret }}"
|
||||
#openshift_installer_ssh_key: "{{ vault_ssh_key }}"
|
||||
|
||||
22
test.yml
Normal file
22
test.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
- name: Run all tasks necessary to configure matchbox to install the cluster
|
||||
hosts: matchbox
|
||||
connection: local
|
||||
gather_facts: true
|
||||
|
||||
tasks:
|
||||
- name: Print vars for debugging
|
||||
ansible.builtin.debug:
|
||||
msg: System {{ hostvars['infra01'].matchbox_assets }} / {{ hostvars['ocp-hub'].cluster_name }}
|
||||
|
||||
- name: Print vars for debugging 2
|
||||
ansible.builtin.debug:
|
||||
msg: System {{ groups }}
|
||||
|
||||
- name: Print vars for debugging 3
|
||||
ansible.builtin.debug:
|
||||
msg: System {{ groups['hub-cluster'][0] }}
|
||||
|
||||
- name: Print vars for debugging 4
|
||||
ansible.builtin.debug:
|
||||
msg: System {{ hostvars[groups['hub-cluster'][0]].cluster_name }}
|
||||
Reference in New Issue
Block a user