98 lines
2.9 KiB
YAML
Raw Normal View History

2020-06-13 01:12:23 -04:00
- name: Install expect
2023-05-03 23:42:55 -04:00
ansible.builtin.apt:
2020-06-13 01:12:23 -04:00
name: expect
state: present
- name: Create Bitwarden directory
2023-05-03 23:42:55 -04:00
ansible.builtin.file:
2021-02-27 00:00:52 -05:00
path: "{{ bitwarden_root }}"
2020-06-13 01:12:23 -04:00
state: directory
2023-11-05 21:34:19 -05:00
mode: "755"
2020-06-13 01:12:23 -04:00
- name: Download Bitwarden script
2023-05-03 23:42:55 -04:00
ansible.builtin.get_url:
2020-06-13 01:12:23 -04:00
url: "https://raw.githubusercontent.com/\
2022-05-19 23:19:09 -04:00
bitwarden/self-host/master/bitwarden.sh"
2021-02-27 00:00:52 -05:00
dest: "{{ bitwarden_root }}"
2020-06-13 01:12:23 -04:00
mode: u+x
- name: Install Bitwarden script wrapper
2023-05-03 23:42:55 -04:00
ansible.builtin.template:
2020-06-13 01:12:23 -04:00
src: bw_wrapper.j2
2021-02-27 00:00:52 -05:00
dest: "{{ bitwarden_root }}/bw_wrapper"
2020-06-13 01:12:23 -04:00
mode: u+x
2021-02-27 00:00:52 -05:00
- name: Run Bitwarden installation script
2023-11-05 21:34:19 -05:00
ansible.builtin.command: "{{ bitwarden_root }}/bw_wrapper"
2021-02-27 00:00:52 -05:00
args:
creates: "{{ bitwarden_root }}/bwdata/config.yml"
2023-11-02 23:29:54 -04:00
- name: Install compose override
2023-05-03 23:42:55 -04:00
ansible.builtin.template:
2021-02-27 00:00:52 -05:00
src: compose.override.yml.j2
dest: "{{ bitwarden_root }}/bwdata/docker/docker-compose.override.yml"
2023-11-05 21:34:19 -05:00
mode: "644"
2023-11-02 23:29:54 -04:00
when: bitwarden_override | default(true)
2022-05-27 00:03:49 -04:00
notify: rebuild_bitwarden
2021-02-27 00:00:52 -05:00
- name: Disable bitwarden-nginx HTTP on 80
2023-05-03 23:42:55 -04:00
ansible.builtin.replace:
2021-02-27 00:00:52 -05:00
path: "{{ bitwarden_root }}/bwdata/config.yml"
regexp: "^http_port: 80$"
2023-11-02 23:29:54 -04:00
replace: "http_port: {{ bitwarden_http_port | default('127.0.0.1:9080') }}"
2021-02-27 00:00:52 -05:00
when: not bitwarden_standalone
2022-05-27 00:03:49 -04:00
notify: rebuild_bitwarden
2021-02-27 00:00:52 -05:00
- name: Disable bitwarden-nginx HTTPS on 443
2023-05-03 23:42:55 -04:00
ansible.builtin.replace:
2021-02-27 00:00:52 -05:00
path: "{{ bitwarden_root }}/bwdata/config.yml"
regexp: "^https_port: 443$"
2023-11-02 23:29:54 -04:00
replace: "https_port: {{ bitwarden_https_port | default('127.0.0.1:9443') }}"
2021-02-27 00:00:52 -05:00
when: not bitwarden_standalone
2022-05-27 00:03:49 -04:00
notify: rebuild_bitwarden
2021-02-27 00:00:52 -05:00
- name: Disable Bitwarden managed Lets Encrypt
2023-05-03 23:42:55 -04:00
ansible.builtin.replace:
2021-02-27 00:00:52 -05:00
path: "{{ bitwarden_root }}/bwdata/config.yml"
regexp: "^ssl_managed_lets_encrypt: true$"
replace: "ssl_managed_lets_encrypt: false"
when: not bitwarden_standalone or not bitwarden_production
2022-05-27 00:03:49 -04:00
notify: rebuild_bitwarden
2021-02-27 00:00:52 -05:00
- name: Disable Bitwarden managed SSL
2023-05-03 23:42:55 -04:00
ansible.builtin.replace:
2021-02-27 00:00:52 -05:00
path: "{{ bitwarden_root }}/bwdata/config.yml"
regexp: "^ssl: true$"
replace: "ssl: false"
when: not bitwarden_standalone
2022-05-27 00:03:49 -04:00
notify: rebuild_bitwarden
- name: Define reverse proxy servers
2023-05-03 23:42:55 -04:00
ansible.builtin.lineinfile:
path: "{{ bitwarden_root }}/bwdata/config.yml"
line: "- {{ bitwarden_realips }}"
insertafter: "^real_ips"
2022-06-27 20:21:25 -04:00
notify: rebuild_bitwarden
2022-05-27 00:03:49 -04:00
- name: Install Bitwarden systemd service
2023-05-03 23:42:55 -04:00
ansible.builtin.template:
2022-05-27 00:03:49 -04:00
src: bitwarden.service.j2
dest: "/etc/systemd/system/{{ bitwarden_name }}.service"
2023-11-05 21:34:19 -05:00
mode: "644"
2022-05-27 00:03:49 -04:00
register: bitwarden_systemd
notify: rebuild_bitwarden
2022-06-07 00:25:47 -04:00
- name: Create Bitwarden's initial logging directory
2023-05-03 23:42:55 -04:00
ansible.builtin.file:
2022-06-07 00:25:47 -04:00
path: "{{ bitwarden_logs_identity }}"
state: directory
2023-11-05 21:34:19 -05:00
mode: "755"
notify: touch_bitwarden
2022-06-07 00:25:47 -04:00
2022-05-28 02:31:41 -04:00
- name: Install Bitwarden's Fail2ban jail
2023-05-03 23:42:55 -04:00
ansible.builtin.template:
2022-05-28 02:31:41 -04:00
src: fail2ban-jail.conf.j2
dest: /etc/fail2ban/jail.d/bitwarden.conf
2023-11-05 21:34:19 -05:00
mode: "640"
2022-05-28 02:31:41 -04:00
notify: restart_fail2ban