init test commit

This commit is contained in:
2026-11-10 20:36:01 -07:00
commit 8693b3bd8d
42 changed files with 311150 additions and 0 deletions

102
playbook.yml Normal file
View File

@@ -0,0 +1,102 @@
---
- name: Deploy Star Citizen Inventory (trade-hub)
hosts: webservers
vars:
backend_image: sc-inventory-backend
frontend_image: sc-inventory-frontend
image_tag: latest
network_name: sc-inventory
frontend_port: "8080:80"
# Set to true to force image rebuilds even when the images already exist
force_rebuild: false
tasks:
- name: Check whether podman is installed
ansible.builtin.command: podman --version
register: podman_check
failed_when: false
changed_when: false
- name: Install podman if missing
become: true
ansible.builtin.package:
name: podman
state: present
when: podman_check.rc != 0
- name: Remove legacy Apache container if present
containers.podman.podman_container:
name: my-apache-server
state: absent
- name: Check if backend image exists
ansible.builtin.command: podman image exists {{ backend_image }}:{{ image_tag }}
register: backend_image_check
failed_when: false
changed_when: false
- name: Check if frontend image exists
ansible.builtin.command: podman image exists {{ frontend_image }}:{{ image_tag }}
register: frontend_image_check
failed_when: false
changed_when: false
- name: Build backend image
ansible.builtin.command: >
podman build -t {{ backend_image }}:{{ image_tag }}
{{ playbook_dir }}/trade-hub/backend
when: backend_image_check.rc != 0 or force_rebuild | bool
- name: Build frontend image
ansible.builtin.command: >
podman build -t {{ frontend_image }}:{{ image_tag }}
{{ playbook_dir }}/trade-hub/frontend
when: frontend_image_check.rc != 0 or force_rebuild | bool
# podman_container does not recreate a container whose image tag now
# resolves to a new ID, so rebuilt images require removing them first.
- name: Remove containers so rebuilt images are used
containers.podman.podman_container:
name: "{{ item }}"
state: absent
loop:
- sc-inventory-backend
- sc-inventory-frontend
when: force_rebuild | bool
- name: Create podman network
containers.podman.podman_network:
name: "{{ network_name }}"
state: present
- name: Run backend container (internal only)
containers.podman.podman_container:
name: sc-inventory-backend
image: "{{ backend_image }}:{{ image_tag }}"
state: started
network: "{{ network_name }}"
# Network alias "backend" matches the compose service name, so the
# nginx upstream (http://backend:8000) resolves in both deployments.
network_aliases:
- backend
restart_policy: unless-stopped
- name: Run frontend container (published port)
containers.podman.podman_container:
name: sc-inventory-frontend
image: "{{ frontend_image }}:{{ image_tag }}"
state: started
network: "{{ network_name }}"
ports:
- "{{ frontend_port }}"
restart_policy: unless-stopped
- name: Verify the stack responds
ansible.builtin.uri:
url: http://localhost:8080/healthz
status_code: 200
register: health_result
until: health_result.status == 200
retries: 5
delay: 10