|
| 1 | +## Disclaimer: |
| 2 | +# This playbook is not officially supported and comes with no guarantees. |
| 3 | +# Use it at your own risk. Ensure you test thoroughly in your environment |
| 4 | +# before deploying to production. |
| 5 | + |
| 6 | +# This Ansible playbook is designed for deploying an OpenShift cluster. |
| 7 | +# It includes various roles and tasks necessary to configure a bastion host, |
| 8 | +# deploy virtual machines (VMs), and boot bare-metal (BM) and VM nodes. |
| 9 | +# The playbook also sets up dependencies, generates manifests, and monitors the installation process. |
| 10 | + |
| 11 | +## Overview: |
| 12 | +# This playbook automates the process of deploying ocp cluster. It includes: |
| 13 | +# - Bastion host setup: Installs required dependencies and extracts OpenShift installer. |
| 14 | +# - OCP version facts: Retrieves OpenShift release information. |
| 15 | +# - HTTP storage setup: Configures HTTP-based storage for required artifacts. |
| 16 | +# - Virtual control plane setup: Enables necessary repositories and configures sushy tools. |
| 17 | +# - VM and BM booting: Deploys instances and boots nodes using an agent-based installer. |
| 18 | +# - Installation monitoring: Ensures the installation process completes successfully. |
| 19 | + |
| 20 | +## Prerequisites: |
| 21 | +# - Ansible 2.10+ installed on the control node. |
| 22 | +# - Ansible control node configured with necessary permissions. |
| 23 | +# - SSH Access to hypervisors hosts. |
| 24 | +# - SSH Access to bastion hosts. |
| 25 | +# - ocp version of link to ocp release |
| 26 | +# - pre-configured hosts_vars and grup_vars directories |
| 27 | + |
| 28 | +## Roles Requirements |
| 29 | +# The playbook uses role: |
| 30 | +# - redhatci.ocp.create_vms: Creates VMs on given hypervisor. |
| 31 | + |
| 32 | +# Required Roles: |
| 33 | +# The playbook uses roles: |
| 34 | +# - ocp_version_facts |
| 35 | +# - redhatci.ocp.setup_http_store |
| 36 | +# - ocp_client |
| 37 | +# - redhatci.ocp.extract_openshift_installer |
| 38 | +# - redhatci.ocp.generate_manifests |
| 39 | +# - redhatci.ocp.generate_agent_iso |
| 40 | +# - redhatci.ocp.process_kvm_nodes |
| 41 | +# - redhatci.ocp.setup_sushy_tools |
| 42 | +# - redhatci.ocp.destroy_vms |
| 43 | +# - redhatci.ocp.create_vms |
| 44 | +# - redhatci.ocp.boot_iso |
| 45 | +# - redhatci.ocp.monitor_agent_based_installer |
| 46 | + |
| 47 | +## Usage: |
| 48 | +# - Ensure all required variables are defined in the inventory or host_vars/group_vars. |
| 49 | +# - Execute the playbook using Ansible's command-line tool: |
| 50 | +# |
| 51 | +# Deploy latest 4.17 |
| 52 | +# ansible-playbook ./playbooks/deploy-ocp-hybrid-multinode.yml -i ./inventories/ocp-deployment/deploy-ocp-hybrid-multinode.yml --extra-vars 'release=4.17' |
| 53 | +# Deploy specific release from link: |
| 54 | +# ansible-playbook ./playbooks/deploy-ocp-hybrid-multinode.yml -i ./inventories/ocp-deployment/deploy-ocp-hybrid-multinode.yml |
| 55 | +# --extra-vars 'release=quay.io/openshift-release-dev/ocp-release:4.15.44-x86_64' |
| 56 | +# Deploy specific version: |
| 57 | +# ansible-playbook ./playbooks/deploy-ocp-hybrid-multinode.yml -i ./inventories/ocp-deployment/deploy-ocp-hybrid-multinode.yml --extra-vars 'release=4.17.9' |
| 58 | +# |
| 59 | +# Notes: |
| 60 | +# - This playbook assumes the hypervisor and bastion hosts are pre-installed and ready. |
| 61 | +# - Test in a non-production environment before deploying. |
| 62 | +--- |
| 63 | +- name: Setup bastion environment and generate manifests for cluster deployment |
| 64 | + hosts: bastion |
| 65 | + vars: |
| 66 | + release: "4.17" |
| 67 | + tasks: |
| 68 | + |
| 69 | + - name: Set openshift-installer path fact |
| 70 | + ansible.builtin.set_fact: |
| 71 | + openshift_installer_extract_dest_path: "{{ dest_iso_dir }}/wip/extract" |
| 72 | + |
| 73 | + - name: Install dependencies required for the installer |
| 74 | + become: true |
| 75 | + ansible.builtin.dnf: |
| 76 | + name: |
| 77 | + - nmstate |
| 78 | + state: present |
| 79 | + |
| 80 | + - name: Ensure firewalld is running |
| 81 | + become: true |
| 82 | + ansible.builtin.service: |
| 83 | + name: firewalld |
| 84 | + state: started |
| 85 | + |
| 86 | + # The role below sets follwing facts. Please note values are just examples |
| 87 | + # ocp_version_facts_pull_spec: quay.io/openshift-release-dev/ocp-release:4.15.44-x86_64 |
| 88 | + # ocp_version_facts_parsed_release: "4.15.44" |
| 89 | + # ocp_version_facts_major: "4" |
| 90 | + # ocp_version_facts_minor: "15" |
| 91 | + # ocp_version_facts_oc_client_pull_link: |
| 92 | + # "https://openshift-release-artifacts.apps.ci.l2s4.p1.openshiftapps.com/4.15.44/openshift-client-linux-4.15.44.tar.gz" |
| 93 | + # ocp_version_facts_z_stream: "44" |
| 94 | + # ocp_version_facts_dev_version: "rc1" |
| 95 | + - name: Set OCP version facts |
| 96 | + ansible.builtin.import_role: |
| 97 | + name: ocp_version_facts |
| 98 | + vars: |
| 99 | + ocp_version_facts_release: "{{ release }}" |
| 100 | + |
| 101 | + - name: Setup HTTP storage |
| 102 | + ansible.builtin.import_role: |
| 103 | + name: redhatci.ocp.setup_http_store |
| 104 | + |
| 105 | + - name: Deploy/Redeploy OC client |
| 106 | + ansible.builtin.import_role: |
| 107 | + name: ocp_client |
| 108 | + vars: |
| 109 | + ocp_client_url: "{{ ocp_version_facts_oc_client_pull_link }}" |
| 110 | + ocp_client_archive_dest_dir: "{{ dest_iso_dir }}" |
| 111 | + |
| 112 | + - name: Download and extract OCP installer |
| 113 | + ansible.builtin.import_role: |
| 114 | + name: redhatci.ocp.extract_openshift_installer |
| 115 | + vars: |
| 116 | + openshift_version: "{{ ocp_version_facts_parsed_release }}" |
| 117 | + release_image: "{{ ocp_version_facts_pull_spec }}" |
| 118 | + extract_dest_path: "{{ openshift_installer_extract_dest_path }}" |
| 119 | + |
| 120 | + - name: Generate deployment manifests for OCP installation |
| 121 | + ansible.builtin.import_role: |
| 122 | + name: redhatci.ocp.generate_manifests |
| 123 | + |
| 124 | + - name: Generate boot ISO for agent-based installer |
| 125 | + ansible.builtin.import_role: |
| 126 | + name: redhatci.ocp.generate_agent_iso |
| 127 | + vars: |
| 128 | + gai_cluster_name: "{{ cluster_name }}" |
| 129 | + gai_repo_root_path: "{{ repo_root_path }}" |
| 130 | + gai_pull_secret: "{{ pull_secret }}" |
| 131 | + gai_agent_based_installer_path: "{{ openshift_installer_extract_dest_path }}/openshift-install" |
| 132 | + gai_discovery_iso_name: "agent.iso" |
| 133 | + gai_remote_http_src: true |
| 134 | + gai_http_delegate_host: "{{ inventory_hostname }}" |
| 135 | + |
| 136 | + - name: Process KVM nodes to set facts |
| 137 | + ansible.builtin.import_role: |
| 138 | + name: redhatci.ocp.process_kvm_nodes |
| 139 | + |
| 140 | +- name: Setup Virtual Control Plane |
| 141 | + hosts: vm_hosts |
| 142 | + tasks: |
| 143 | + |
| 144 | + - name: Enable CRB repository |
| 145 | + become: true |
| 146 | + ansible.builtin.command: "dnf config-manager --enable rhosp-rhel-9.4-crb" |
| 147 | + changed_when: false |
| 148 | + |
| 149 | + - name: Setup sushy tool to emulate OOB interface |
| 150 | + ansible.builtin.import_role: |
| 151 | + name: redhatci.ocp.setup_sushy_tools |
| 152 | + vars: |
| 153 | + cert_state: "QE" |
| 154 | + cert_locality: TLV |
| 155 | + cert_organization: RH |
| 156 | + cert_country: US |
| 157 | + cert_organizational_unit: QE |
| 158 | + fetched_dest: "/tmp/artifacts" |
| 159 | + |
| 160 | + - name: Destroy pre-installed VMs |
| 161 | + ansible.builtin.import_role: |
| 162 | + name: redhatci.ocp.destroy_vms |
| 163 | + |
| 164 | + - name: Create VMs |
| 165 | + ansible.builtin.import_role: |
| 166 | + name: redhatci.ocp.create_vms |
| 167 | + |
| 168 | +- name: Boot Bare-Metal Nodes |
| 169 | + hosts: workers |
| 170 | + gather_facts: false |
| 171 | + tasks: |
| 172 | + - name: Boot ISO |
| 173 | + ansible.builtin.import_role: |
| 174 | + name: redhatci.ocp.boot_iso |
| 175 | + vars: |
| 176 | + boot_iso_url: "http://{{ hostvars['bastion']['ansible_default_ipv4']['address'] }}/{{ agent_iso_name }}" |
| 177 | + |
| 178 | +- name: Boot Virtual Machines |
| 179 | + hosts: masters |
| 180 | + gather_facts: false |
| 181 | + serial: 1 |
| 182 | + tasks: |
| 183 | + - name: Boot ISO |
| 184 | + ansible.builtin.import_role: |
| 185 | + name: redhatci.ocp.boot_iso |
| 186 | + vars: |
| 187 | + boot_iso_url: "http://{{ hostvars['bastion']['ansible_default_ipv4']['address'] }}/{{ agent_iso_name }}" |
| 188 | + |
| 189 | +- name: Monitor installation process of agent-based installer |
| 190 | + hosts: bastion |
| 191 | + gather_facts: false |
| 192 | + tasks: |
| 193 | + |
| 194 | + - name: Monitor agent based installation |
| 195 | + ansible.builtin.import_role: |
| 196 | + name: redhatci.ocp.monitor_agent_based_installer |
| 197 | + vars: |
| 198 | + agent_based_installer_path: "{{ openshift_installer_extract_dest_path }}/openshift-install" |
| 199 | + mabi_retry_install_complete_check: true |
0 commit comments