diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index e68c01c..5667c12 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -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: @@ -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') && @@ -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 @@ -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 @@ -292,49 +336,7 @@ jobs: - name: Apply Run uses: hashicorp/tfc-workflows-github/actions/apply-run@v1.0.4 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 }} diff --git a/terraform/awx-ansible-tower-instance/main.tf b/terraform/awx-ansible-tower-instance/main.tf index 735b7bd..ca25487 100644 --- a/terraform/awx-ansible-tower-instance/main.tf +++ b/terraform/awx-ansible-tower-instance/main.tf @@ -29,9 +29,11 @@ provider "azurerm" { provider "google" {} module "aws_hashiqube" { - source = "star3am/hashiqube/hashicorp" + # source = "star3am/hashiqube/hashicorp" + source = "git@github.com: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 diff --git a/variables.auto.pkrvars.hcl b/variables.auto.pkrvars.hcl index 1a581e7..85e1948 100644 --- a/variables.auto.pkrvars.hcl +++ b/variables.auto.pkrvars.hcl @@ -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"