Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ skip_list:
mock_modules:
- agnosticd.core.agnosticd_user_info
- ansible.controller.license
- troshka.cloud.project_info
53 changes: 53 additions & 0 deletions roles/host_ocp4_agent_installer/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
# OCP Agent-Based Installer role defaults

# OCP version — major.minor or major.minor.patch
host_ocp4_installer_version: "4.20"

# Mirror URL for downloading openshift-install and oc
host_ocp4_installer_root_url: https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp

# Cluster config
host_ocp4_cluster_name: "{{ ocp.cluster_name | default('ocp') }}"
host_ocp4_base_domain: "{{ ocp.base_domain | default('ocp.local') }}"
host_ocp4_api_vip: "{{ ocp.api_vip }}"
host_ocp4_ingress_vip: "{{ ocp.ingress_vip }}"

# Pull secret — JSON string
host_ocp4_pull_secret: "{{ pull_secret | default('{}') }}"

# SSH public key for core user access
host_ocp4_ssh_key: "{{ ssh_pub_key | default('') }}"

# BMC credentials for Redfish virtual media boot
host_ocp4_bmc_user: admin
host_ocp4_bmc_password: "{{ common_password }}"

# BMC IPs to boot — list of IPs, derived from topology if not set
host_ocp4_bmc_ips: []

# Cluster network CIDRs
host_ocp4_machine_network_cidr: "{{ networks.cluster.cidr | default('10.0.0.0/24') }}"
host_ocp4_bmc_cidr: "{{ networks.bmc.cidr | default('192.168.50.0/24') }}"
host_ocp4_cluster_network_cidr: 10.128.0.0/14
host_ocp4_service_network_cidr: 172.30.0.0/16

# Install dir on bastion
host_ocp4_install_dir: "/home/{{ ansible_user }}/ocp-install"

# HTTP server port for serving agent ISO
host_ocp4_iso_http_port: 8080

# Timeout for cluster install (seconds)
host_ocp4_install_timeout: 5400

# Additional trust bundle (registry CA cert) — set by disconnected_registry role
host_ocp4_additional_trust_bundle: ""

# RHCOS images to download and serve via HTTP for assisted-image-service
host_ocp4_rhcos_images: []

# NTP sources
host_ocp4_ntp_sources:
- clock.redhat.com
- pool.ntp.org
42 changes: 42 additions & 0 deletions roles/host_ocp4_agent_installer/tasks/boot_via_bmc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# Boot a single node via Redfish virtual media
# Called in a loop with _bmc_ip as the loop var

- name: Get Redfish system ID - {{ _bmc_ip }}
ansible.builtin.uri:
url: "http://{{ _bmc_ip }}:8000/redfish/v1/Systems"
user: "{{ host_ocp4_bmc_user }}"
password: "{{ host_ocp4_bmc_password }}"
force_basic_auth: true
return_content: true
register: _redfish_systems

- name: Extract system ID
ansible.builtin.set_fact:
_sys_id: "{{ _redfish_systems.json.Members[0]['@odata.id'].split('/')[-1] }}"

- name: Insert virtual media ISO - {{ _bmc_ip }}
ansible.builtin.uri:
url: "http://{{ _bmc_ip }}:8000/redfish/v1/Systems/{{ _sys_id }}/VirtualMedia/Cd/Actions/VirtualMedia.InsertMedia"
method: POST
user: "{{ host_ocp4_bmc_user }}"
password: "{{ host_ocp4_bmc_password }}"
force_basic_auth: true
body_format: json
body:
Image: "http://{{ _bastion_ip }}:{{ host_ocp4_iso_http_port }}/agent.x86_64.iso"
Inserted: true
WriteProtected: true
status_code: [200, 204]

- name: Reboot node from ISO - {{ _bmc_ip }}
ansible.builtin.uri:
url: "http://{{ _bmc_ip }}:8000/redfish/v1/Systems/{{ _sys_id }}/Actions/ComputerSystem.Reset"
method: POST
user: "{{ host_ocp4_bmc_user }}"
password: "{{ host_ocp4_bmc_password }}"
force_basic_auth: true
body_format: json
body:
ResetType: ForceRestart
status_code: [200, 204]
34 changes: 34 additions & 0 deletions roles/host_ocp4_agent_installer/tasks/eject_iso.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
# Eject virtual media from a BMC node after install
# Called in a loop with _bmc_ip as the loop var

- name: Get Redfish system ID for eject - {{ _bmc_ip }}
ansible.builtin.uri:
url: "http://{{ _bmc_ip }}:8000/redfish/v1/Systems"
user: "{{ host_ocp4_bmc_user }}"
password: "{{ host_ocp4_bmc_password }}"
force_basic_auth: true
return_content: true
register: _redfish_systems_eject
ignore_errors: true

- name: Extract system ID for eject
when: _redfish_systems_eject is success
ansible.builtin.set_fact:
_sys_id_eject: >-
{{ _redfish_systems_eject.json.Members[0]['@odata.id'].split('/')[-1] }}

- name: Eject virtual media - {{ _bmc_ip }}
when: _redfish_systems_eject is success
ansible.builtin.uri:
url: >-
http://{{ _bmc_ip }}:8000/redfish/v1/Systems/{{
_sys_id_eject }}/VirtualMedia/Cd/Actions/VirtualMedia.EjectMedia
method: POST
user: "{{ host_ocp4_bmc_user }}"
password: "{{ host_ocp4_bmc_password }}"
force_basic_auth: true
body_format: json
body: {}
status_code: [200, 204]
ignore_errors: true
Loading
Loading