The Custom OS feature lets you install a different OS on the server with a unique setup. By default, it installs Ubuntu Jammy (22.04) to RAM and lets you run post-provisioning actions on the server. To demonstrate the custom OS feature on BMC, this tutorial installs a CentOS alternative: Rocky Linux.
The steps below show how to provision a server with a custom OS using an Ansible playbook. The Ansible playbook uses the Bare Metal Cloud API to provision a server and performs additional post-provisioning actions.
The following features are customizable through the Ansible playbook:
- The root size.
- The choice of whether to use LVM or not.
- Setting the RAID level, if any. To learn more, check out our RAID levels and types guide.
- Custom OS disk image, either a pre-created one or a custom-made image.
Prerequisites
Log in to the BMC portal (if you are a new user, set up your account). You will also need access to an Ubuntu machine with Ansible 2.9+, BMC Ansible module, and Git installed.
Step 1: Authorize Access to BMC Resources
1. Open the API Credentials page.
2. Create new credentials with the bmc scope.
3. Copy and paste the credentials into a ~/.pnap/config.yaml file:
clientId: [client_ID]
clientSecret: [client_secret]Code language: YAML (yaml)
The Ansible playbook uses these credentials to authorize API requests for provisioning the server.
4. Lastly, generate SSH keys to allow access to the server:
ssh-keygenCode language: Bash (bash)
Save the keys using default names (id_rsa and id_rsa.pub). For different names, apply the changes in subsequent steps.
The SSH public key provisions the server with the Ansible playbook. After setup, the keys enable remote SSH access to the server.
Step 2: Clone Ansible Playbook Files from GitHub
The Custom OS playbooks are available on phoenixNAP's GitHub page. The playbooks work with the BMC API to provision and set up the server.
Fetch the Ansible playbook files:
git clone https://github.com/phoenixnap/ansible-ramos-bmcCode language: Bash (bash)
The playbook files are:
| File | Description |
|---|---|
| inventory.yaml | Contains all the information about the BMC server. Provide custom values in this file for a different setup. |
| provision.yaml | Deploys the BMC server using the Custom OS feature. The playbook uses the information from inventory.yaml to deploy and set up a custom OS on the server. |
Step 3: Customize OS Inventory File
The inventory.yaml file contains information about your server and the custom OS setup. The default values used in this guide are:
- An s2.c1.medium server in Phoenix at an hourly rate.
- Rocky OS with a 50G root volume, LVM, and RAID level 0.
The file contains information about the server in the following fields:
| Field | Description |
|---|---|
hosts | Lists individual hosts. Specify additional hosts with personalized options to provision multiple custom OS servers. Value: ramosrocky9 |
description | A description of the server. |
os | The OS of the provisioned server. Do not change this field. Value: ubuntu/jammy |
type | The BMC server instance to provision. |
location | The three-letter code for the server location. |
ssh_key | The location of the public SSH key for authentication. If using a different name or path, change the value. |
install_default_ssh_keys | Tells the server to add any default SSH keys from your BMC account. |
ssh_key_ids | List of additional SSH keys to add. Locate the IDs on the SSH Keys Management page. Leave blank if no additional keys are necessary. |
reservation_id | If using a reservation, provide the reservation ID in this field. If provisioning a new server, leave this field as Null. |
pricing_model | The billing model. Value: HOURLY |
network_type | Defines the network to install additional requirements. |
Additional information about the custom OS is in the following variables:
| Field | Description |
|---|---|
os_user | The user for accessing the server via SSH after installation. Value: rocky. |
os_root_size | Size of the root partition in gigabytes. Set the size between 20 and 50GB. |
os_lvm | Indicates whether to use logical volume management. |
os_raid | Sets the RAID level. Available options are 0 or 1. Leave blank for no RAID setup. |
os_image_url | Link to the image of the custom OS you wish to install. |
Step 4: Run Provision Playbook
The provision.yaml playbook provisions a server with Ubuntu Jammy (22.04) booted in RAM. After the boot, the playbook automatically installs a custom OS based on the values provided in inventory.yaml.
Run the playbook:
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook provision.yaml -i inventory.yamlCode language: Bash (bash)
The playbook goes through the following tasks:
- Provisions the server. Once the server provisions, the output shows a response with the server details. If provisioning fails, double-check that the server instance you're trying to deploy is available for the chosen location.
- Connects to the server via SSH.
- Sets up the OS image. The playbook uses the curtin tool to download the image previously created using packer.
- Performs block device checks to ensure the right resources are available for the custom setup.
- Creates the curtin installer configuration file and executes the file to perform the installation.
- Reboots and connects via SSH to confirm a connection.
Note
Add the -vv tag for verbose output to see task details.
Once the setup completes, the output shows the playbook recap. The server is set up with a custom OS and ready to use.
Step 5: Connect to Server
To connect to the server via SSH, use the OS user provided in the inventory.yaml file and the server's IP address to access the server via SSH. If using the default values, the user is set to rocky.
After connecting to the server, list the block devices to confirm the setup is successful:
lsblkCode language: Bash (bash)
The output shows the values provided in the inventory.yaml file. The default values are a 50G root volume with LVM and RAID 0 setup. Root access and sudo commands are immediately available.