diff --git a/website/source/guides/packer-on-cicd/build-image-in-cicd.html.md b/website/source/guides/packer-on-cicd/build-image-in-cicd.html.md index 29631703e..1604d91df 100644 --- a/website/source/guides/packer-on-cicd/build-image-in-cicd.html.md +++ b/website/source/guides/packer-on-cicd/build-image-in-cicd.html.md @@ -6,11 +6,22 @@ page_title: Build Images in CI/CD # Build Images in CI/CD -The following guides from our partners show how to use their services to build images with Packer. +The following guides from our partners show how to use their services to build +images with Packer. - How to Build Immutable Infrastructure with Packer and CircleCI Workflows (coming soon) - [Using Packer and Ansible to Build Immutable Infrastructure in CodeShip](https://blog.codeship.com/packer-ansible/) -The majority of the [Packer Builders](/docs/builders/index.html) can run in a container or VM, a common model used by most CI/CD services. However, the [QEMU builder](/docs/builders/qemu.html) for [KVM](https://www.linux-kvm.org/page/Main_Page) and [Xen](https://www.xenproject.org/) virtual machine images, [VirtualBox builder](/docs/builders/virtualbox.html) for OVA or OVF virtual machines and [VMWare builder](/docs/builders/vmware.html) for use with VMware products require running on a bare-metal machine. +The majority of the [Packer Builders](/docs/builders/index.html) can run in +a container or VM, a common model used by most CI/CD services. However, the +[QEMU builder](/docs/builders/qemu.html) for +[KVM](https://www.linux-kvm.org/page/Main_Page) and +[Xen](https://www.xenproject.org/) virtual machine images, [VirtualBox +builder](/docs/builders/virtualbox.html) for OVA or OVF virtual machines and +[VMWare builder](/docs/builders/vmware.html) for use with VMware products +require running on a bare-metal machine. -The [Building a VirtualBox Image with Packer in TeamCity](/guides/packer-on-cicd/building-virtualbox-image.html) guide shows how to create a VirtualBox image using TeamCity's support for running scripts on bare-metal machines. +The [Building a VirtualBox Image with Packer in +TeamCity](/guides/packer-on-cicd/building-virtualbox-image.html) guide shows +how to create a VirtualBox image using TeamCity's support for running scripts +on bare-metal machines. diff --git a/website/source/guides/packer-on-cicd/index.html.md b/website/source/guides/packer-on-cicd/index.html.md index bd10914e0..328e699c7 100644 --- a/website/source/guides/packer-on-cicd/index.html.md +++ b/website/source/guides/packer-on-cicd/index.html.md @@ -6,7 +6,11 @@ page_title: Build Immutable Infrastructure with Packer in CI/CD # Build Immutable Infrastructure with Packer in CI/CD -This guide focuses on the following workflow for building immutable infrastructure. This workflow can be manual or automated and it can be implemented with a variety of technologies. The goal of this guide is to show how this workflow can be fully automated using Packer for building images from a continuous integration/continuous deployment (CI/CD) pipeline. +This guide focuses on the following workflow for building immutable +infrastructure. This workflow can be manual or automated and it can be +implemented with a variety of technologies. The goal of this guide is to show +how this workflow can be fully automated using Packer for building images from +a continuous integration/continuous deployment (CI/CD) pipeline. 1. [Build Images using Packer in CI/CD](/guides/packer-on-cicd/build-image-in-cicd.html) 2. [Upload the new image to S3](/guides/packer-on-cicd/upload-images-to-artifact.html) for future deployment or use during development diff --git a/website/source/guides/packer-on-cicd/trigger-tfe.html.md b/website/source/guides/packer-on-cicd/trigger-tfe.html.md index 0200bd571..55d40c65b 100644 --- a/website/source/guides/packer-on-cicd/trigger-tfe.html.md +++ b/website/source/guides/packer-on-cicd/trigger-tfe.html.md @@ -6,13 +6,23 @@ page_title: Trigger Terraform Enterprise runs # Create Terraform Enterprise Runs -Once an image is built and uploaded to an artifact store, the next step is to use this new image. In some cases the image will be downloaded by the dev team and used locally in development, like is often done with VirtualBox images with Vagrant. In most other cases, the new image will be used to provision new infrastructure. +Once an image is built and uploaded to an artifact store, the next step is to +use this new image. In some cases the image will be downloaded by the dev team +and used locally in development, like is often done with VirtualBox images with +Vagrant. In most other cases, the new image will be used to provision new +infrastructure. -[Terraform](https://www.terraform.io/) is an open source tool that is ideal for provisioning new infrastructure with images generated by Packer, and [Terraform Enterprise](https://www.hashicorp.com/products/terraform/) is the best way to perform automated Terraform runs. +[Terraform](https://www.terraform.io/) is an open source tool that is ideal for +provisioning new infrastructure with images generated by Packer, and [Terraform +Enterprise](https://www.hashicorp.com/products/terraform/) is the best way to +perform automated Terraform runs. ## Create a Terraform Configuration and Workspace -The following is a sample Terraform configuration which provisions a new AWS EC2 instance. The `aws_ami_id` is a variable which will be provided when running `terraform plan` and `terraform apply`. This variable references the latest AMI generated with the Packer build in CI/CD. +The following is a sample Terraform configuration which provisions a new AWS +EC2 instance. The `aws_ami_id` is a variable which will be provided when +running `terraform plan` and `terraform apply`. This variable references the +latest AMI generated with the Packer build in CI/CD. ```hcl variable "aws_ami_id" { } @@ -27,12 +37,24 @@ resource "aws_instance" "web" { } ``` -Terraform Enterprise should have a workspace with this terraform configuration and a placeholder variable `aws_ami_id`. +Terraform Enterprise should have a workspace with this terraform configuration +and a placeholder variable `aws_ami_id`. ## Include Terraform Enterprise in Your CI Builds -Follow these steps to create a new run from CI/CD after a Packer build is complete and uploaded. +Follow these steps to create a new run from CI/CD after a Packer build is +complete and uploaded. 1. Add a new step to the CI/CD pipeline. -2. In the new step add a `curl` call to update the variables in the workspace using the [update variables API](https://www.terraform.io/docs/enterprise-beta/api/variables.html#update-variables), so that Terraform has a reference to the latest image. For the sample configuration above, the `aws_ami_id` variable should be updated to the AMI ID of the latest image. -3. In that same step, add another `curl` call to [create a new run via the API](https://www.terraform.io/docs/enterprise-beta/api/run.html#create-a-run). A run performs a plan and apply on the last configuration version created, using the variables set in the workspace. In the previous step we update the variables, so the new run can be created using the previous configuration version. +2. In the new step add a `curl` call to update the variables in the workspace + using the [update variables + API](https://www.terraform.io/docs/enterprise-beta/api/variables.html#update-variables), + so that Terraform has a reference to the latest image. For the sample + configuration above, the `aws_ami_id` variable should be updated to the AMI + ID of the latest image. +3. In that same step, add another `curl` call to [create a new run via the + API](https://www.terraform.io/docs/enterprise-beta/api/run.html#create-a-run). + A run performs a plan and apply on the last configuration version created, + using the variables set in the workspace. In the previous step we update the + variables, so the new run can be created using the previous configuration + version. diff --git a/website/source/guides/packer-on-cicd/upload-images-to-artifact.html.md b/website/source/guides/packer-on-cicd/upload-images-to-artifact.html.md index b7f034e95..9916fd871 100644 --- a/website/source/guides/packer-on-cicd/upload-images-to-artifact.html.md +++ b/website/source/guides/packer-on-cicd/upload-images-to-artifact.html.md @@ -6,21 +6,39 @@ page_title: Upload VirtualBox Image to S3 # Upload VirtualBox Image to S3 -Once the image is generated it will be used by other parts of your operations workflow. For example, it is common to build VirtualBox images with Packer to be used as base boxes in Vagrant. +Once the image is generated it will be used by other parts of your operations +workflow. For example, it is common to build VirtualBox images with Packer to +be used as base boxes in Vagrant. -The exact process for uploading images depends on the artifact store and CI system you use. TeamCity provides a [Build Artifacts](https://confluence.jetbrains.com/display/TCD9/Build+Artifact) feature which can be used to store the newly generated image. Other CI/CD services also have similar build artifacts features built in, like [Circle CI Build Artifacts](https://circleci.com/docs/2.0/artifacts/). In addition to the built in artifact stores in CI/CD tools, there are also dedicated universal artifact storage services like [Artifactory](https://confluence.jetbrains.com/display/TCD9/Build+Artifact). All of these are great options for image artifact storage. +The exact process for uploading images depends on the artifact store and CI +system you use. TeamCity provides a [Build +Artifacts](https://confluence.jetbrains.com/display/TCD9/Build+Artifact) +feature which can be used to store the newly generated image. Other CI/CD +services also have similar build artifacts features built in, like [Circle CI +Build Artifacts](https://circleci.com/docs/2.0/artifacts/). In addition to the +built in artifact stores in CI/CD tools, there are also dedicated universal +artifact storage services like +[Artifactory](https://confluence.jetbrains.com/display/TCD9/Build+Artifact). +All of these are great options for image artifact storage. The following example uses TeamCity and Amazon S3. ## Example: Uploading to S3 in a TeamCity Build -On the agent machine responsible for building images, install the [AWS Command Line Tool](https://aws.amazon.com/cli/). Since this is a one-time operation, this can be incorporated into the initial agent provisioning step when installing other dependencies. The AWS Command Line tool may require installing additional [dependencies](http://docs.aws.amazon.com/cli/latest/userguide/installing.html) prior. +On the agent machine responsible for building images, install the [AWS Command +Line Tool](https://aws.amazon.com/cli/). Since this is a one-time operation, +this can be incorporated into the initial agent provisioning step when +installing other dependencies. The AWS Command Line tool may require installing +additional +[dependencies](http://docs.aws.amazon.com/cli/latest/userguide/installing.html) +prior. ```shell pip install awscli ``` -In your build configuration in TeamCity Server, add an additional **Build Step: Command Line** and set the **Script content** field to the following: +In your build configuration in TeamCity Server, add an additional **Build Step: +Command Line** and set the **Script content** field to the following: ```shell awscli s3 cp . s3://bucket/ --exclude β€œ*” --include β€œ*.iso”