82 lines
2 KiB
YAML
82 lines
2 KiB
YAML
|
|
---
|
||
|
|
- name: Create radicale directories
|
||
|
|
file:
|
||
|
|
path: "{{ item }}"
|
||
|
|
state: directory
|
||
|
|
mode: '0755'
|
||
|
|
loop:
|
||
|
|
- /srv/radicale
|
||
|
|
- /srv/radicale/data
|
||
|
|
- /srv/radicale/config
|
||
|
|
|
||
|
|
- name: Create radicale configuration
|
||
|
|
template:
|
||
|
|
src: config.j2
|
||
|
|
dest: /srv/radicale/config/config
|
||
|
|
mode: '0644'
|
||
|
|
notify: restart radicale
|
||
|
|
|
||
|
|
- name: Check for cached radicale hash
|
||
|
|
ansible.builtin.stat:
|
||
|
|
path: /srv/radicale/config/.radicale_hash
|
||
|
|
register: _radicale_hash_stat
|
||
|
|
|
||
|
|
- name: Read radicale hash from cache
|
||
|
|
ansible.builtin.slurp:
|
||
|
|
src: /srv/radicale/config/.radicale_hash
|
||
|
|
register: _radicale_hash_file
|
||
|
|
when: _radicale_hash_stat.stat.exists
|
||
|
|
|
||
|
|
- name: Set radicale hash fact from cache
|
||
|
|
ansible.builtin.set_fact:
|
||
|
|
_radicale_hash: "{{ _radicale_hash_file.content | b64decode | trim }}"
|
||
|
|
when: _radicale_hash_stat.stat.exists
|
||
|
|
|
||
|
|
- name: Generate radicale password hash
|
||
|
|
command:
|
||
|
|
argv:
|
||
|
|
- docker
|
||
|
|
- run
|
||
|
|
- --rm
|
||
|
|
- caddy:2
|
||
|
|
- caddy
|
||
|
|
- hash-password
|
||
|
|
- --plaintext
|
||
|
|
- "{{ radicale_password }}"
|
||
|
|
register: _radicale_hash_result
|
||
|
|
changed_when: false
|
||
|
|
no_log: true
|
||
|
|
when: not _radicale_hash_stat.stat.exists
|
||
|
|
|
||
|
|
- name: Cache radicale hash
|
||
|
|
ansible.builtin.copy:
|
||
|
|
content: "{{ _radicale_hash_result.stdout }}"
|
||
|
|
dest: /srv/radicale/config/.radicale_hash
|
||
|
|
mode: "0600"
|
||
|
|
when: not _radicale_hash_stat.stat.exists
|
||
|
|
|
||
|
|
- name: Set radicale hash fact from generation
|
||
|
|
ansible.builtin.set_fact:
|
||
|
|
_radicale_hash: "{{ _radicale_hash_result.stdout }}"
|
||
|
|
when: not _radicale_hash_stat.stat.exists
|
||
|
|
|
||
|
|
- name: Create radicale users file
|
||
|
|
copy:
|
||
|
|
content: "{{ admin_user }}:{{ _radicale_hash }}"
|
||
|
|
dest: /srv/radicale/config/users
|
||
|
|
mode: '0644'
|
||
|
|
notify: restart radicale
|
||
|
|
|
||
|
|
- name: Create compose file
|
||
|
|
template:
|
||
|
|
src: compose.yml.j2
|
||
|
|
dest: /srv/radicale/compose.yml
|
||
|
|
mode: '0644'
|
||
|
|
notify: restart radicale
|
||
|
|
|
||
|
|
- name: Deploy radicale
|
||
|
|
community.docker.docker_compose_v2:
|
||
|
|
project_src: /srv/radicale
|
||
|
|
state: present
|
||
|
|
build: never
|