Added google tag
Added ansible Added deploy.sh
This commit is contained in:
5
ansible/roles/caddy/handlers/main.yaml
Normal file
5
ansible/roles/caddy/handlers/main.yaml
Normal 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"
|
||||
29
ansible/roles/caddy/tasks/main.yaml
Normal file
29
ansible/roles/caddy/tasks/main.yaml
Normal 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"
|
||||
24
ansible/roles/mozimo/tasks/main.yaml
Normal file
24
ansible/roles/mozimo/tasks/main.yaml
Normal 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 }}"
|
||||
8
ansible/roles/network/tasks/main.yaml
Normal file
8
ansible/roles/network/tasks/main.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: Ensure 'mozimo' Docker network exists
|
||||
docker_network:
|
||||
name: "{{ docker_network }}"
|
||||
state: present
|
||||
connected:
|
||||
- name: caddy
|
||||
appends: yes
|
||||
11
ansible/roles/upload/tasks/main.yaml
Normal file
11
ansible/roles/upload/tasks/main.yaml
Normal 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"
|
||||
Reference in New Issue
Block a user