Skip to content

Commit

Permalink
testing using packer build ami
Browse files Browse the repository at this point in the history
  • Loading branch information
star3am committed Nov 9, 2023
1 parent 2d3e1cf commit 89e8808
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 49 deletions.
96 changes: 49 additions & 47 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ env:
TF_CLOUD_ORGANIZATION: "nolan"
TF_API_TOKEN: "${{ secrets.TF_API_TOKEN }}"
TF_WORKSPACE: "golden-image-builder"
TF_MAX_TIMEOUT: "1h"
CONFIG_DIRECTORY: "./"

jobs:
Expand Down Expand Up @@ -183,8 +184,8 @@ jobs:
run: ${{ steps.create-run.outputs.run_id }}
comment: "Confirmed from GitHub Actions CI"

awx-ansible-tower:
needs: azure-image-gallery
packer-build:
needs: awx-ansible-tower-on-tfc
if: |
always() &&
(needs.run-run-dot-sh.result == 'success' || needs.run-run-dot-sh.result == 'skipped') &&
Expand All @@ -194,6 +195,49 @@ jobs:
image: ghcr.io/${{ github.repository_owner }}/golden-image-builder-container:latest
options: --user 1001

steps:
# Checking out the repo
- uses: actions/checkout@v3

- name: Ansible version
run: ansible --version

- name: Ansible Galaxy install roles
run: ansible-galaxy install -f -r ansible/roles/requirements.yml -p ansible/roles/

- name: Packer version
run: packer -v

- name: Packer init
run: packer init -upgrade packer/all

- name: Packer build
# https://developer.hashicorp.com/packer/docs/templates/hcl_templates/onlyexcept
run: packer build -force -only='amazon-ebs.ubuntu-2204' packer/all
# run: packer build -force -except='vagrant.*' packer/all
# run: PACKER_LOG=1 packer build -debug -force -only='googlecompute.ubuntu-2204' packer/all
env:
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}

awx-ansible-tower:
needs: packer-build
if: |
always() &&
(needs.run-run-dot-sh.result == 'success' || needs.run-run-dot-sh.result == 'skipped') &&
(needs.packer-build.result == 'success' || needs.packer-build.result == 'skipped')
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository_owner }}/golden-image-builder-container:latest
options: --user 1001

steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -229,11 +273,11 @@ jobs:
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}

awx-ansible-tower-on-tfc:
needs: azure-image-gallery-on-tfc
needs: packer-build
if: |
always() &&
(needs.run-run-dot-sh.result == 'success' || needs.run-run-dot-sh.result == 'skipped') &&
(needs.azure-image-gallery.result == 'success' || needs.azure-image-gallery.result == 'skipped' || needs.azure-image-gallery-on-tfc.result == 'success' || needs.azure-image-gallery-on-tfc.result == 'skipped')
(needs.packer-build.result == 'success' || needs.packer-build.result == 'skipped')
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository_owner }}/golden-image-builder-container:latest
Expand Down Expand Up @@ -292,49 +336,7 @@ jobs:
- name: Apply Run
uses: hashicorp/tfc-workflows-github/actions/[email protected]
id: apply
continue-on-error: true
with:
run: ${{ steps.create-run.outputs.run_id }}
comment: "Confirmed from GitHub Actions CI"

packer-build:
needs: awx-ansible-tower-on-tfc
if: |
always() &&
(needs.run-run-dot-sh.result == 'success' || needs.run-run-dot-sh.result == 'skipped') &&
(needs.azure-image-gallery.result == 'success' || needs.azure-image-gallery.result == 'skipped' || needs.azure-image-gallery-on-tfc.result == 'success' || needs.azure-image-gallery-on-tfc.result == 'skipped')
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository_owner }}/golden-image-builder-container:latest
options: --user 1001

steps:
# Checking out the repo
- uses: actions/checkout@v3

- name: Ansible version
run: ansible --version

- name: Ansible Galaxy install roles
run: ansible-galaxy install -f -r ansible/roles/requirements.yml -p ansible/roles/

- name: Packer version
run: packer -v

- name: Packer init
run: packer init -upgrade packer/all

- name: Packer build
# https://developer.hashicorp.com/packer/docs/templates/hcl_templates/onlyexcept
run: packer build -force -only='amazon-ebs.ubuntu-2204' packer/all
# run: packer build -force -except='vagrant.*' packer/all
# run: PACKER_LOG=1 packer build -debug -force -only='googlecompute.ubuntu-2204' packer/all
env:
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }}
4 changes: 3 additions & 1 deletion terraform/awx-ansible-tower-instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ provider "azurerm" {
provider "google" {}

module "aws_hashiqube" {
source = "star3am/hashiqube/hashicorp"
# source = "star3am/hashiqube/hashicorp"
source = "[email protected]:star3am/terraform-hashicorp-hashiqube.git?ref=riaan"
deploy_to_aws = true
aws_instance_type = "t2.large"
use_packer_image = true
deploy_to_azure = false
deploy_to_gcp = false
debug_user_data = true
Expand Down
2 changes: 1 addition & 1 deletion variables.auto.pkrvars.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# constraints documentation
# https://www.packer.io/docs/templates/hcl_templates/variables#type-constraints for more info.

skip_create_image = true
skip_create_image = false
build_directory = "./output"
cpus = "2"
memory = "512"
Expand Down

0 comments on commit 89e8808

Please sign in to comment.