Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci review #269

Merged
merged 62 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
6aa4f43
Add network attached instructions
Daemonslayer2048 Jan 3, 2025
a444c5e
Update tarball docs
Daemonslayer2048 Jan 3, 2025
156bb6e
Github does not support titled admons
Daemonslayer2048 Jan 3, 2025
0883f70
Clear some lint issues
Daemonslayer2048 Jan 6, 2025
c3954de
Clear some galaxy errors
Daemonslayer2048 Jan 6, 2025
a785925
Clear some new lint issues
Daemonslayer2048 Jan 6, 2025
213a05c
Fix ansible semver string
Daemonslayer2048 Jan 6, 2025
7b3f100
Use a supported ansible version
Daemonslayer2048 Jan 6, 2025
3865ff9
Update file and folder names
Daemonslayer2048 Jan 6, 2025
4c5d604
Import linting, split linting tasks
Daemonslayer2048 Jan 7, 2025
7a46a11
Update README instruction o inventory use
Daemonslayer2048 Jan 8, 2025
315b9df
Add vale linting, normalized file extensions, and doc tweaks
Daemonslayer2048 Jan 8, 2025
da710ff
Merge branch 'docs-update' into ci-review
Daemonslayer2048 Jan 8, 2025
da16f97
Tweak workflow lints
Daemonslayer2048 Jan 8, 2025
669df78
Merge workflows back into one file
Daemonslayer2048 Jan 8, 2025
bb30b90
Test sudo access
Daemonslayer2048 Jan 8, 2025
5ddb4ac
Rename Rocky tests, install Terraform
Daemonslayer2048 Jan 8, 2025
d97df9a
Fix rocky task dep
Daemonslayer2048 Jan 8, 2025
f43c743
Install Terraform attempt #2
Daemonslayer2048 Jan 8, 2025
d94c99b
Test reusable workflows
Daemonslayer2048 Jan 9, 2025
48988de
Add OS option
Daemonslayer2048 Jan 9, 2025
b5fc697
Add OS option 2
Daemonslayer2048 Jan 9, 2025
c7229bd
Inherit secrets
Daemonslayer2048 Jan 9, 2025
8dcef63
Install yq
Daemonslayer2048 Jan 9, 2025
1759c36
Install yq #2
Daemonslayer2048 Jan 9, 2025
20b8f85
Install yq #3
Daemonslayer2048 Jan 9, 2025
3f9263a
Install yq #4
Daemonslayer2048 Jan 9, 2025
e3623ad
Use YQ for inventory generation
Daemonslayer2048 Jan 9, 2025
f7ceed4
Merge branch 'rewrite' into ci-review
Daemonslayer2048 Jan 9, 2025
6518a32
Fix missing close bracket
Daemonslayer2048 Jan 9, 2025
601b812
Print hosts file for debugging
Daemonslayer2048 Jan 9, 2025
2caef6b
You should cat hosts file for debugging not exec it
Daemonslayer2048 Jan 9, 2025
0b23e2a
Runn test
Daemonslayer2048 Jan 9, 2025
a4dcbb9
Fix inventory file location
Daemonslayer2048 Jan 9, 2025
67d0863
Fix inventory and add ssh_user
Daemonslayer2048 Jan 10, 2025
796deba
Fix second inventory
Daemonslayer2048 Jan 10, 2025
38caa8d
Add rocky 9
Daemonslayer2048 Jan 10, 2025
7ff796d
Update CI to reference JOBID
Daemonslayer2048 Jan 10, 2025
db2d276
Attempt move to AWS commercial
Daemonslayer2048 Jan 10, 2025
923a9f0
Attempt move to AWS commercial 2
Daemonslayer2048 Jan 10, 2025
aa4a11a
Attempt move to AWS commercial 3
Daemonslayer2048 Jan 10, 2025
b8f9c07
Fix destroy command and defaults
Daemonslayer2048 Jan 10, 2025
c7e9568
Fix AWS Region
Daemonslayer2048 Jan 10, 2025
7d2ec9b
Tweak TF and simplify for debuggin
Daemonslayer2048 Jan 10, 2025
6db4f04
Fix new var
Daemonslayer2048 Jan 10, 2025
94ba646
Remove new var
Daemonslayer2048 Jan 10, 2025
26c9ea5
Remove new var 2
Daemonslayer2048 Jan 10, 2025
f190d4a
Fix bad EOF
Daemonslayer2048 Jan 10, 2025
8d6e612
Fix delete job
Daemonslayer2048 Jan 10, 2025
0bb1330
Reduce EC2 counts
Daemonslayer2048 Jan 11, 2025
d470bb8
Add Rocky 9 back
Daemonslayer2048 Jan 11, 2025
a7396b2
Name sec groups
Daemonslayer2048 Jan 13, 2025
942049e
Add Ubuntu
Daemonslayer2048 Jan 13, 2025
2819e03
Fix using wrong OS
Daemonslayer2048 Jan 13, 2025
a3de3b8
Add SLES
Daemonslayer2048 Jan 13, 2025
2c9bcb1
Fix issue where too in SLES does not have .bashrc
Daemonslayer2048 Jan 13, 2025
8de567b
Fix bad permission
Daemonslayer2048 Jan 13, 2025
8cb9075
Update README, Remove SLES, Test Lint requirements
Daemonslayer2048 Jan 13, 2025
9ba6383
Remove broken lint check
Daemonslayer2048 Jan 13, 2025
52978c3
Updat edocs
Daemonslayer2048 Jan 13, 2025
8aca56f
increase yaml lint line-length
aleiner Jan 14, 2025
796f0af
removing sles tests until they are reimplemented
Jan 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 46 additions & 14 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,72 @@
---
name: Lint Test
name: Lint

