// Module included in the following assemblies:
//
// * installing/installing_bare_metal/ipi/ipi-install-installation-workflow.adoc
//
// As of Dec. 6, 2024, the following link does not have a variable defined. Link is located in the Red Hat Subscription Manager Note on line 66. Please update link to use a defined variable when available:
// https://docs.redhat.com/en/documentation/subscription_central/1-latest/html/getting_started_with_rhel_system_registration/basic-reg-rhel-cli

:_mod-docs-content-type: PROCEDURE
[id="preparing-the-provisioner-node-for-openshift-install_{context}"]
= Preparing the provisioner node for {product-title} installation

Perform the following steps to prepare the environment.

.Procedure

. Log in to the provisioner node via `ssh`.

. Create a non-root user (`kni`) and provide that user with `sudo` privileges:
+
[source,terminal]
----
# useradd kni
----
+
[source,terminal]
----
# passwd kni
----
+
[source,terminal]
----
# echo "kni ALL=(root) NOPASSWD:ALL" | tee -a /etc/sudoers.d/kni
----
+
[source,terminal]
----
# chmod 0440 /etc/sudoers.d/kni
----

. Create an `ssh` key for the new user:
+
[source,terminal]
----
# su - kni -c "ssh-keygen -t ed25519 -f /home/kni/.ssh/id_rsa -N ''"
----

. Log in as the new user on the provisioner node:
+
[source,terminal]
----
# su - kni
----

ifndef::openshift-origin[]
. Use Red Hat Subscription Manager to register the provisioner node:
+
[source,terminal]
----
$ sudo subscription-manager register --username=<user> --password=<pass> --auto-attach
----
+
[source,terminal]
----
$ sudo subscription-manager repos --enable=rhel-9-for-<architecture>-appstream-rpms --enable=rhel-9-for-<architecture>-baseos-rpms
----
+
[NOTE]
====
For more information about Red Hat Subscription Manager, see link:https://docs.redhat.com/en/documentation/subscription_central/1-latest/html/getting_started_with_rhel_system_registration/basic-reg-rhel-cli[Registering a {op-system-base} system with command-line tools].
====
endif::openshift-origin[]

. Install the following packages:
+
[source,terminal]
----
$ sudo dnf install -y libvirt qemu-kvm mkisofs python3-devel jq ipmitool
----

. Modify the user to add the `libvirt` group to the newly created user:
+
[source,terminal]
----
$ sudo usermod --append --groups libvirt <user>
----

. Restart `firewalld` and enable the `http` service:
+
[source,terminal]
----
$ sudo systemctl start firewalld
----
+
[source,terminal]
----
$ sudo firewall-cmd --zone=public --add-service=http --permanent
----
+
[source,terminal]
----
$ sudo firewall-cmd --reload
----

. Start the modular `libvirt` daemon sockets:
+
[source,terminal]
----
$ for drv in qemu interface network nodedev nwfilter secret storage; do sudo systemctl start virt${drv}d{,-ro,-admin}.socket; done
----

. Create the `default` storage pool and start it:
+
[source,terminal]
----
$ sudo virsh pool-define-as --name default --type dir --target /var/lib/libvirt/images
----
+
[source,terminal]
----
$ sudo virsh pool-start default
----
+
[source,terminal]
----
$ sudo virsh pool-autostart default
----

. Create a `pull-secret.txt` file:
+
[source,terminal]
----
$ vim pull-secret.txt
----
+
In a web browser, navigate to link:https://console.redhat.com/openshift/install/metal/installer-provisioned[Install OpenShift on Bare Metal with installer-provisioned infrastructure]. Click **Copy pull secret**. Paste the contents into the `pull-secret.txt` file and save the contents in the `kni` user's home directory.
