Tandoor updated.
This commit is contained in:
1 parent
fabe4bfcfb
commit
b7c5997274
7 files changed
+100
-71
No files matched your search
@@ -5,3 +5,4 @@ POSTGRES_PORT=5432
|
||||
POSTGRES_USER=postgres
|
||||
POSTGRES_PASSWORD=123456
|
||||
POSTGRES_DB=tandoor
|
||||
ALLOWED_HOSTS={{ host }},localhost,127.0.0.1
|
||||
+5
-65
@@ -2,72 +2,12 @@
|
||||
# DO Community Playbooks: Docker
|
||||
#################################################
|
||||
---
|
||||
- hosts: all
|
||||
- hosts: monoco
|
||||
become: true
|
||||
vars_files:
|
||||
- vars/default.yml
|
||||
|
||||
tasks:
|
||||
- name: Pull Tandoor.dev image
|
||||
docker_image:
|
||||
name: "{{ image_name }}"
|
||||
source: pull
|
||||
state: present
|
||||
force_source: yes
|
||||
|
||||
- name: Ensure Host Directory exists
|
||||
file:
|
||||
path: "/var/lib/{{ host_directory }}"
|
||||
state: directory
|
||||
group: www-data
|
||||
owner: www-data
|
||||
mode: 0655
|
||||
|
||||
- name: Upload the .env file
|
||||
template:
|
||||
src: "files/.env"
|
||||
dest: "/var/lib/{{ host_directory }}/.env"
|
||||
|
||||
- name: Create Tandoor.dev container
|
||||
docker_container:
|
||||
name: "{{ container_name }}"
|
||||
image: "{{ image_name }}"
|
||||
state: started
|
||||
restart_policy: "unless-stopped"
|
||||
env_file: "/var/lib/{{ host_directory }}/.env"
|
||||
links:
|
||||
- "postgres:db"
|
||||
published_ports:
|
||||
- "127.0.0.1:8880:8080"
|
||||
volumes:
|
||||
- "/var/lib/{{ host_directory }}/staticfiles:/opt/recipes/staticfiles"
|
||||
- "/var/lib/{{ host_directory }}/mediafiles:/opt/recipes/mediafiles"
|
||||
- "/var/lib/{{ host_directory }}/externalfiles:/opt/recipes/externalfiles"
|
||||
|
||||
- name: Check if Nginx conf file exists
|
||||
stat: path="/etc/nginx/sites-available/{{ http_conf }}"
|
||||
register: status
|
||||
|
||||
- name: No need to reload Nginx
|
||||
debug: msg= {{ "No need to reload Nginx as sites-available entries have already been created" }}
|
||||
|
||||
- name: Set Nginx conf file
|
||||
when: status.stat.exists == false
|
||||
template:
|
||||
src: "files/nginx.conf.j2"
|
||||
dest: "/etc/nginx/sites-available/{{ http_conf }}"
|
||||
|
||||
- name: Enable new site
|
||||
when: status.stat.exists == false
|
||||
file:
|
||||
src: "/etc/nginx/sites-available/{{ http_conf }}"
|
||||
dest: "/etc/nginx/sites-enabled/{{ http_conf }}"
|
||||
state: link
|
||||
notify: Reload Nginx
|
||||
|
||||
handlers:
|
||||
- name: Reload Nginx
|
||||
service:
|
||||
name: nginx
|
||||
state: reloaded
|
||||
|
||||
roles:
|
||||
- network
|
||||
- tandoor
|
||||
- caddy
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
# Handlers for Nginx role
|
||||
- name: Restart caddy container
|
||||
docker_container:
|
||||
name: "{{ caddy_container }}"
|
||||
state: started
|
||||
restart: true
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
- 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: 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: Restart caddy container
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
- name: Ensure tandoor, caddy, postgres are on Docker network
|
||||
docker_network:
|
||||
name: "{{ docker_network }}"
|
||||
state: present
|
||||
connected:
|
||||
- name: "{{ docker_container }}"
|
||||
- name: "{{ postgres_container }}"
|
||||
alias: db
|
||||
- name: "{{ caddy_container }}"
|
||||
appends: yes
|
||||
@@ -0,0 +1,42 @@
|
||||
---
|
||||
# Tasks for a Tandoor.dev role
|
||||
- name: Pull image
|
||||
docker_image:
|
||||
name: "{{ docker_image }}"
|
||||
source: pull
|
||||
state: present
|
||||
force_source: yes
|
||||
|
||||
- name: Ensure Host Directory exists
|
||||
file:
|
||||
path: "/var/lib/{{ host_directory }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: Upload the .env file
|
||||
template:
|
||||
src: "files/.env"
|
||||
dest: "/var/lib/{{ host_directory }}/.env"
|
||||
|
||||
|
||||
# - name: Ensure Docker network exists
|
||||
# docker_network:
|
||||
# name: "{{ docker_network }}"
|
||||
# connected:
|
||||
# - name: "{{ postgres_container }}"
|
||||
# alias: db
|
||||
# - name: "{{ caddy_container }}"
|
||||
|
||||
- name: Create container
|
||||
docker_container:
|
||||
name: "{{ docker_container }}"
|
||||
image: "{{ docker_image }}"
|
||||
state: started
|
||||
restart_policy: "unless-stopped"
|
||||
env_file: "/var/lib/{{ host_directory }}/.env"
|
||||
volumes:
|
||||
- "/var/lib/{{ host_directory }}/staticfiles:/opt/recipes/staticfiles"
|
||||
- "/var/lib/{{ host_directory }}/mediafiles:/opt/recipes/mediafiles"
|
||||
- "/var/lib/{{ host_directory }}/externalfiles:/opt/recipes/externalfiles"
|
||||
networks:
|
||||
- name: "{{ docker_network }}"
|
||||
@@ -1,9 +1,15 @@
|
||||
---
|
||||
http_host: "recipes.tanshu.com"
|
||||
http_conf: "recipes.tanshu.com.conf"
|
||||
http_url: "https://recipes.tanshu.com"
|
||||
|
||||
container_name: tandoor
|
||||
image_name: vabene1111/recipes:latest
|
||||
host: recipes.tanshu.com
|
||||
docker_image: vabene1111/recipes:latest
|
||||
docker_container: tandoor
|
||||
docker_network: "{{ docker_container }}_net"
|
||||
|
||||
host_directory: tandoor
|
||||
|
||||
postgres_container: postgres
|
||||
caddy_container: caddy
|
||||
caddyfile_path: /var/lib/caddy/conf/Caddyfile
|
||||
snippet_block: |
|
||||
{{ host }} {
|
||||
reverse_proxy {{ docker_container }}:80
|
||||
}
|
||||
Reference in new issue
Block a user