Skip to content

Commit

Permalink
Update CI to reference JOBID
Browse files Browse the repository at this point in the history
  • Loading branch information
Daemonslayer2048 committed Jan 10, 2025
1 parent 38caa8d commit 7ff796d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/reusable_integration_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
id: plan
run: |
cd testing/
terraform plan -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -var "os=${{ inputs.os }}" -no-color
terraform plan -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -var "GITHUB_JOB_ID=$GITHUB_JOB" -var "os=${{ inputs.os }}" -no-color
continue-on-error: true
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand All @@ -88,7 +88,7 @@ jobs:
- name: Terraform Apply
run: |
cd testing/
terraform apply -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -var "os=${{ inputs.os }}" -auto-approve
terraform apply -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -var "GITHUB_JOB_ID=$GITHUB_JOB" -var "os=${{ inputs.os }}" -auto-approve
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand All @@ -97,8 +97,8 @@ jobs:
- name: Create inventory
run: |
mkdir ./${{ inputs.os }}
export RKE2_SERVER=$(aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=Server" "Name=tag:github_run,Values=$GITHUB_RUN_ID" --query "Reservations[*].Instances[*].PublicIpAddress" --output text | head -1)
export RKE2_AGENT=$(aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=Agent" "Name=tag:github_run,Values=$GITHUB_RUN_ID" --query "Reservations[*].Instances[*].PublicIpAddress" --output text | head -1)
export RKE2_SERVER=$(aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=Server" "Name=tag:github_run,Values=$GITHUB_RUN_ID" "Name=tag:github_job,Values=$GITHUB_JOB_ID" --query "Reservations[*].Instances[*].PublicIpAddress" --output text | head -1)
export RKE2_AGENT=$(aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=Agent" "Name=tag:github_run,Values=$GITHUB_RUN_ID" "Name=tag:github_job,Values=$GITHUB_JOB_ID" --query "Reservations[*].Instances[*].PublicIpAddress" --output text | head -1)
yq --null-input '.rke2_cluster.children.rke2_servers.hosts.master-01.ansible_host = strenv(RKE2_SERVER)' > ./${{ inputs.os }}/hosts.yml
yq -i '.all.vars.rke2_kubernetes_api_server_host = strenv(RKE2_SERVER)' ./${{ inputs.os }}/hosts.yml
yq -i '.rke2_cluster.children.rke2_agents.hosts.worker-01.ansible_host = strenv(RKE2_AGENT)' ./${{ inputs.os }}/hosts.yml
Expand Down Expand Up @@ -134,7 +134,7 @@ jobs:
- name: Update inventory hosts.yml with added host
run: |
export RKE2_AGENT2=$(aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=ExtraNode" "Name=tag:github_run,Values=$GITHUB_RUN_ID" --query "Reservations[*].Instances[*].PublicIpAddress" --output text | head -1)
export RKE2_AGENT2=$(aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=ExtraNode" "Name=tag:github_run,Values=$GITHUB_RUN_ID" "Name=tag:github_job,Values=$GITHUB_JOB_ID --query "Reservations[*].Instances[*].PublicIpAddress" --output text | head -1)
yq -i '.rke2_cluster.children.rke2_agents.hosts.worker-02.ansible_host = strenv(RKE2_AGENT2)' ./${{ inputs.os }}/hosts.yml
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down Expand Up @@ -164,7 +164,7 @@ jobs:
if: ${{ always() }}
run: |
cd testing/
terraform destroy -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -auto-approve
terraform destroy -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -var "GITHUB_JOB_ID=$GITHUB_JOB" -auto-approve
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rocky.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ jobs:
"_9_":
uses: ./.github/workflows/reusable_integration_testing.yml
with:
os: rocky8
os: rocky9
ssh_user: centos
secrets: inherit
12 changes: 8 additions & 4 deletions testing/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ provider "aws" {
### SECURITY GROUPS
###
resource "aws_security_group" "allow-all" {
name = "${var.tf_user}-allow-all-${var.GITHUB_RUN_ID}"
name = "${var.tf_user}-allow-all-${var.GITHUB_RUN_ID}-${var.GITHUB_JOB_ID}"
vpc_id = "vpc-07402b459d3b18976"

ingress {
Expand All @@ -30,6 +30,7 @@ resource "aws_security_group" "allow-all" {
Name = "allow-all"
Owner = var.tf_user
github_run = "${var.GITHUB_RUN_ID}"
github_job = "${var.GITHUB_JOB_ID}"
}
}

Expand All @@ -52,10 +53,11 @@ resource "aws_instance" "control_node" {
vpc_security_group_ids = [aws_security_group.allow-all.id]

tags = {
Name = "rke2_ansible-testing-server-${var.os}-${var.GITHUB_RUN_ID}-${count.index}"
Name = "rke2_ansible-testing-server-${var.os}-${var.GITHUB_RUN_ID}-${var.GITHUB_JOB_ID}-${count.index}"
Owner = var.tf_user
NodeType = "Server"
github_run = "${var.GITHUB_RUN_ID}"
github_job = "${var.GITHUB_JOB_ID}"
}

provisioner "remote-exec" {
Expand Down Expand Up @@ -89,10 +91,11 @@ resource "aws_instance" "worker_node" {
}

tags = {
Name = "rke2_ansible-testing-agent-${var.os}-${var.GITHUB_RUN_ID}-${count.index}"
Name = "rke2_ansible-testing-agent-${var.os}-${var.GITHUB_RUN_ID}-${var.GITHUB_JOB_ID}-${count.index}"
Owner = var.tf_user
NodeType = "Agent"
github_run = "${var.GITHUB_RUN_ID}"
github_job = "${var.GITHUB_JOB_ID}"
}

provisioner "remote-exec" {
Expand Down Expand Up @@ -126,10 +129,11 @@ resource "aws_instance" "extra_worker_node" {
}

tags = {
Name = "rke2_ansible-testing-agent-idempotency-${var.os}-${var.GITHUB_RUN_ID}-${count.index}"
Name = "rke2_ansible-testing-agent-idempotency-${var.os}-${var.GITHUB_RUN_ID}-${var.GITHUB_JOB_ID}-${count.index}"
Owner = var.tf_user
NodeType = "ExtraNode"
github_run = "${var.GITHUB_RUN_ID}"
github_job = "${var.GITHUB_JOB_ID}"
}

provisioner "remote-exec" {
Expand Down
1 change: 1 addition & 0 deletions testing/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,4 @@ variable "ansible_user" {
}

variable "GITHUB_RUN_ID" {}
variable "GITHUB_JOB_ID" {}

0 comments on commit 7ff796d

Please sign in to comment.