@@ -44,30 +44,26 @@ jobs:
4444 name : Deploy Application
4545 needs : lint
4646
47- # For a local Vagrant/VirtualBox setup behind NAT, the simplest free option
48- # is a self-hosted Linux runner on the same machine (for example, inside WSL2).
4947 runs-on : [self-hosted, linux]
5048
5149 steps :
5250 - name : Checkout
5351 uses : actions/checkout@v4
5452
55- - name : Install Ansible (self-hosted)
53+ - name : Set up Python venv
5654 shell : bash
5755 run : |
5856 set -euo pipefail
59- python3 -m pip install --user --upgrade pip
60- python3 -m pip install --user ansible
61-
62- - name : Add user-local bin to PATH
63- shell : bash
64- run : |
65- echo "$HOME/.local/bin" >> "$GITHUB_PATH"
57+ python3 -m venv .venv
58+ . .venv/bin/activate
59+ python -m pip install --upgrade pip
60+ python -m pip install ansible ansible-lint
6661
6762 - name : Install Ansible collections
6863 shell : bash
6964 run : |
7065 set -euo pipefail
66+ . .venv/bin/activate
7167 ansible-galaxy collection install -r ansible/requirements.yml
7268
7369 - name : Deploy with Ansible
@@ -76,14 +72,16 @@ jobs:
7672 ANSIBLE_VAULT_PASSWORD : ${{ secrets.ANSIBLE_VAULT_PASSWORD }}
7773 run : |
7874 set -euo pipefail
75+ . .venv/bin/activate
76+ export ANSIBLE_CONFIG="$GITHUB_WORKSPACE/ansible/ansible.cfg"
7977 cd ansible
8078
8179 if [[ -n "${ANSIBLE_VAULT_PASSWORD:-}" ]]; then
8280 trap 'rm -f /tmp/vault_pass' EXIT
8381 printf '%s' "${ANSIBLE_VAULT_PASSWORD}" > /tmp/vault_pass
84- ansible-playbook playbooks/deploy.yml --vault-password-file /tmp/vault_pass
82+ ansible-playbook -i inventory/hosts.ini playbooks/deploy.yml --vault-password-file /tmp/vault_pass
8583 else
86- ansible-playbook playbooks/deploy.yml
84+ ansible-playbook -i inventory/hosts.ini playbooks/deploy.yml
8785 fi
8886
8987 - name : Verify deployment
9492 set -euo pipefail
9593 HOST="${VM_HOST:-127.0.0.1}"
9694 curl --retry 10 --retry-delay 3 --retry-connrefused -fsS "http://${HOST}:8000/health"
97- curl --retry 10 --retry-delay 3 --retry-connrefused -fsS "http://${HOST}:8000/"
95+ curl --retry 10 --retry-delay 3 --retry-connrefused -fsS "http://${HOST}:8000/"
0 commit comments