<img height="1" width="1" style="display:none;" alt="" src="https://px.ads.linkedin.com/collect/?pid=299788&amp;fmt=gif">

Manifest Post Procesor: The Missing Manifest

Technology, Data Center

We here at Isos are big fans of Ansible and HashiCorp Packer. We use these tools (among others) to build pipelines that create custom images (including AMIs) for many of our Data Center implementations. During this build process, we used to use the machine-readable option in order to extract the image ID (such as the AMI ID in AWS) and use it in the next build step (typically executing some infrastructure as code such as CloudFormation). This method certainly works, but doesn't always lend itself to having an artifact that tracks the AMI ID after the build process.

Then I discovered the "missing" manifest. It wasn't so much missing, instead being not an option I hadn't come across. Adding the manifest post processor to your JSON file will create another JSON file with the output of the Packer execution in it.

Here are some examples from a recent Jira Data Center AMI creation process:

 

Adding to the Existing Packer JSON

You'll need to add a post processor similar to this:

"post-processors": [
{
"type": "manifest",
"output": "jira-manifest.json",
"strip_path": <b>true</b>
}

 

What to Expect After Executing Packer

You'll get a file called jira-manifest.json (using the above example code) with contents such as this:

{
"builds": [
{
"name": "amazon-ebs",
"builder_type": "amazon-ebs",
"build_time": 1554580597,
"files": <b>null</b>,
"artifact_id": "us-east-1:ami-082079600550f7cd6",
"packer_run_uuid": "5379de7a-fa4c-9eb9-45b9-7f715e8e1463"
}
],
"last_run_uuid": "5379de7a-fa4c-9eb9-45b9-7f715e8e1463"
}

 

What to Do Next

From here you have a JSON file with AMI ID and you can parse it however you see fit. One way is to parse it using jq and some quick clean up, such as:

cat jira-manifest.json | jq '.builds[0].artifact_id' | tr -d '"' | awk 'match($0, /ami-.*/) { print substr($0, RSTART, RLENGTH) }'

Expected output: ami-082079600550f7cd6

From there, you can continue your automated build process by standing up your newly created AMI with a CloudFormation template and the rest of your Data Center infrastructure.

Happy building!

 

Managing JIRA at Scale White Paper

TAGS: Technology, Data Center

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Subscribe to Our Newsletter

Recent Blog Posts