Ansible roles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

97 lines
2.9 KiB

---
- name: Install needed packages
yum:
name:
- openssl-devel
- gcc
- sqlite
tags: bitwarden
- name: Check if MariaDB version is set
fail: msg="Need to define mysql_mariadb_version"
when:
- bitwarden_db_engine == 'mysql'
- mysql_mariadb_version is not defined or mysql_mariadb_version == 'default'
tags: bitwarden
- name: Install MariaDB devel package
yum:
name:
- MariaDB-devel
- /usr/lib64/libmariadb.so
when: bitwarden_db_engine == 'mysql'
tags: bitwarden
- when: bitwarden_install_mode != 'none'
tags: bitwarden
block:
- name: Download bitwarden
get_url:
url: "{{ bitwarden_archive_url }}"
dest: "{{ bitwarden_root_dir }}/tmp"
checksum: sha1:{{ bitwarden_archive_sha1 }}
- name: Extract bitwarden archive
unarchive:
src: "{{ bitwarden_root_dir }}/tmp/bitwarden_rs-{{ bitwarden_version }}.tar.gz"
dest: "{{ bitwarden_root_dir }}/tmp"
remote_src: True
- name: Build bitwarden
command: bash -lc 'cargo build --features={{ (bitwarden_db_engine == "mysql") | ternary("mysql","sqlite") }} --release'
args:
chdir: "{{ bitwarden_root_dir }}/tmp/bitwarden_rs-{{ bitwarden_version }}"
- name: Install binary
copy: src={{ bitwarden_root_dir }}/tmp/bitwarden_rs-{{ bitwarden_version }}/target/release/bitwarden_rs dest="{{ bitwarden_root_dir }}/" mode=755 remote_src=True
notify: restart bitwarden_rs
- when: bitwarden_web_install_mode != 'none'
tags: bitwarden
block:
- name: Download bitwarden web vault
get_url:
url: "{{ bitwarden_web_archive_url }}"
dest: "{{ bitwarden_root_dir }}/tmp"
checksum: sha1:{{ bitwarden_web_archive_sha1 }}
- name: Extract the archive
unarchive:
src: "{{ bitwarden_root_dir }}/tmp/bw_web_v{{ bitwarden_web_version }}.tar.gz"
dest: "{{ bitwarden_root_dir }}/tmp"
remote_src: True
- name: Move files to their final location
synchronize:
src: "{{ bitwarden_root_dir }}/tmp/web-vault/"
dest: "{{ bitwarden_root_dir }}/web-vault/"
recursive: True
delete: True
delegate_to: "{{ inventory_hostname }}"
- name: Install systemd unit
template: src=bitwarden_rs.service.j2 dest=/etc/systemd/system/bitwarden_rs.service
register: bitwarden_unit
tags: bitwarden
- name: Reload systemd
systemd: daemon_reload=True
when: bitwarden_unit.changed
tags: bitwarden
- name: Install pre/post backup hooks
template: src={{ item }}-backup.sh.j2 dest=/etc/backup/{{ item }}.d/bitwarden_rs.sh mode=755
loop:
- pre
- post
tags: bitwarden
- import_tasks: ../includes/webapps_create_mysql_db.yml
vars:
- db_name: "{{ bitwarden_db_name }}"
- db_user: "{{ bitwarden_db_user }}"
- db_server: "{{ bitwarden_db_server }}"
- db_pass: "{{ bitwarden_db_pass }}"
when: bitwarden_db_engine == 'mysql'
tags: bitwarden