July 31, 2019 By Ryan Tiffany 3 min read

Deploying a custom image in a cloud environment can present certain challenges

Building automation around infrastructure deployment is key to ensuring rapid delivery of services in the cloud. Deploying standard image templates is a straightforward process on the IBM Cloud, and this can be automated for efficiency and to avoid manual errors. But what about deploying a custom image?  

Deploying a custom image in a cloud environment can present various challenges—ensuring proper formatting of images, encountering cloud server image limitations and compatibility, and the time required to upload and configure images, just to mention a few.  

Automation technology can drastically speed up the deployment of custom images, ensure best practices, and remove any chance of manual errors.    

Example code for an automation solution 

In this blog post, I will provide example code for a solution to automate deployment of a custom OS on a No OS IBM Cloud Bare Metal Server using Terraform and Ansible technology. Terraform will be used to deploy the compute resources—in this case a virtual server that will serve as our Preboot Execution Environment (PXE) server and the No OS bare metal server. Then, Ansible will be used to set up the PXE server.

Specifically, the code in this example will do the following:

  • Create a new VLAN for PXE deployment environment
  • Create a new Subnet on the PXE Server VLAN for use with DHCP
  • Deploy an hourly virtual server as the PXE Server (Ubuntu 16 2×4 Instance)
  • Run Ansible Playbooks to:
    • Update the PXE Server Operating System
    • Install and configure Dnsmasq and PXE
    • Download an Ubuntu 18 Server ISO
    • Copy ISO netboot tools in to the tftpboot directory
    • Copy Ubuntu ISO files to PXE Directory
    • Update the dnsmasq server configuration
    • Configure DHCP settings
  • Create an IBM Cloud support ticket to have the virtual servers private IP set as the DHCP helper address on the appropriate VLAN
  • Deploy a No OS server on to the PXE server VLAN

Prerequisites

In order to use this example code, you will need an upgraded IBM Cloud account. Don’t have an IBM Cloud account yet?  Sign up here.

  • Terraform and the IBM Terraform provider plugin installed. Guide.
  • Ansible installed. Guide.
  • An IBM Cloud PaaS and IaaS API key. Guide.

If you already have Terraform v0.12 installed, you will need to use a different machine or downgrade. The IBM Cloud Provider plugin only supports pre-v0.12 Terraform versions.

Step-by-step process to use the example code

1. Download the example code

$ git clone https://github.com/greyhoundforty/ibm_pxe_terraform.git
$ cd ibm_pxe_terraform

2. Update the install.yml file with your local SSH key

If you don’t have an SSH key generated, you will need to create one. The SSH key will be used to authenticate with our PXE instance for Ansible communication. The example below will work on macOS and Linux. If you need different options, please see this guide on how to generate an SSH Key.

$ ssh-keygen -o -t rsa -b 4096

Replace your_public_ssh_key_here with your Public SSH Key in the install.yml file.

$ nano/vi install.yml

3. Configuring the provider

Copy the credentials template file and update it with your IBM Cloud details. See this page for more information about provider variables.

$ cp credentials.tfvars.tpl credentials.tfvars
$ nano/vi credentials.tfvars

4. Initialize Terraform

Run the terraform init command to initialize the directory containing your Terraform files.

$ terraform init

5. Create the initial Terraform plan

The plan command is used to create an execution plan based on your Terraform files.

$ terraform plan -var-file='./credentials.tfvars' -out project.tfplan

6. Deploy your infrastructure

With our plan created, we can now get to the task at hand of deploying infrastructure assets.

$ terraform apply project.tfplan

7. Run Ansible playbook

Run the Ansible playbook to configure your PXE server. 

$ ansible-playbook -i Hosts/inventory.env Playbooks/deploy-environment.yml

You may need to reboot the bare metal server via the Customer portal or API in order for it to pick up the new DHCP Helper IP address.

8. Log in to the NO OS Server IPMI and complete the install

Questions and issues

For any issues or questions, please visit the GitHub repositories issues page.

Was this article helpful?
YesNo

More from Cloud

Announcing Dizzion Desktop as a Service for IBM Virtual Private Cloud (VPC)

2 min read - For more than four years, Dizzion and IBM Cloud® have strategically partnered to deliver incredible digital workspace experiences to our clients. We are excited to announce that Dizzion has expanded their Desktop as a Service (DaaS) offering to now support IBM Cloud Virtual Private Cloud (VPC). Powered by Frame, Dizzion’s cloud-native DaaS platform, clients can now deploy their Windows and Linux® virtual desktops and applications on IBM Cloud VPC and enjoy fast, dynamic, infrastructure provisioning and a true consumption-based model.…

Microcontrollers vs. microprocessors: What’s the difference?

6 min read - Microcontroller units (MCUs) and microprocessor units (MPUs) are two kinds of integrated circuits that, while similar in certain ways, are very different in many others. Replacing antiquated multi-component central processing units (CPUs) with separate logic units, these single-chip processors are both extremely valuable in the continued development of computing technology. However, microcontrollers and microprocessors differ significantly in component structure, chip architecture, performance capabilities and application. The key difference between these two units is that microcontrollers combine all the necessary elements…

Seven top central processing unit (CPU) use cases

7 min read - The central processing unit (CPU) is the computer’s brain, assigning and processing tasks and managing essential operational functions. Computers have been so seamlessly integrated with modern life that sometimes we’re not even aware of how many CPUs are in use around the world. It’s a staggering amount—so many CPUs that a conclusive figure can only be approximated. How many CPUs are now in use? It’s been estimated that there may be as many as 200 billion CPU cores (or more)…

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.
Subscribe now More newsletters