From b3cf41af6ff76dffdf797ade06eee838b56b6492 Mon Sep 17 00:00:00 2001 From: uk-bolly <69214557+uk-bolly@users.noreply.github.com> Date: Wed, 27 Jul 2022 11:30:09 +0100 Subject: [PATCH 01/15] changed to local file lookup --- .github/workflows/main.tf | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.tf b/.github/workflows/main.tf index b284d24..555f23d 100644 --- a/.github/workflows/main.tf +++ b/.github/workflows/main.tf @@ -3,6 +3,11 @@ provider "aws" { region = var.aws_region } +// Read local file not created via terraform +data "local_file" "github_actions" { + filename = "${path.module}/${var.private_key}" +} + // Create a security group with access to port 22 and port 80 open to serve HTTP traffic data "aws_vpc" "default" { @@ -66,7 +71,7 @@ resource "aws_instance" "testing_vm" { # The default username for our AMI user = var.ami_username # Private key for connection - private_key = file(".ssh/github_actions.pem") + private_key = data.local_file.github_actions.content # Type of connection type = "ssh" } From d050db7fa9916c73a27b1bc006e62c489a6a053d Mon Sep 17 00:00:00 2001 From: uk-bolly <69214557+uk-bolly@users.noreply.github.com> Date: Wed, 27 Jul 2022 11:45:08 +0100 Subject: [PATCH 02/15] sync main.tf --- .github/workflows/main.tf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.tf b/.github/workflows/main.tf index 555f23d..d322cda 100644 --- a/.github/workflows/main.tf +++ b/.github/workflows/main.tf @@ -64,7 +64,7 @@ resource "aws_instance" "testing_vm" { root_block_device { delete_on_termination = true } - # SSH into instance - will ensure server is up before next step in workflows + # SSH into instance - will ensure server is up before next step in workflows connection { # Host name host = self.public_ip @@ -101,4 +101,3 @@ resource "local_file" "inventory" { audit_git_version: devel EOF } - From a83d96f4d4002af2eaa2cde9dedd64f337ffaff1 Mon Sep 17 00:00:00 2001 From: uk-bolly <69214557+uk-bolly@users.noreply.github.com> Date: Wed, 27 Jul 2022 11:58:36 +0100 Subject: [PATCH 03/15] changed private key path --- .github/workflows/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.tf b/.github/workflows/main.tf index d322cda..77966d9 100644 --- a/.github/workflows/main.tf +++ b/.github/workflows/main.tf @@ -71,7 +71,7 @@ resource "aws_instance" "testing_vm" { # The default username for our AMI user = var.ami_username # Private key for connection - private_key = data.local_file.github_actions.content + private_key = file("${path.module}/.ssh/github_actions.pem") # Type of connection type = "ssh" } From bffb3d2dc6bb439987d77a26c910649cb24fc4ac Mon Sep 17 00:00:00 2001 From: uk-bolly <69214557+uk-bolly@users.noreply.github.com> Date: Wed, 27 Jul 2022 16:49:06 +0100 Subject: [PATCH 04/15] aligned with new process removed debug --- .github/workflows/linux_benchmark_testing.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linux_benchmark_testing.yml b/.github/workflows/linux_benchmark_testing.yml index 08b0217..b35264f 100644 --- a/.github/workflows/linux_benchmark_testing.yml +++ b/.github/workflows/linux_benchmark_testing.yml @@ -38,7 +38,7 @@ jobs: runs-on: ubuntu-latest env: - ENABLE_DEBUG: true + ENABLE_DEBUG: false # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -58,6 +58,7 @@ jobs: chmod 700 .ssh echo $PRIVATE_KEY > .ssh/github_actions.pem chmod 600 .ssh/github_actions.pem + file .ssh/github_actions.pem && cat .ssh/github_actions.pem ### Build out the server - name: Terraform_Init @@ -67,12 +68,12 @@ jobs: - name: Terraform_Validate working-directory: .github/workflows run: terraform validate - - - name: validate path contents + + - name: Validate path contents if: env.ENABLE_DEBUG == 'true' working-directory: .github/workflows run: pwd && ls -laR - + - name: Terraform_Apply working-directory: .github/workflows env: From 9d91c2cba2b0c211a048aa8ef8bc9b377a56db60 Mon Sep 17 00:00:00 2001 From: uk-bolly <69214557+uk-bolly@users.noreply.github.com> Date: Wed, 27 Jul 2022 16:50:17 +0100 Subject: [PATCH 05/15] alignment --- .github/workflows/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.tf b/.github/workflows/main.tf index 77966d9..d322cda 100644 --- a/.github/workflows/main.tf +++ b/.github/workflows/main.tf @@ -71,7 +71,7 @@ resource "aws_instance" "testing_vm" { # The default username for our AMI user = var.ami_username # Private key for connection - private_key = file("${path.module}/.ssh/github_actions.pem") + private_key = data.local_file.github_actions.content # Type of connection type = "ssh" } From 0747cc978ab7259283d91bc29712f7b8989d1b27 Mon Sep 17 00:00:00 2001 From: uk-bolly <69214557+uk-bolly@users.noreply.github.com> Date: Thu, 28 Jul 2022 21:14:07 +0100 Subject: [PATCH 06/15] Update linux_benchmark_testing.yml turned off ready check --- .github/workflows/linux_benchmark_testing.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/linux_benchmark_testing.yml b/.github/workflows/linux_benchmark_testing.yml index b35264f..5f9f17f 100644 --- a/.github/workflows/linux_benchmark_testing.yml +++ b/.github/workflows/linux_benchmark_testing.yml @@ -89,11 +89,11 @@ jobs: # Ensure system is up for connections before continuing - - name: Check system is up and running - working-directory: .github/workflows - id: test_os - run: >- - ansible all -i hosts.yml -m wait_for -a "port=22 delay=10 timeout=600" --private-key=.ssh/github_actions.pem -u ec2-user -vvv + # - name: Check system is up and running + # working-directory: .github/workflows + # id: test_os + # run: >- + # ansible all -i hosts.yml -m wait_for -a "port=22 delay=10 timeout=600" --private-key=.ssh/github_actions.pem -u ec2-user -vvv # Run the ansible playbook - name: Run_Ansible_Playbook From 4e2fd296b68ada8da4de7182e8040522d45ca135 Mon Sep 17 00:00:00 2001 From: uk-bolly <69214557+uk-bolly@users.noreply.github.com> Date: Fri, 29 Jul 2022 09:50:06 +0100 Subject: [PATCH 07/15] Changed way key is loaded --- .github/workflows/linux_benchmark_testing.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/linux_benchmark_testing.yml b/.github/workflows/linux_benchmark_testing.yml index 5f9f17f..175b3e6 100644 --- a/.github/workflows/linux_benchmark_testing.yml +++ b/.github/workflows/linux_benchmark_testing.yml @@ -89,11 +89,12 @@ jobs: # Ensure system is up for connections before continuing - # - name: Check system is up and running - # working-directory: .github/workflows - # id: test_os - # run: >- - # ansible all -i hosts.yml -m wait_for -a "port=22 delay=10 timeout=600" --private-key=.ssh/github_actions.pem -u ec2-user -vvv + - name: Check system is up and running + working-directory: .github/workflows + env: + PRIVATE_KEY: "${{ secrets.SSH_PRV_KEY }}" + id: test_os + run: ansible all -i hosts.yml -m wait_for -a "port=22 delay=10 timeout=600" --private-key=.ssh/github_actions.pem -u ec2-user -e ansible_ssh_private_key_file='{{ lookup("env", "PRIVATE_KEY") # Run the ansible playbook - name: Run_Ansible_Playbook From 4f325c435d9fab2a2dd13c586ecade372d1bba03 Mon Sep 17 00:00:00 2001 From: uk-bolly <69214557+uk-bolly@users.noreply.github.com> Date: Fri, 29 Jul 2022 09:57:08 +0100 Subject: [PATCH 08/15] fix darn typo --- .github/workflows/linux_benchmark_testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux_benchmark_testing.yml b/.github/workflows/linux_benchmark_testing.yml index 175b3e6..594783d 100644 --- a/.github/workflows/linux_benchmark_testing.yml +++ b/.github/workflows/linux_benchmark_testing.yml @@ -94,7 +94,7 @@ jobs: env: PRIVATE_KEY: "${{ secrets.SSH_PRV_KEY }}" id: test_os - run: ansible all -i hosts.yml -m wait_for -a "port=22 delay=10 timeout=600" --private-key=.ssh/github_actions.pem -u ec2-user -e ansible_ssh_private_key_file='{{ lookup("env", "PRIVATE_KEY") + run: ansible all -i hosts.yml -m wait_for -a "port=22 delay=10 timeout=600" --private-key=.ssh/github_actions.pem -u ec2-user -e ansible_ssh_private_key_file='{{ lookup("env", "PRIVATE_KEY") }}' # Run the ansible playbook - name: Run_Ansible_Playbook From 07710c09b7f51f4f4c5dae9918c16d9722bb244c Mon Sep 17 00:00:00 2001 From: uk-bolly <69214557+uk-bolly@users.noreply.github.com> Date: Fri, 29 Jul 2022 10:01:54 +0100 Subject: [PATCH 09/15] testing --- .github/workflows/linux_benchmark_testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux_benchmark_testing.yml b/.github/workflows/linux_benchmark_testing.yml index 594783d..6d9e11a 100644 --- a/.github/workflows/linux_benchmark_testing.yml +++ b/.github/workflows/linux_benchmark_testing.yml @@ -94,7 +94,7 @@ jobs: env: PRIVATE_KEY: "${{ secrets.SSH_PRV_KEY }}" id: test_os - run: ansible all -i hosts.yml -m wait_for -a "port=22 delay=10 timeout=600" --private-key=.ssh/github_actions.pem -u ec2-user -e ansible_ssh_private_key_file='{{ lookup("env", "PRIVATE_KEY") }}' + run: ansible all -i hosts.yml -m wait_for -a "port=22 delay=10 timeout=600" -u ec2-user -e ansible_ssh_private_key_file='{{ lookup("env", "PRIVATE_KEY") }}' # Run the ansible playbook - name: Run_Ansible_Playbook From d6f60ffba406b1d597ab9aad9e8a05c951ec96db Mon Sep 17 00:00:00 2001 From: uk-bolly <69214557+uk-bolly@users.noreply.github.com> Date: Fri, 29 Jul 2022 10:04:49 +0100 Subject: [PATCH 10/15] testing --- .github/workflows/linux_benchmark_testing.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/linux_benchmark_testing.yml b/.github/workflows/linux_benchmark_testing.yml index 6d9e11a..f745e77 100644 --- a/.github/workflows/linux_benchmark_testing.yml +++ b/.github/workflows/linux_benchmark_testing.yml @@ -89,12 +89,12 @@ jobs: # Ensure system is up for connections before continuing - - name: Check system is up and running - working-directory: .github/workflows - env: - PRIVATE_KEY: "${{ secrets.SSH_PRV_KEY }}" - id: test_os - run: ansible all -i hosts.yml -m wait_for -a "port=22 delay=10 timeout=600" -u ec2-user -e ansible_ssh_private_key_file='{{ lookup("env", "PRIVATE_KEY") }}' +# - name: Check system is up and running +# working-directory: .github/workflows +# env: +# PRIVATE_KEY: "${{ secrets.SSH_PRV_KEY }}" +# id: test_os +# run: ansible all -i hosts.yml -m wait_for -a "port=22 delay=10 timeout=600" -u ec2-user -e ansible_ssh_private_key_file='{{ lookup("env", "PRIVATE_KEY") }}' # Run the ansible playbook - name: Run_Ansible_Playbook From 6171400d1705eca8fd3bf314ca0d11b3727dcda3 Mon Sep 17 00:00:00 2001 From: uk-bolly <69214557+uk-bolly@users.noreply.github.com> Date: Fri, 29 Jul 2022 10:21:16 +0100 Subject: [PATCH 11/15] revert --- .github/workflows/main.tf | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/.github/workflows/main.tf b/.github/workflows/main.tf index d322cda..b231d2a 100644 --- a/.github/workflows/main.tf +++ b/.github/workflows/main.tf @@ -3,11 +3,6 @@ provider "aws" { region = var.aws_region } -// Read local file not created via terraform -data "local_file" "github_actions" { - filename = "${path.module}/${var.private_key}" -} - // Create a security group with access to port 22 and port 80 open to serve HTTP traffic data "aws_vpc" "default" { @@ -64,22 +59,6 @@ resource "aws_instance" "testing_vm" { root_block_device { delete_on_termination = true } - # SSH into instance - will ensure server is up before next step in workflows - connection { - # Host name - host = self.public_ip - # The default username for our AMI - user = var.ami_username - # Private key for connection - private_key = data.local_file.github_actions.content - # Type of connection - type = "ssh" - } - provisioner "remote-exec" { - inline = [ - "echo 'hello_world'", - ] - } } // generate inventory file From 7fed2bcbc9bdad1fd6cc265fa161bab7bd316d53 Mon Sep 17 00:00:00 2001 From: uk-bolly <69214557+uk-bolly@users.noreply.github.com> Date: Fri, 29 Jul 2022 10:22:08 +0100 Subject: [PATCH 12/15] revert --- .github/workflows/linux_benchmark_testing.yml | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/linux_benchmark_testing.yml b/.github/workflows/linux_benchmark_testing.yml index f745e77..3c4cf3f 100644 --- a/.github/workflows/linux_benchmark_testing.yml +++ b/.github/workflows/linux_benchmark_testing.yml @@ -58,7 +58,6 @@ jobs: chmod 700 .ssh echo $PRIVATE_KEY > .ssh/github_actions.pem chmod 600 .ssh/github_actions.pem - file .ssh/github_actions.pem && cat .ssh/github_actions.pem ### Build out the server - name: Terraform_Init @@ -69,11 +68,6 @@ jobs: working-directory: .github/workflows run: terraform validate - - name: Validate path contents - if: env.ENABLE_DEBUG == 'true' - working-directory: .github/workflows - run: pwd && ls -laR - - name: Terraform_Apply working-directory: .github/workflows env: @@ -87,14 +81,20 @@ jobs: working-directory: .github/workflows run: cat hosts.yml -# Ensure system is up for connections before continuing +# Centos 7 images take a while to come up insert sleep or playbook fails -# - name: Check system is up and running -# working-directory: .github/workflows -# env: -# PRIVATE_KEY: "${{ secrets.SSH_PRV_KEY }}" -# id: test_os -# run: ansible all -i hosts.yml -m wait_for -a "port=22 delay=10 timeout=600" -u ec2-user -e ansible_ssh_private_key_file='{{ lookup("env", "PRIVATE_KEY") }}' + - name: Check if test os is rhel7 + working-directory: .github/workflows + id: test_os + run: >- + echo "::set-output name=RHEL7::$( + grep -c RHEL7 OS.tfvars + )" + + - name: if RHEL7 - Sleep for 60 seconds + if: steps.test_os.outputs.RHEL7 >= 1 + run: sleep 60s + shell: bash # Run the ansible playbook - name: Run_Ansible_Playbook From 3ae56ddd232fa83527b8d893db73492b41077680 Mon Sep 17 00:00:00 2001 From: uk-bolly <69214557+uk-bolly@users.noreply.github.com> Date: Fri, 29 Jul 2022 10:45:52 +0100 Subject: [PATCH 13/15] updated image name --- .github/workflows/OS.tfvars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/OS.tfvars b/.github/workflows/OS.tfvars index 5baddfc..96c19c4 100644 --- a/.github/workflows/OS.tfvars +++ b/.github/workflows/OS.tfvars @@ -1,5 +1,5 @@ #Ami Rocky 85 -ami_id = "ami-0c41531b8d18cc72b" +ami_id = "ami-02881bd671eb4ac61" ami_os = "rhel9" ami_username = "ec2-user" ami_user_home = "/home/ec2-user" From 5f4b38a8b3af425925e6c6e1776a6bf9106f814f Mon Sep 17 00:00:00 2001 From: uk-bolly <69214557+uk-bolly@users.noreply.github.com> Date: Fri, 29 Jul 2022 10:47:05 +0100 Subject: [PATCH 14/15] updated comment --- .github/workflows/OS.tfvars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/OS.tfvars b/.github/workflows/OS.tfvars index 96c19c4..a5e2fda 100644 --- a/.github/workflows/OS.tfvars +++ b/.github/workflows/OS.tfvars @@ -1,4 +1,4 @@ -#Ami Rocky 85 +#Ami Alma 9 ami_id = "ami-02881bd671eb4ac61" ami_os = "rhel9" ami_username = "ec2-user" From f76919734eb155cbfc2b6e5b68c5a84dd71f631a Mon Sep 17 00:00:00 2001 From: uk-bolly <69214557+uk-bolly@users.noreply.github.com> Date: Fri, 29 Jul 2022 11:16:31 +0100 Subject: [PATCH 15/15] sleep anyway --- .github/workflows/linux_benchmark_testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux_benchmark_testing.yml b/.github/workflows/linux_benchmark_testing.yml index 3c4cf3f..f802b4c 100644 --- a/.github/workflows/linux_benchmark_testing.yml +++ b/.github/workflows/linux_benchmark_testing.yml @@ -92,7 +92,7 @@ jobs: )" - name: if RHEL7 - Sleep for 60 seconds - if: steps.test_os.outputs.RHEL7 >= 1 + #if: steps.test_os.outputs.RHEL7 >= 1 run: sleep 60s shell: bash