99 lines
2.7 KiB
YAML
99 lines
2.7 KiB
YAML
---
|
|
- hosts: all
|
|
become: yes
|
|
remote_user: ansible
|
|
gather_facts: false
|
|
|
|
vars:
|
|
docker_compose_definition: |
|
|
services:
|
|
cronicle:
|
|
image: ghcr.io/soulteary/cronicle:latest
|
|
container_name: cronicle
|
|
hostname: cronicle
|
|
environment:
|
|
- TZ=America/Chicago
|
|
volumes:
|
|
- /etc/localtime:/etc/localtime:ro
|
|
- /etc/timezone:/etc/timezone:ro
|
|
- ./data/data:/opt/cronicle/data
|
|
- ./data/logs:/opt/cronicle/logs
|
|
- ./data/plugins:/opt/cronicle/plugins
|
|
ports:
|
|
- 3012:3012
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider localhost:3012/api/app/ping || exit 1"]
|
|
interval: 5s
|
|
timeout: 1s
|
|
retries: 3
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
|
|
|
|
tasks:
|
|
- name: Upgrade-packages.yml - update packages
|
|
include: ../../lib/upgrade-packages.yml
|
|
|
|
- name: Install-docker.yml - setting up docker
|
|
include: ../../lib/install-docker.yml
|
|
|
|
- name: Install Restic and setup
|
|
include: ../../lib/setup-restic.yml
|
|
|
|
- name: Setup Restic Cron jobs
|
|
include: ../../lib/setup-restic-cron.yml
|
|
|
|
- name: Setup Service
|
|
copy:
|
|
dest: /etc/systemd/system/cronicle.service
|
|
content: |
|
|
[Unit]
|
|
Description=cronicle
|
|
After=network.target
|
|
|
|
[Service]
|
|
User=cronicle
|
|
WorkingDirectory=/home/docker/
|
|
ExecStart=docker compose up -d
|
|
Restart=always
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
owner: root
|
|
group: root
|
|
mode: '0644'
|
|
|
|
# docker image is broken using manual install method
|
|
- name: Write docker-compose.yml
|
|
ansible.builtin.copy:
|
|
content: "{{ docker_compose_definition }}"
|
|
dest: /home/docker/docker-compose.yml
|
|
owner: docker
|
|
group: docker
|
|
mode: u=rw,g=r,o=r
|
|
|
|
- name: Check if cronicle's data directory exists
|
|
stat:
|
|
path: /data/data
|
|
register: cronicle_stat
|
|
|
|
- name: Restore cronicle Dir
|
|
shell: |
|
|
restic --password-file /home/restic/.resticpassword -r sftp:misamisa://home/restic/$(hostname) --target / restore latest
|
|
args:
|
|
chdir: /home/restic
|
|
creates: /data/cronicle
|
|
when: not cronicle_stat.stat.exists or not cronicle_stat.stat.isdir
|
|
|
|
- name: Reload systemd daemon
|
|
systemd:
|
|
daemon_reload: yes
|
|
|
|
- name: Start cronicle Service
|
|
systemd:
|
|
name: cronicle
|
|
state: started
|
|
enabled: yes |