1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_etesync_dav.git synced 2024-08-16 10:09:54 +02:00

Create Etesync.dav setup

This commit is contained in:
L3D 2023-10-24 02:11:32 +02:00
parent 957301147d
commit 9e8fffa145
No known key found for this signature in database
GPG key ID: AD65B920933B4B20
8 changed files with 100 additions and 5 deletions

View file

@ -1,5 +1,7 @@
---
etesync_dav__user: 'etesync_dav'
etesync_dav__version: 'latest'
etesync_dav__executable: '/usr/local/bin/etesync-dav'
etesync_dav__port: '37358'
# should we do a version check? (recomended)
submodules_versioncheck: false

15
handlers/main.yml Normal file
View file

@ -0,0 +1,15 @@
---
- name: Run systemctl enable etesync-dav.service
become: true
ansible.builtin.systemd:
name: 'etesync-dav.service'
enabled: true
state: 'started'
daemon_reload: true
- name: Run systemctl restart etesync-dav.service
become: true
ansible.builtin.systemd:
name: 'etesync-dav.service'
enabled: true
state: 'restarted'

View file

@ -0,0 +1,10 @@
---
- name: "Download etesync-dav version v{{ etesync_dav__version_target }}"
become: true
ansible.builtin.get_url:
url: "{{ etesync_dav__dl_url }}"
dest: "{{ etesync_dav__executable }}"
owner: root
group: root
mode: "0755"
notify: 'Run systemctl restart etesync-dav.service'

View file

@ -0,0 +1,38 @@
---
- name: "Determine 'latest' version release"
when: etesync_dav__version == "latest"
block:
- name: "Get latest etesync-dav release metadata"
ansible.builtin.uri:
url: "{{ etesync_dav__repo_api }}"
return_content: true
register: etesync_dav__remote_metadata
become: false
when: not ansible_check_mode
- name: "Fail if running in check mode without versions set."
ansible.builtin.fail:
msg: |
"You are running this playbook in check mode:
Please set the desired version with the variable
'etesync_dav__version', because the URI module cannot detect the latest version in this mode."
when: ansible_check_mode and (etesync_dav__version == 'latest')
- name: "Set fact latest etesync-dav release"
ansible.builtin.set_fact:
etesync_dav__remote_version: "{{ etesync_dav__remote_metadata.json.tag_name[1:] }}"
when: not ansible_check_mode
- name: "Set etesync-dav version target (latest)"
ansible.builtin.set_fact:
etesync_dav__version_target: "{{ etesync_dav__remote_version }}"
when: not ansible_check_mode
- name: "Set etesync-dav version target {{ etesync_dav__version }}"
ansible.builtin.set_fact:
etesync_dav__version_target: "{{ etesync_dav__version }}"
when: etesync_dav__version != "latest"
- name: "Generate etesync-dav download URL"
ansible.builtin.set_fact:
etesync_dav__dl_url: "https://github.com/etesync/etesync-dav/releases/download/v{{ etesync_dav__version_target }}/linux-amd64-etesync-dav"

View file

@ -2,3 +2,12 @@
- name: Run optional versionscheck
ansible.builtin.include_tasks: versioncheck.yml
when: submodules_versioncheck | bool
- name: Get Version of etesync-dav
ansible.builtin.include_tasks: tasks/get_version_of_etesync_dav.yml
- name: Download etesync-dav
ansible.builtin.include_tasks: download_etesync_dav.yml
- name: Setup Systemd service
ansible.builtin.include_tasks: setup_systemd.yml

12
tasks/setup_systemd.yml Normal file
View file

@ -0,0 +1,12 @@
---
- name: Generate etesync-dav.service
become: true
ansible.builtin.template:
src: 'templates/etesync-dav.service.j2'
dest: '/usr/lib/systemd/system/etesync-dav.service'
mode: '0644'
owner: 'root'
group: 'root'
notify:
- 'Run systemctl restart etesync-dav.service'
- 'Run systemctl enable etesync-dav.service'

View file

@ -0,0 +1,11 @@
{{ ansible_managed | comment }}
[Unit]
Description=Cal/CardDAV frontend for Etesync
[Service]
Type=simple
Environment=ETESYNC_LISTEN_PORT={{ etesync_dav__port }}
ExecStart={{ etesync_dav__executable }}
[Install]
WantedBy=default.target

View file

@ -1,8 +1,6 @@
---
etesync_dav__repo: 'https://github.com/etesync/server.git'
etesync_dav__repo_api: 'https://api.github.com/repos/etesync/server/tags'
etesync_dav__venv: "{{ etesync_dav__venv_path }}/{{ etesync_dav_version_target }}"
etesync_dav__repo_api: 'https://api.github.com/repos/etesync/etesync-dav/releases/latest'
# versionscheck
playbook_version_number: 15 # should be a integer
playbook_version_number: 16
playbook_version_path: 'role-l3d.etesync_dav.version'