on:
push:

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

jobs:

lint-test:
name: Lint for push
ansible-lint:
name: Ansible
runs-on: ubuntu-latest

steps:
- name: Check out the codebase.
- name: Check out the codebase
uses: actions/checkout@v3

- name: Set up Python.
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install test dependencies.
run: pip3 install yamllint ansible-lint ansible
- name: Install ansible-lint
run: pip3 install ansible-lint ansible

- name: Version check
run: |
ansible --version
ansible-lint --version

- name: Run ansible-lint
run: ansible-lint

yaml-lint:
name: YAML
runs-on: ubuntu-latest

steps:
- name: Check out the codebase
uses: actions/checkout@v3

- name: Set up Python.
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install yamllint
run: pip3 install yamllint

- name: Version check
run: |
yamllint --version

- name: Run yamllint.
- name: Run yamllint
run: yamllint .

- name: Run ansible-lint.
run: ansible-lint
vale-lint:
name: Vale
runs-on: ubuntu-latest

steps:
- name: Check out the codebase
uses: actions/checkout@v3

- name: Install vale
run: sudo snap install vale

- name: Version check
run: |
vale --version

- name: Run yamllint
run: vale --glob='*.md' ./docs ./README.md
172 changes: 172 additions & 0 deletions .github/workflows/reusable_integration_testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
---
name: Reusable Cluster Testing

on:
workflow_call:
inputs:
os:
required: true
type: string
ssh_user:
required: true
type: string

jobs:

cluster-test:
runs-on: ubuntu-latest

steps:
- name: Check out the codebase.
uses: actions/checkout@v2

- name: Add terraform repository
run: |
wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list

- name: Set up Python
id: setup_python
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install dependencies
run: |
sudo apt update -y
sudo apt install terraform -y
sudo snap install yq
python -m pip install --upgrade pip
pip3 install ansible pytest-testinfra

- name: Ansible version check
run: ansible --version

- name: Terraform version check
run: terraform --version

- name: yq version check
run: yq --version

- name: Terraform Init
id: init
run: |
cd testing/
terraform init

- run: 'echo "$SSH_KEY" > .key'
shell: bash
env:
SSH_KEY: ${{secrets.SSH_PRIVATE_KEY}}

- run: chmod 400 .key

- name: Terraform private key
run: cp .key testing/.key

- name: Terraform Validate
id: validate
run: |
cd testing/
terraform validate -no-color

- name: Terraform Plan
id: plan
run: |
cd testing/
terraform plan -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -var "os=${{ inputs.os }}" -no-color
continue-on-error: true
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-2

- name: Terraform Plan Status
if: steps.plan.outcome == 'failure'
run: exit 1

- name: Terraform Apply
run: |
cd testing/
terraform apply -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -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 }}
AWS_DEFAULT_REGION: us-east-2

- 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" "Name=tag:os_test,Values=${{ inputs.os }}" --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:os_test,Values=${{ inputs.os }}" --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
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 }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-2

- name: Check hosts.yml and ansible.cfg
run: |
cat ./${{ inputs.os }}/hosts.yml
cat ansible.cfg

- name: Run playbook
run: |
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 ${{ 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 ${{ inputs.ssh_user }} --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=./${{ inputs.os }}/hosts.yml --force-ansible --connection=ansible --sudo testing/basic_server_tests.py
pytest --hosts=rke2_agents --ansible-inventory=./${{ inputs.os }}/hosts.yml --force-ansible --connection=ansible --sudo testing/basic_agent_tests.py

- 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" "Name=tag:os_test,Values=${{ inputs.os }}" --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 }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-2

- name: Run playbook again with added host
run: |
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 ${{ inputs.ssh_user }} --verbose --skip-tags "troubleshooting" --private-key .key testing.yml

- name: Run Python Tests with added host
run: |
export DEFAULT_PRIVATE_KEY_FILE=.key
pytest --hosts=rke2_servers --ansible-inventory=./${{ inputs.os }}/hosts.yml --force-ansible --connection=ansible --sudo testing/basic_server_tests.py
pytest --hosts=rke2_agents --ansible-inventory=./${{ inputs.os }}/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 ./${{ inputs.os }}/hosts.yml -u ${{ inputs.ssh_user }} -vvv --tags "troubleshooting" --private-key .key testing.yml

- name: Delete Stack
if: ${{ always() }}
run: |
cd testing/
terraform destroy -var "GITHUB_RUN_ID=$GITHUB_RUN_ID" -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 }}
AWS_DEFAULT_REGION: us-east-2

22 changes: 22 additions & 0 deletions .github/workflows/rocky.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Rocky

on:
pull_request:
workflow_dispatch:

jobs:

"_8_":
uses: ./.github/workflows/reusable_integration_testing.yml
with:
os: rocky8
ssh_user: rocky
secrets: inherit

"_9_":
uses: ./.github/workflows/reusable_integration_testing.yml
with:
os: rocky9
ssh_user: rocky
secrets: inherit
Loading
Loading