diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dba5bb2..2e53cf5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,11 @@ ---- name: CI on: - workflow_dispatch: + workflow_dispatch: pull_request: env: - VAULT_PASSWORD: "${{ secrets.VAULT_PASSWORD }}" - SSH_PUB: "${{ secrets.SSH_PUB }}" + VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD }} + SSH_PUB: ${{ secrets.SSH_PUB }} ANSIBLE_FORCE_COLOR: '1' jobs: @@ -14,41 +13,41 @@ jobs: name: Test Ansible Playbooks runs-on: ubuntu-latest steps: - - name: Create SSH pub - run: | - echo "creating ~/.ssh/id_rsa.pub file" - mkdir -p ~/.ssh/ - echo "$SSH_PUB" > ~/.ssh/id_rsa.pub - - name: Install SSH key - uses: shimataro/ssh-key-action@v2 - with: - key: ${{ secrets.SSH_KEY }} - known_hosts: ${{ secrets.KNOWN_HOSTS }} - - name: Check out the codebase. - uses: actions/checkout@v3 - - name: Prepare Test Files - run: | - mv tests/.vault-pass.sh ./.vault-pass.sh - mv tests/ansible.cfg ./ansible.cfg - mv tests/hosts.ini ./hosts.ini - - uses: actions/setup-python@v4 - with: - python-version: 3.8.9 - - name: Install test dependencies. - run: pip install -r requirements.txt - - name: Install ansible dependencies. - run: ansible-galaxy install -r requirements.yml - - name: Syntax Check - run: | - ansible-playbook setup-linode.yml --syntax-check - ansible-playbook setup-homelab.yml --syntax-check - ansible-playbook verify-homelab.yml --syntax-check - - name: Setup Linode Instance - run: ansible-playbook setup-linode.yml - - name: Setup Home Lab - run: ansible-playbook setup-homelab.yml - - name: Verify Home Lab - run: ansible-playbook verify-homelab.yml - - name: Delete Linode Instance - run: ansible-playbook setup-linode.yml --extra-vars "state=absent" + - name: Create SSH pub + run: | + echo "creating ~/.ssh/id_rsa.pub file" + mkdir -p ~/.ssh/ + echo "$SSH_PUB" > ~/.ssh/id_rsa.pub + - name: Install SSH key + uses: shimataro/ssh-key-action@v2 + with: + key: ${{ secrets.SSH_KEY }} + known_hosts: ${{ secrets.KNOWN_HOSTS }} + - name: Check out the codebase. + uses: actions/checkout@v3 + - name: Prepare Test Files + run: | + mv tests/.vault-pass.sh ./.vault-pass.sh + mv tests/ansible.cfg ./ansible.cfg + mv tests/hosts.ini ./hosts.ini + - uses: actions/setup-python@v4 + with: + python-version: 3.8.9 + - name: Install test dependencies. + run: pip install -r requirements.txt + - name: Install ansible dependencies. + run: ansible-galaxy install -r requirements.yml + - name: Syntax Check + run: | + ansible-playbook setup-linode.yml --syntax-check + ansible-playbook setup-homelab.yml --syntax-check + ansible-playbook verify-homelab.yml --syntax-check + - name: Setup Linode Instance + run: ansible-playbook setup-linode.yml + - name: Setup Home Lab + run: ansible-playbook setup-homelab.yml + - name: Verify Home Lab + run: ansible-playbook verify-homelab.yml + - name: Delete Linode Instance + run: ansible-playbook setup-linode.yml --extra-vars "state=absent" diff --git a/.github/workflows/delete-linode-instances.yml b/.github/workflows/delete-linode-instances.yml index 697d653..c40f3bf 100644 --- a/.github/workflows/delete-linode-instances.yml +++ b/.github/workflows/delete-linode-instances.yml @@ -1,12 +1,11 @@ ---- name: Delete test linode instance on: schedule: - - cron: "0 0 * * *" # delete at midnight every day + - cron: 0 0 * * * # delete at midnight every day env: - VAULT_PASSWORD: "${{ secrets.VAULT_PASSWORD }}" - SSH_PUB: "${{ secrets.SSH_PUB }}" + VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD }} + SSH_PUB: ${{ secrets.SSH_PUB }} ANSIBLE_FORCE_COLOR: '1' jobs: @@ -14,28 +13,28 @@ jobs: name: Delete Linode Instance runs-on: ubuntu-latest steps: - - name: Create SSH pub - run: | - echo "creating ~/.ssh/id_rsa.pub file" - mkdir -p ~/.ssh/ - echo "$SSH_PUB" > ~/.ssh/id_rsa.pub - - name: Install SSH key - uses: shimataro/ssh-key-action@v2 - with: - key: ${{ secrets.SSH_KEY }} - known_hosts: ${{ secrets.KNOWN_HOSTS }} - - name: Check out the codebase. - uses: actions/checkout@v3 - - name: Prepare Test Files - run: | - mv tests/.vault-pass.sh ./.vault-pass.sh - mv tests/ansible.cfg ./ansible.cfg - mv tests/hosts.ini ./hosts.ini - - uses: actions/setup-python@v4 - with: - python-version: 3.8.9 - - name: Install test dependencies. - run: pip install -r requirements.txt - - name: Delete Linode Instance - run: ansible-playbook setup-linode.yml --extra-vars "state=absent" + - name: Create SSH pub + run: | + echo "creating ~/.ssh/id_rsa.pub file" + mkdir -p ~/.ssh/ + echo "$SSH_PUB" > ~/.ssh/id_rsa.pub + - name: Install SSH key + uses: shimataro/ssh-key-action@v2 + with: + key: ${{ secrets.SSH_KEY }} + known_hosts: ${{ secrets.KNOWN_HOSTS }} + - name: Check out the codebase. + uses: actions/checkout@v3 + - name: Prepare Test Files + run: | + mv tests/.vault-pass.sh ./.vault-pass.sh + mv tests/ansible.cfg ./ansible.cfg + mv tests/hosts.ini ./hosts.ini + - uses: actions/setup-python@v4 + with: + python-version: 3.8.9 + - name: Install test dependencies. + run: pip install -r requirements.txt + - name: Delete Linode Instance + run: ansible-playbook setup-linode.yml --extra-vars "state=absent" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3cf1642..9a21b46 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,7 +1,6 @@ ---- -name: Lint +name: Code Health on: - workflow_dispatch: + workflow_dispatch: push: jobs: @@ -10,31 +9,31 @@ jobs: strategy: matrix: directory: - - roles - - playbooks - - group_vars - - host_vars + - roles + - playbooks + - group_vars + - host_vars steps: - - name: Checkout the codebase - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: 3.8.9 - - name: Install dependencies - run: make deps - - name: Test Directory - run: ansible-lint ${{ matrix.directory }} + - name: Checkout the codebase + uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: 3.8.9 + - name: Install dependencies + run: make deps + - name: Test Directory + run: ansible-lint ${{ matrix.directory }} - format: + format: runs-on: ubuntu-latest steps: - - name: Checkout the codebase - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: 3.8.9 - - name: Install dependencies - run: make deps - - name: Format code - run: make format + - name: Checkout the codebase + uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: 3.8.9 + - name: Install dependencies + run: make deps + - name: Format code + run: make format diff --git a/scripts/format_all_yaml.sh b/scripts/format_all_yaml.sh index 962b522..8a14ae8 100755 --- a/scripts/format_all_yaml.sh +++ b/scripts/format_all_yaml.sh @@ -13,3 +13,4 @@ format_dir roles format_dir playbooks format_dir host_vars format_dir group_vars +format_dir .github/workflows