Initial vaultwarden role

docker compose based vaultwarden, bound to 127.0.0.1, sign ups off, admin panel only with an argon2 token, SMTP via mailcow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
lhahnandClaude Opus 5.5 committed 2026-10-14 17:51:51 +02:00
commit 2c8d9f7907
9 files changed
+162

No files matched your search

Executable
+9
View File
@@ -0,0 +1,9 @@
MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+11
View File
@@ -0,0 +1,11 @@
# cloud-vaultwarden
Ansible role to setup vaultwarden (Bitwarden compatible password manager) via docker compose.
- listens on `127.0.0.1:<vaultwarden_http_port>` only; expose it with the nginx role (TLS)
- sign ups are disabled by default; invite family members from an organization instead
- the admin panel is disabled unless `vaultwarden_admin_token` (argon2 PHC string) is set;
block `/admin` in the public nginx site and reach it through an SSH tunnel
- do NOT put a forward-auth (e.g. authentik) in front of it, the Bitwarden clients talk to the API directly
- data lives in `vaultwarden_data_location`; back up `db.sqlite3` with `sqlite3 .backup`, plus
`attachments`, `sends`, `config.json` and the `rsa_key*` files
+34
View File
@@ -0,0 +1,34 @@
---
cloud_apps: /opt
cloud_storage: /opt/storage
cloud_stage: prod
cloud_update: false
domain_external: "my-domain.tld"
vaultwarden_version: 1.37.4
vaultwarden_image: ghcr.io/dani-garcia/vaultwarden
vaultwarden_domain: "vault.{{ domain_external }}"
vaultwarden_http_port: 8222
vaultwarden_data_location: "{{ cloud_storage }}/vaultwarden-data"
vaultwarden_signups_allowed: false
vaultwarden_signups_verify: true
vaultwarden_invitations_allowed: true
vaultwarden_invitation_org_name: "Vaultwarden"
vaultwarden_show_password_hint: false
vaultwarden_password_iterations: 600000
#argon2 PHC string (vaultwarden hash); empty disables the admin panel
vaultwarden_admin_token:
vaultwarden_smtp_host: "mail.{{ domain_external }}"
vaultwarden_smtp_port: 465
vaultwarden_smtp_security: force_tls
vaultwarden_smtp_from: "noreply@{{ domain_external }}"
vaultwarden_smtp_from_name: Vaultwarden
vaultwarden_smtp_user: user@my-domain.tld
vaultwarden_smtp_pass: ThisCouldBeYourAdd
vaultwarden_loglevel: warn
+8
View File
@@ -0,0 +1,8 @@
---
- name: restart vaultwarden
community.docker.docker_compose_v2:
project_src: "{{ vaultwarden_inst }}"
state: present
pull: missing
recreate: always
remove_orphans: yes
+17
View File
@@ -0,0 +1,17 @@
---
galaxy_info:
role_name: vaultwarden
namespace: hahn-cloud
author: Lars Hahn
company: OpenDevChain
license: MIT
description: Role to setup vaultwarden password manager
min_ansible_version: 2.7
platforms:
- name: Debian
versions:
- 13
galaxy_tags:
- vaultwarden
dependencies:
- docker
+43
View File
@@ -0,0 +1,43 @@
---
- name: install vaultwarden recommendations
apt:
update_cache: yes
state: "{% if cloud_update | bool %}latest{% else %}present{% endif %}"
install_recommends: yes
pkg:
- "sqlite3"
- name: setup vaultwarden directories
file:
state: directory
path: "{{ item }}"
owner: root
group: root
mode: 0750
loop:
- "{{ vaultwarden_dir }}"
- "{{ vaultwarden_inst }}"
- "{{ vaultwarden_data_location }}"
- name: template vaultwarden compose file
template:
src: opt/vaultwarden/docker-compose.yml.j2
dest: "{{ vaultwarden_inst }}/docker-compose.yml"
mode: 0644
owner: root
group: root
notify: restart vaultwarden
- name: template vaultwarden environment
template:
src: opt/vaultwarden/.env.j2
dest: "{{ vaultwarden_inst }}/.env"
mode: 0640
owner: root
group: root
notify: restart vaultwarden
- name: start vaultwarden
community.docker.docker_compose_v2:
project_src: "{{ vaultwarden_inst }}"
state: present
+26
View File
@@ -0,0 +1,26 @@
### BASIC ###
DOMAIN=https://{{ vaultwarden_domain }}
LOG_LEVEL={{ vaultwarden_loglevel }}
IP_HEADER=X-Real-IP
SIGNUPS_ALLOWED={{ vaultwarden_signups_allowed | bool | lower }}
SIGNUPS_VERIFY={{ vaultwarden_signups_verify | bool | lower }}
INVITATIONS_ALLOWED={{ vaultwarden_invitations_allowed | bool | lower }}
INVITATION_ORG_NAME={{ vaultwarden_invitation_org_name }}
SHOW_PASSWORD_HINT={{ vaultwarden_show_password_hint | bool | lower }}
PASSWORD_ITERATIONS={{ vaultwarden_password_iterations }}
{# admin panel stays disabled without a token #}
{% if vaultwarden_admin_token %}
ADMIN_TOKEN='{{ vaultwarden_admin_token }}'
{% endif %}
### SMTP ###
SMTP_HOST={{ vaultwarden_smtp_host }}
SMTP_PORT={{ vaultwarden_smtp_port }}
SMTP_SECURITY={{ vaultwarden_smtp_security }}
SMTP_FROM={{ vaultwarden_smtp_from }}
SMTP_FROM_NAME={{ vaultwarden_smtp_from_name }}
SMTP_USERNAME={{ vaultwarden_smtp_user }}
SMTP_PASSWORD='{{ vaultwarden_smtp_pass }}'
@@ -0,0 +1,11 @@
name: vaultwarden
services:
vaultwarden:
image: {{ vaultwarden_image }}:{{ vaultwarden_version }}
restart: unless-stopped
env_file:
- .env
ports:
- "127.0.0.1:{{ vaultwarden_http_port }}:80"
volumes:
- {{ vaultwarden_data_location }}:/data
+3
View File
@@ -0,0 +1,3 @@
---
vaultwarden_dir: "{{ cloud_apps }}/vaultwarden"
vaultwarden_inst: "{{ vaultwarden_dir }}/inst"