Here is a 500-word blog post based on the information provided:
—
Building a New Centos7 Template with Packer and Code Stream
In this post, we will detail a simple Code Stream pipeline that builds a new Centos7 template using Packer. We will also cover how to configure Packer to create templates for your lab environment.
To begin, we will make a few assumptions:
* You have a basic understanding of Packer and Code Stream.
* You have the necessary tools installed on your system, including Docker and Git.
* You have a GitHub repository containing the Packer build definition and kickstart file for the Centos7 build.
To get started, we will need to download Packer and create a new pipeline in Code Stream. We can do this by following these steps:
1. Open Code Stream and click on the “New Pipeline” button.
2. Give your pipeline a name and select “Docker” as the runtime.
3. Click on the “Inputs” tab and add three input parameters: GIT_REPOSITORY_PATH, PACKER_FILE, and PACKER_URI. These inputs will be used to configure Packer and obtain the necessary files for the build process.
4. Click on the “Configure Workspace” button and select the Docker radio option for the Auto inject parameters parameter. This will ensure that the input parameters we configure are injected into our Docker container when our pipeline executes.
5. Save your pipeline configuration.
Next, we will need to provide default values for our input parameters. To do this, we can add three variables to obfuscate the values that our pipeline will use:
1. SECRETYour projectssh_password (the password that will be used to SSH into your Centos7 VM)
2. SECRETYour projectvcenter_password (the password for your adminstrator@vsphere.local account)
3. SECRETYour projectGithub Access Token (the access token generated on Github)
We can add these variables by clicking the “New Variable” button in the Configuration section and adding the details below:
Type: Project Name
Value: Your projectssh_password
Type: Project Name
Value: Your projectvcenter_password
Type: Project Name
Value: Your projectGithub Access Token
Once we have configured our pipeline and variables, we can move on to the next stage. We will create a new stage for each task, grouping related tasks together to achieve our end goal of building a new Centos7 template.
The main purpose of this task is to download and unzip Packer using a new variable. We will add some bash code to download Packer using a new variable. This task is very straightforward.
Next, we will create a new stage for the Packer validate switch. This stage will carry out our instructions and ultimately generate our new VM template. Before this, we will carry out a find and replace function to insert the root password into the Centos7 kickstart file. We will also download and add a package into our Docker container, xorriso. This package allows Packer to create our kickstart ISO file on the fly.
You should now be in a position to execute your pipeline and build your first template. Congratulations! In future posts, I will look to improve on this process.
Footnote: Image attribution on this post: Design vector created by macrovector. Tags: automation, build, cloud, code, codestream, hashicorp, icosa, packer, vra8, paul_davey. CIO at Sonar, Automation Practice Lead at Xtravirt and guitarist in The Waders. Loves IT, automation, programming, music. Copyright AutomationPro 2018.