radicale/tasks/main.yaml
2019-10-11 18:57:11 +02:00

61 lines
2.3 KiB
YAML

---
- name: Install Radicale package dependencies.
package:
state: present # required. Whether to install (C(present)), or remove (C(absent)) a package. Other states depend on the underlying package module, i.e C(latest).
name: radicale # required. Package name, or package specifier with version, like C(name-1.0).,Be aware that packages are not always named the same and this module will not 'translate' them per distro.
use: auto # not required. The required package manager module to use (yum, apt, etc). The default 'auto' will use existing facts or try to autodetect it.,You should only use this field if the automatic selection is not working for some reason.
- name: Write Radicale configuration file.
template:
src: etc/radicale/config.j2
dest: /etc/radicale/config
notify:
- Restart Radicale.
- name: Write Radicale user rights configuration.
copy:
src: rights.conf
dest: "{{ radicale_server_home_dir }}/rights.conf"
notify:
- Restart Radicale.
- name: Ensure Radicale user accounts are defined.
when:
- radicale_config.auth is defined
- radicale_config.auth.type is defined
- radicale_config.auth.type == "htpasswd"
block:
- name: Ensure Radicale htpasswd file exists.
file:
path: "{{ radicale_config.auth.htpasswd_filename | default('/var/lib/radicale/users.htpasswd') }}"
state: touch
access_time: preserve
modification_time: preserve
- name: Set Radicale user with password.
when: item.password is defined
no_log: true
htpasswd:
path: "{{ radicale_config.auth.htpasswd_filename | default('/var/lib/radicale/users.htpasswd') }}"
name: "{{ item.name }}"
password: "{{ item.password }}"
state: "{{ item.state | default('present') }}"
crypt_scheme: "bcrypt"
loop: "{{ radicale_users }}"
- name: Set Radicale user with password hash.
when: item.bcrypt_hash is defined
no_log: true
lineinfile:
path: "{{ radicale_config.auth.htpasswd_filename | default('/var/lib/radicale/users.htpasswd') }}"
line: "{{ item.name }}:{{ item.bcrypt_hash }}"
state: "{{ item.state | default('present') }}"
loop: "{{ radicale_users }}"
- name: Start and enable Radicale service.
service:
name: radicale
state: "{{ radicale_service_state }}"
enabled: true