Updated bitwarden to work with caddy
This commit is contained in:
1 parent
3ff953acdb
commit
e429ce661e
8 files changed
+62
-47
No files matched your search
@@ -2,7 +2,7 @@
|
||||
# Tasks for Bitwarden role
|
||||
- name: Pull Bitwarden Vault Warden image
|
||||
docker_image:
|
||||
name: "{{ container_image }}"
|
||||
name: "{{ image_name }}"
|
||||
source: pull
|
||||
force_source: yes
|
||||
|
||||
@@ -14,16 +14,14 @@
|
||||
|
||||
- name: Create bitwarden container
|
||||
docker_container:
|
||||
name: "{{ container_name }}"
|
||||
image: "{{ container_image }}"
|
||||
name: "{{ docker_container }}"
|
||||
image: "{{ image_name }}"
|
||||
state: started
|
||||
restart_policy: "unless-stopped"
|
||||
env:
|
||||
DATABASE_URL: "{{ db_url }}"
|
||||
DOMAIN: "https://{{ http_host }}"
|
||||
links:
|
||||
- "postgres:db"
|
||||
published_ports:
|
||||
- 127.0.0.1:8080:80
|
||||
DOMAIN: "https://{{ host }}"
|
||||
volumes:
|
||||
- "/var/lib/{{ host_directory }}/data:/data/"
|
||||
networks:
|
||||
- name: "{{ docker_network }}"
|
||||
@@ -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"
|
||||
@@ -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: "Reload Caddy"
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: "Ensure {{ docker_container }} Docker network exists"
|
||||
docker_network:
|
||||
name: "{{ docker_network }}"
|
||||
state: present
|
||||
connected:
|
||||
- "{{ caddy_container }}"
|
||||
- "{{ postgres_container }}"
|
||||
appends: yes
|
||||
@@ -1,6 +0,0 @@
|
||||
---
|
||||
# Handlers for Nginx role
|
||||
- name: Reload Nginx
|
||||
service:
|
||||
name: nginx
|
||||
state: reloaded
|
||||
@@ -1,24 +0,0 @@
|
||||
---
|
||||
# Tasks for Nginx role
|
||||
- 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
|
||||
Reference in new issue
Block a user