Add Bitwarden systemd service
This commit is contained in:
parent
be6e1596c5
commit
e346180b13
@ -1,5 +1,5 @@
|
|||||||
bitwarden_name: bitwarden
|
bitwarden_name: bitwarden
|
||||||
bitwarden_root: "/opt/{{ bitwarden_name }}"
|
bitwarden_root: "{{ docker_root }}/{{ bitwarden_name }}"
|
||||||
bitwarden_database: "{{ bitwarden_name }}"
|
bitwarden_database: "{{ bitwarden_name }}"
|
||||||
bitwarden_standalone: false
|
bitwarden_standalone: false
|
||||||
bitwarden_production: false
|
bitwarden_production: false
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
|
- name: Stop Bitwarden for rebuild
|
||||||
|
service:
|
||||||
|
name: "{{ bitwarden_name }}"
|
||||||
|
state: stopped
|
||||||
|
listen: rebuild_bitwarden
|
||||||
|
|
||||||
- name: Rebuild Bitwarden
|
- name: Rebuild Bitwarden
|
||||||
shell: "{{ bitwarden_root }}/bitwarden.sh rebuild"
|
shell: "{{ bitwarden_root }}/bitwarden.sh rebuild"
|
||||||
listen: rebuild_bitwarden
|
listen: rebuild_bitwarden
|
||||||
|
|
||||||
- name: Start Bitwarden
|
- name: Start Bitwarden after rebuild
|
||||||
shell: "{{ bitwarden_root }}/bitwarden.sh start"
|
service:
|
||||||
listen: start_bitwarden
|
name: "{{ bitwarden_name }}"
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
listen: rebuild_bitwarden
|
||||||
|
@ -25,36 +25,29 @@
|
|||||||
shell: "{{ bitwarden_root }}/bw_wrapper"
|
shell: "{{ bitwarden_root }}/bw_wrapper"
|
||||||
args:
|
args:
|
||||||
creates: "{{ bitwarden_root }}/bwdata/config.yml"
|
creates: "{{ bitwarden_root }}/bwdata/config.yml"
|
||||||
notify: start_bitwarden
|
|
||||||
|
|
||||||
- name: Install docker-compose override
|
- name: Install docker-compose override
|
||||||
template:
|
template:
|
||||||
src: compose.override.yml.j2
|
src: compose.override.yml.j2
|
||||||
dest: "{{ bitwarden_root }}/bwdata/docker/docker-compose.override.yml"
|
dest: "{{ bitwarden_root }}/bwdata/docker/docker-compose.override.yml"
|
||||||
when: traefik_version is defined
|
when: traefik_version is defined
|
||||||
notify:
|
notify: rebuild_bitwarden
|
||||||
- rebuild_bitwarden
|
|
||||||
- start_bitwarden
|
|
||||||
|
|
||||||
- name: Disable bitwarden-nginx HTTP on 80
|
- name: Disable bitwarden-nginx HTTP on 80
|
||||||
replace:
|
replace:
|
||||||
path: "{{ bitwarden_root }}/bwdata/config.yml"
|
path: "{{ bitwarden_root }}/bwdata/config.yml"
|
||||||
regexp: "^http_port: 80$"
|
regexp: "^http_port: 80$"
|
||||||
replace: "http_port: 8080"
|
replace: "http_port: 127.0.0.1:8080"
|
||||||
when: not bitwarden_standalone
|
when: not bitwarden_standalone
|
||||||
notify:
|
notify: rebuild_bitwarden
|
||||||
- rebuild_bitwarden
|
|
||||||
- start_bitwarden
|
|
||||||
|
|
||||||
- name: Disable bitwarden-nginx HTTPS on 443
|
- name: Disable bitwarden-nginx HTTPS on 443
|
||||||
replace:
|
replace:
|
||||||
path: "{{ bitwarden_root }}/bwdata/config.yml"
|
path: "{{ bitwarden_root }}/bwdata/config.yml"
|
||||||
regexp: "^https_port: 443$"
|
regexp: "^https_port: 443$"
|
||||||
replace: "https_port: 8443"
|
replace: "https_port: 127.0.0.1:8443"
|
||||||
when: not bitwarden_standalone
|
when: not bitwarden_standalone
|
||||||
notify:
|
notify: rebuild_bitwarden
|
||||||
- rebuild_bitwarden
|
|
||||||
- start_bitwarden
|
|
||||||
|
|
||||||
- name: Disable Bitwarden managed Lets Encrypt
|
- name: Disable Bitwarden managed Lets Encrypt
|
||||||
replace:
|
replace:
|
||||||
@ -62,9 +55,7 @@
|
|||||||
regexp: "^ssl_managed_lets_encrypt: true$"
|
regexp: "^ssl_managed_lets_encrypt: true$"
|
||||||
replace: "ssl_managed_lets_encrypt: false"
|
replace: "ssl_managed_lets_encrypt: false"
|
||||||
when: not bitwarden_standalone or not bitwarden_production
|
when: not bitwarden_standalone or not bitwarden_production
|
||||||
notify:
|
notify: rebuild_bitwarden
|
||||||
- rebuild_bitwarden
|
|
||||||
- start_bitwarden
|
|
||||||
|
|
||||||
- name: Disable Bitwarden managed SSL
|
- name: Disable Bitwarden managed SSL
|
||||||
replace:
|
replace:
|
||||||
@ -72,6 +63,17 @@
|
|||||||
regexp: "^ssl: true$"
|
regexp: "^ssl: true$"
|
||||||
replace: "ssl: false"
|
replace: "ssl: false"
|
||||||
when: not bitwarden_standalone
|
when: not bitwarden_standalone
|
||||||
notify:
|
notify: rebuild_bitwarden
|
||||||
- rebuild_bitwarden
|
|
||||||
- start_bitwarden
|
- name: Install Bitwarden systemd service
|
||||||
|
template:
|
||||||
|
src: bitwarden.service.j2
|
||||||
|
dest: "/etc/systemd/system/{{ bitwarden_name }}.service"
|
||||||
|
register: bitwarden_systemd
|
||||||
|
notify: rebuild_bitwarden
|
||||||
|
|
||||||
|
- name: Reload systemd manager configuration
|
||||||
|
systemd:
|
||||||
|
daemon_reload: true
|
||||||
|
when: bitwarden_systemd.changed
|
||||||
|
notify: rebuild_bitwarden
|
||||||
|
13
roles/bitwarden/templates/bitwarden.service.j2
Normal file
13
roles/bitwarden/templates/bitwarden.service.j2
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Bitwarden Password Manager Server
|
||||||
|
PartOf=docker.service
|
||||||
|
After=docker.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
RemainAfterExit=true
|
||||||
|
ExecStart={{ bitwarden_root }}/bitwarden.sh start
|
||||||
|
ExecStop={{ bitwarden_root }}/bitwarden.sh stop
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user