Skip to content

Commit

Permalink
Fix inventory and add ssh_user
Browse files Browse the repository at this point in the history
  • Loading branch information
Daemonslayer2048 committed Jan 10, 2025
1 parent a4dcbb9 commit 67d0863
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/reusable_integration_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
os:
required: true
type: string
ssh_user:
required: true
type: string

jobs:

Expand Down Expand Up @@ -98,8 +101,8 @@ jobs:
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)
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_SERVER)' ./${{ inputs.os }}/hosts.yml
echo "remote_user=centos" >> ansible.cfg
yq -i '.rke2_cluster.children.rke2_agents.hosts.worker-01.ansible_host = strenv(RKE2_AGENT)' ./${{ inputs.os }}/hosts.yml
echo "remote_user=${{ inputs.ssh_user }}" >> ansible.cfg
echo "private_key_file=.key" >> ansible.cfg
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand All @@ -113,15 +116,15 @@ jobs:
- name: Run playbook
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ./${{ inputs.os }}/hosts.yml -u centos -vv --private-key .key site.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ./${{ inputs.os }}/hosts.yml -u ${{ inputs.ssh_user }} -vv --private-key .key site.yml
- name: Run playbook again for idempotency
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ./${{ inputs.os }}/hosts.yml -u centos -vv --private-key .key site.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ./${{ inputs.os }}/hosts.yml -u ${{ inputs.ssh_user }} -vv --private-key .key site.yml
- name: Run Ansible Tests
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ./${{ inputs.os }}/hosts.yml -u centos --verbose --skip-tags "troubleshooting" --private-key .key testing.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ./${{ inputs.os }}/hosts.yml -u ${{ inputs.ssh_user }} --verbose --skip-tags "troubleshooting" --private-key .key testing.yml
- name: Run Python Tests
run: |
Expand All @@ -140,11 +143,11 @@ jobs:

- name: Run playbook again with added host
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ./${{ inputs.os }}/hosts.yml -u centos --verbose --private-key .key site.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ./${{ inputs.os }}/hosts.yml -u ${{ inputs.ssh_user }} --verbose --private-key .key site.yml
- name: Run Ansible Tests with added host
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ./${{ inputs.os }}/hosts.yml -u centos --verbose --skip-tags "troubleshooting" --private-key .key testing.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ./${{ inputs.os }}/hosts.yml -u ${{ inputs.ssh_user }} --verbose --skip-tags "troubleshooting" --private-key .key testing.yml
- name: Run Python Tests with added host
run: |
Expand All @@ -155,7 +158,7 @@ jobs:
- name: Run troubleshoot tasks
if: ${{ failure() }}
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ./${{ inputs.os }}/hosts.yml -u centos -vvv --tags "troubleshooting" --private-key .key testing.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ./${{ inputs.os }}/hosts.yml -u ${{ inputs.ssh_user }} -vvv --tags "troubleshooting" --private-key .key testing.yml
- name: Delete Stack
if: ${{ always() }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/rocky.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ jobs:
uses: ./.github/workflows/reusable_integration_testing.yml
with:
os: rocky8
ssh_user: centos
secrets: inherit

0 comments on commit 67d0863

Please sign in to comment.