# HAProxy playbook — provisions one Incus container `haproxy` and # lays down the HAProxy config in front of the backend-api + # stream-server pools. # # v1.0.9 W4 Day 19. # # Run with: # ansible-galaxy collection install community.general # ansible-playbook -i inventory/lab.yml playbooks/haproxy.yml --- - name: Provision Incus container for HAProxy hosts: incus_hosts become: true gather_facts: true tasks: - name: Launch haproxy container ansible.builtin.shell: cmd: | set -e if ! incus info haproxy >/dev/null 2>&1; then incus launch images:ubuntu/22.04 haproxy for _ in $(seq 1 30); do if incus exec haproxy -- cloud-init status 2>/dev/null | grep -q "status: done"; then break fi sleep 1 done incus exec haproxy -- apt-get update incus exec haproxy -- apt-get install -y python3 python3-apt fi args: executable: /bin/bash register: provision_result changed_when: "'incus launch' in provision_result.stdout" tags: [haproxy, provision] - name: Refresh inventory so the new container is reachable ansible.builtin.meta: refresh_inventory - name: Apply common baseline hosts: haproxy become: true gather_facts: true roles: - common - name: Install + configure HAProxy hosts: haproxy become: true gather_facts: true roles: - haproxy