Added google tag

Added ansible
Added deploy.sh
This commit is contained in:
2025-10-04 14:53:45 +00:00
parent 67411b3972
commit 7b1ee49d11
10 changed files with 130 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
# Handlers for Caddy role
- name: Reload Caddy configuration
ansible.builtin.command: "docker exec -w /etc/caddy {{ caddy_container }} caddy reload"
listen: "Reload Caddy"

View File

@ -0,0 +1,29 @@
---
- name: Read current Caddyfile
ansible.builtin.slurp:
path: "{{ caddyfile_path }}"
register: caddyfile_raw
- name: Decode Caddyfile content
set_fact:
caddyfile_content: "{{ caddyfile_raw['content'] | b64decode }}"
- name: Build snippet block from variables
set_fact:
snippet_block: |
{{ host }} {
reverse_proxy {{ docker_container }}:{{ docker_port }}
}
- name: Check if snippet already exists
set_fact:
snippet_present: "{{ snippet_block in caddyfile_content }}"
- name: Add snippet if missing
ansible.builtin.blockinfile:
path: "{{ caddyfile_path }}"
marker: "# {mark} Ansible managed Caddy snippet for {{ host }}"
block: "{{ snippet_block }}"
create: yes
when: not snippet_present
notify: "Reload Caddy"

View File

@ -0,0 +1,24 @@
---
# Tasks for docker role
- name: Log in to Docker registry
docker_login:
registry: "{{ registry }}"
username: "{{ username }}"
password: "{{ password }}"
- name: Pull Mozimo image
docker_image:
name: "{{ docker_image }}"
source: pull
state: present
force_source: yes
- name: Create Mozimo container
docker_container:
name: "{{ docker_container }}"
image: "{{ docker_image }}"
state: started
restart_policy: "unless-stopped"
env_file: "{{ host_directory }}/.env"
networks:
- name: "{{ docker_network }}"

View File

@ -0,0 +1,8 @@
---
- name: Ensure 'mozimo' Docker network exists
docker_network:
name: "{{ docker_network }}"
state: present
connected:
- name: caddy
appends: yes

View File

@ -0,0 +1,11 @@
---
# Tasks for upload role
- name: Ensure Host Directory exists
file:
path: "{{ host_directory }}"
state: directory
- name: Upload the .env file
template:
src: "files/.env"
dest: "{{ host_directory }}/.env"