initial commit
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
75891c3271
129 changed files with 8046 additions and 0 deletions
81
roles/radicale/tasks/main.yml
Normal file
81
roles/radicale/tasks/main.yml
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
---
|
||||
- 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue