Skip to content

Commit

Permalink
Add ability to specify TAR urls for installing RKE2 and downloading i…
Browse files Browse the repository at this point in the history
…mage tars, convert samples to using yaml based inventories
  • Loading branch information
Michael DAmato authored and Michael DAmato committed Apr 19, 2024
1 parent c8264a7 commit fd98dbc
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 124 deletions.
74 changes: 42 additions & 32 deletions .github/workflows/rocky8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,20 @@ jobs:
- name: Ansible Version check
run: ansible --version

- name: Create inventory hosts.ini
run: |
touch hosts.ini
echo "[rke2_servers]" > hosts.ini
aws ec2 describe-instances --filters "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 >> hosts.ini
echo "[rke2_agents]" >> hosts.ini
aws ec2 describe-instances --filters "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 >> hosts.ini
echo "[all:vars]" >> hosts.ini
echo "kubernetes_api_server_host=$(aws ec2 describe-instances --filters "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=Server" "Name=tag:github_run,Values=$GITHUB_RUN_ID" --query "Reservations[*].Instances[*].PrivateIpAddress" --output text | head -1)" >> hosts.ini
- name: Create inventory hosts.yml
run: |
touch hosts.yml
echo "rke2_cluster:" > hosts.yml
echo " children:" >> hosts.yml
echo " rke2_servers:" >> hosts.yml
echo " hosts:" >> hosts.yml
echo " $(aws ec2 describe-instances --filters "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):" >> hosts.yml
echo " rke2_agents:" >> hosts.yml
echo " hosts:" >> hosts.yml
echo " $(ec2 describe-instances --filters "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):" >> hosts.yml
echo "all:" >> hosts.yml
echo " vars:" >> hosts.yml
echo " kubernetes_api_server_host: $(aws ec2 describe-instances --filters "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=Server" "Name=tag:github_run,Values=$GITHUB_RUN_ID" --query "Reservations[*].Instances[*].PrivateIpAddress" --output text | head -1)" >> hosts.yml
echo "" >> ansible.cfg
echo "" >> ansible.cfg
echo "remote_user=centos" >> ansible.cfg
Expand All @@ -124,69 +129,74 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-gov-west-1

- name: Check hosts.ini and ansible.cfg
- name: Check hosts.yml and ansible.cfg
run: |
cat hosts.ini
cat hosts.yml
cat ansible.cfg
- name: Prep inventory
run: |
cp -R inventory/sample inventory/rocky8
cp hosts.ini inventory/rocky8/hosts.ini
cp hosts.yml inventory/rocky8/hosts.yml
- name: Run playbook
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.ini -u centos -vv --private-key .key site.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.yml -u centos -vv --private-key .key site.yml
- name: Run playbook again for idempotency
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.ini -u centos -vv --private-key .key site.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.yml -u centos -vv --private-key .key site.yml
- name: Run Ansible Tests
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.ini -u centos --verbose --skip-tags "troubleshooting" --private-key .key testing.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.yml -u centos --verbose --skip-tags "troubleshooting" --private-key .key testing.yml
- name: Run Python Tests
run: |
export DEFAULT_PRIVATE_KEY_FILE=.key
pytest --hosts=rke2_servers --ansible-inventory=inventory/rocky8/hosts.ini --force-ansible --connection=ansible --sudo testing/basic_server_tests.py
pytest --hosts=rke2_agents --ansible-inventory=inventory/rocky8/hosts.ini --force-ansible --connection=ansible --sudo testing/basic_agent_tests.py
pytest --hosts=rke2_servers --ansible-inventory=inventory/rocky8/hosts.yml --force-ansible --connection=ansible --sudo testing/basic_server_tests.py
pytest --hosts=rke2_agents --ansible-inventory=inventory/rocky8/hosts.yml --force-ansible --connection=ansible --sudo testing/basic_agent_tests.py
- name: Create new inventory hosts.ini with added hosts
- name: Create new inventory hosts.yml with added hosts
run: |
rm hosts.ini
touch hosts.ini
echo "[rke2_servers]" > hosts.ini
aws ec2 describe-instances --filters "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 >> hosts.ini
echo "[rke2_agents]" >> hosts.ini
aws ec2 describe-instances --filters "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 >> hosts.ini
aws ec2 describe-instances --filters "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 >> hosts.ini
echo "[all:vars]" >> hosts.ini
echo "kubernetes_api_server_host=$(aws ec2 describe-instances --filters "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=Server" "Name=tag:github_run,Values=$GITHUB_RUN_ID" --query "Reservations[*].Instances[*].PrivateIpAddress" --output text | head -1)" >> hosts.ini
cp hosts.ini inventory/rocky8/hosts.ini
touch hosts.yml
echo "rke2_cluster:" > hosts.yml
echo " children:" >> hosts.yml
echo " rke2_servers:" >> hosts.yml
echo " hosts:" >> hosts.yml
echo " $(aws ec2 describe-instances --filters "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):" >> hosts.yml
echo " rke2_agents:" >> hosts.yml
echo " hosts:" >> hosts.yml
echo " $(aws ec2 describe-instances --filters "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):" >> hosts.yml
echo " $(aws ec2 describe-instances --filters "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):" >> hosts.yml
echo "all:" >> hosts.yml
echo " vars:" >> hosts.yml
echo " kubernetes_api_server_host: $(aws ec2 describe-instances --filters "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=Server" "Name=tag:github_run,Values=$GITHUB_RUN_ID" --query "Reservations[*].Instances[*].PrivateIpAddress" --output text | head -1)" >> hosts.yml
cp hosts.yml inventory/rocky8/hosts.yml
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-gov-west-1

- name: Run playbook again with added hosts
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.ini -u centos --verbose --private-key .key site.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.yml -u centos --verbose --private-key .key site.yml
- name: Run Ansible Tests with added hosts
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.ini -u centos --verbose --skip-tags "troubleshooting" --private-key .key testing.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.yml -u centos --verbose --skip-tags "troubleshooting" --private-key .key testing.yml
- name: Run Python Tests with added hosts
run: |
export DEFAULT_PRIVATE_KEY_FILE=.key
pytest --hosts=rke2_servers --ansible-inventory=inventory/rocky8/hosts.ini --force-ansible --connection=ansible --sudo testing/basic_server_tests.py
pytest --hosts=rke2_agents --ansible-inventory=inventory/rocky8/hosts.ini --force-ansible --connection=ansible --sudo testing/basic_agent_tests.py
pytest --hosts=rke2_servers --ansible-inventory=inventory/rocky8/hosts.yml --force-ansible --connection=ansible --sudo testing/basic_server_tests.py
pytest --hosts=rke2_agents --ansible-inventory=inventory/rocky8/hosts.yml --force-ansible --connection=ansible --sudo testing/basic_agent_tests.py
- name: Run troubleshoot tasks
if: ${{ failure() }}
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.ini -u centos -vvv --tags "troubleshooting" --private-key .key testing.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/rocky8/hosts.yml -u centos -vvv --tags "troubleshooting" --private-key .key testing.yml
- name: Delete Stack
if: ${{ always() }}
Expand Down
78 changes: 44 additions & 34 deletions .github/workflows/ubuntu20.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,20 @@ jobs:
- name: Ansible Version check
run: ansible --version

- name: Create inventory hosts.ini
run: |
touch hosts.ini
echo "[rke2_servers]" > hosts.ini
aws ec2 describe-instances --filters "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 >> hosts.ini
echo "[rke2_agents]" >> hosts.ini
aws ec2 describe-instances --filters "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 >> hosts.ini
echo "[all:vars]" >> hosts.ini
echo "kubernetes_api_server_host=$(aws ec2 describe-instances --filters "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=Server" "Name=tag:github_run,Values=$GITHUB_RUN_ID" --query "Reservations[*].Instances[*].PrivateIpAddress" --output text | head -1)" >> hosts.ini
- name: Create inventory hosts.yml
run: |
touch hosts.yml
echo "rke2_cluster:" > hosts.yml
echo " children:" >> hosts.yml
echo " rke2_servers:" >> hosts.yml
echo " hosts:" >> hosts.yml
echo " $(aws ec2 describe-instances --filters "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):" >> hosts.yml
echo " rke2_agents:" >> hosts.yml
echo " hosts:" >> hosts.yml
echo " $(aws ec2 describe-instances --filters "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):" >> hosts.yml
echo "all:" >> hosts.yml
echo " vars:" >> hosts.yml
echo " kubernetes_api_server_host: $(aws ec2 describe-instances --filters "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=Server" "Name=tag:github_run,Values=$GITHUB_RUN_ID" --query "Reservations[*].Instances[*].PrivateIpAddress" --output text | head -1)" >> hosts.yml
echo "" >> ansible.cfg
echo "" >> ansible.cfg
echo "remote_user=ubuntu" >> ansible.cfg
Expand All @@ -122,64 +127,69 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-gov-west-1

