fp/ansible/roles/our/tasks/stack.yml
CJ_Clippy 144a460ed5
Some checks failed
fp/our CI/CD / build (push) Successful in 3m0s
ci / test (push) Failing after 5m32s
put env vars in docker_stack compose
2025-10-06 01:31:03 -08:00

68 lines
1.7 KiB
YAML

---
- name: Create directory
ansible.builtin.file:
path: /etc/futureporn/our
state: directory
mode: "0755"
# - name: Copy env file
# ansible.builtin.copy:
# src: ../../../../.env.production
# dest: /etc/futureporn/our/.env
# mode: "0600"
- name: Clone the latest code
ansible.builtin.git:
repo: https://gitea.futureporn.net/futureporn/fp
dest: /tmp/checkout
single_branch: true
version: main
clone: true
force: true
- name: Copy compose files
ansible.builtin.copy:
remote_src: true
src: "/tmp/checkout/services/our/{{ item }}"
dest: "/etc/futureporn/our/{{ item }}"
mode: "0744"
loop:
- compose.db.yaml
- compose.production.yaml
- compose.green.yaml
- compose.blue.yaml
- name: Deploy db stack
community.docker.docker_stack:
state: present
name: our-postgres
compose:
- /etc/futureporn/our/compose.db.yaml
- name: Deploy stack to green
community.docker.docker_stack:
state: present
name: our-green
compose:
- /etc/futureporn/our/compose.production.yaml
- /etc/futureporn/our/compose.green.yaml
- services:
worker:
environment:
DATABASE_URL: "{{ lookup('dotenv', 'DATABASE_URL', file='../../../../.env.production') }}"
server:
environment:
DATABASE_URL: "{{ lookup('dotenv', 'DATABASE_URL', file='../../../../.env.production') }}"
- name: Deploy stack to blue
community.docker.docker_stack:
state: present
name: our-blue
compose:
- /etc/futureporn/our/compose.production.yaml
- /etc/futureporn/our/compose.blue.yaml
# - name: Remove stack
# community.docker.docker_stack:
# name: mystack
# state: absent