88 lines
2.0 KiB
YAML
88 lines
2.0 KiB
YAML
---
|
|
- name: Ensure bibliogram user exists
|
|
ansible.builtin.user:
|
|
name: bibliogram
|
|
state: present
|
|
system: yes
|
|
|
|
- name: Ensure dependencies are present
|
|
apt:
|
|
name:
|
|
- npm
|
|
- git
|
|
- sudo
|
|
state: present
|
|
|
|
- name: Ensure the repo is present
|
|
git:
|
|
repo: https://git.sr.ht/~cadence/bibliogram
|
|
dest: "{{ ansible_bibliogram_root_directory }}"
|
|
ignore_errors: yes
|
|
|
|
- name: Fix the root directory permissions
|
|
file:
|
|
path: "{{ ansible_bibliogram_root_directory }}"
|
|
state: directory
|
|
owner: bibliogram
|
|
group: www-data
|
|
recurse: yes
|
|
|
|
- name: Ensure the upgrade script is present
|
|
template:
|
|
src: upgrade.sh.j2
|
|
dest: /usr/local/bin/upgrade_bibliogram.sh
|
|
mode: 0755
|
|
owner: bibliogram
|
|
group: www-data
|
|
register: upgrade_script
|
|
|
|
- name: Run upgrade script
|
|
shell: sudo -u bibliogram /usr/local/bin/upgrade_bibliogram.sh
|
|
when: upgrade_script is defined and upgrade_script.changed
|
|
|
|
- name: Ensure the configuration is present
|
|
template:
|
|
src: config.js.j2
|
|
dest: "{{ ansible_bibliogram_root_directory }}/config.js"
|
|
mode: 0644
|
|
owner: bibliogram
|
|
group: www-data
|
|
|
|
- name: Ensure the service unit is present
|
|
template:
|
|
src: bibliogram.service.j2
|
|
dest: /etc/systemd/system/bibliogram.service
|
|
mode: 0600
|
|
owner: root
|
|
group: root
|
|
notify: Restart service
|
|
|
|
- name: Ensure the upgrade service unit is present
|
|
template:
|
|
src: bibliogram-upgrade.service.j2
|
|
dest: /etc/systemd/system/bibliogram-upgrade.service
|
|
mode: 0600
|
|
owner: root
|
|
group: root
|
|
|
|
- name: Ensure the timer is present
|
|
template:
|
|
src: bibliogram-upgrade.timer.j2
|
|
dest: /etc/systemd/system/bibliogram-upgrade.timer
|
|
mode: 0600
|
|
owner: root
|
|
group: root
|
|
notify: Restart timer
|
|
|
|
- name: Ensure the service unit is enabled and started
|
|
systemd:
|
|
name: bibliogram.service
|
|
state: started
|
|
enabled: yes
|
|
|
|
- name: Ensure the timer is enabled and started
|
|
systemd:
|
|
name: bibliogram-upgrade.timer
|
|
state: started
|
|
enabled: yes
|