- name: Check hosts.ini and ansible.cfg
- name: Check hosts.yml and ansible.cfg
run: |
cat hosts.ini
cat hosts.yml
cat ansible.cfg
- name: Prep inventory
run: |
cp -R inventory/sample inventory/ubuntu20
cp hosts.ini inventory/ubuntu20/hosts.ini
cp hosts.yml inventory/ubuntu20/hosts.yml
- name: Run playbook
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/ubuntu20/hosts.ini -u ubuntu --verbose --private-key .key site.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/ubuntu20/hosts.yml -u ubuntu --verbose --private-key .key site.yml
- name: Run playbook again for idempotency
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/ubuntu20/hosts.ini -u ubuntu --verbose --private-key .key site.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/ubuntu20/hosts.yml -u ubuntu --verbose --private-key .key site.yml
- name: Run Ansible Tests
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/ubuntu20/hosts.ini -u ubuntu --verbose --private-key .key testing.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/ubuntu20/hosts.yml -u ubuntu --verbose --private-key .key testing.yml
- name: Run Python Tests
run: |
export DEFAULT_PRIVATE_KEY_FILE=.key
pytest --hosts=rke2_servers --ansible-inventory=inventory/ubuntu20/hosts.ini --force-ansible --connection=ansible --sudo testing/basic_server_tests.py
pytest --hosts=rke2_agents --ansible-inventory=inventory/ubuntu20/hosts.ini --force-ansible --connection=ansible --sudo testing/basic_agent_tests.py
- name: Create new inventory hosts.ini with added hosts
run: |
rm hosts.ini
touch hosts.ini
echo "[rke2_servers]" > hosts.ini
aws ec2 describe-instances --filters "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 >> hosts.ini
echo "[rke2_agents]" >> hosts.ini
aws ec2 describe-instances --filters "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 >> hosts.ini
aws ec2 describe-instances --filters "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 >> hosts.ini
echo "[all:vars]" >> hosts.ini
echo "kubernetes_api_server_host=$(aws ec2 describe-instances --filters "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=Server" "Name=tag:github_run,Values=$GITHUB_RUN_ID" --query "Reservations[*].Instances[*].PrivateIpAddress" --output text | head -1)" >> hosts.ini
cp hosts.ini inventory/ubuntu20/hosts.ini
pytest --hosts=rke2_servers --ansible-inventory=inventory/ubuntu20/hosts.yml --force-ansible --connection=ansible --sudo testing/basic_server_tests.py
pytest --hosts=rke2_agents --ansible-inventory=inventory/ubuntu20/hosts.yml --force-ansible --connection=ansible --sudo testing/basic_agent_tests.py
- name: Create new inventory hosts.yml with added hosts
run: |
rm -f hosts.ini
touch hosts.yml
echo "rke2_cluster:" > hosts.yml
echo " children:" >> hosts.yml
echo " rke2_servers:" >> hosts.yml
echo " hosts:" >> hosts.yml
echo " $(aws ec2 describe-instances --filters "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):" >> hosts.yml
echo " rke2_agents:" >> hosts.yml
echo " hosts:" >> hosts.yml
echo " $(aws ec2 describe-instances --filters "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):" >> hosts.yml
echo " $(aws ec2 describe-instances --filters "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):" >> hosts.yml
echo "all:" >> hosts.yml
echo " vars:" >> hosts.yml
echo " kubernetes_api_server_host: $(aws ec2 describe-instances --filters "Name=tag:Owner,Values=rke2-ansible-github-actions" "Name=tag:NodeType,Values=Server" "Name=tag:github_run,Values=$GITHUB_RUN_ID" --query "Reservations[*].Instances[*].PrivateIpAddress" --output text | head -1)" >> hosts.yml
cp hosts.yml inventory/rocky8/hosts.yml
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-gov-west-1

- name: Run playbook again with added hosts
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/ubuntu20/hosts.ini -u ubuntu --verbose --private-key .key site.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/ubuntu20/hosts.yml -u ubuntu --verbose --private-key .key site.yml
- name: Run Ansible Tests with added hosts
run: |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/ubuntu20/hosts.ini -u ubuntu --verbose --private-key .key testing.yml
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory/ubuntu20/hosts.yml -u ubuntu --verbose --private-key .key testing.yml
- name: Run Python Tests with added hosts
run: |
export DEFAULT_PRIVATE_KEY_FILE=.key
pytest --hosts=rke2_servers --ansible-inventory=inventory/ubuntu20/hosts.ini --force-ansible --connection=ansible --sudo testing/basic_server_tests.py
pytest --hosts=rke2_agents --ansible-inventory=inventory/ubuntu20/hosts.ini --force-ansible --connection=ansible --sudo testing/basic_agent_tests.py
pytest --hosts=rke2_servers --ansible-inventory=inventory/ubuntu20/hosts.yml --force-ansible --connection=ansible --sudo testing/basic_server_tests.py
pytest --hosts=rke2_agents --ansible-inventory=inventory/ubuntu20/hosts.yml --force-ansible --connection=ansible --sudo testing/basic_agent_tests.py
- name: Delete Stack
if: ${{ always() }}
Expand Down
Loading

0 comments on commit fd98dbc

Please sign in to comment.