radicale/tasks/main.yaml

76 lines
3.7 KiB
YAML
Raw Permalink Normal View History

2019-10-08 18:18:14 +00:00
---
- name: Install Radicale package dependencies.
2019-10-11 16:57:11 +00:00
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.
2019-10-08 18:18:14 +00:00
- 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') }}"
2020-06-07 13:25:38 +00:00
crypt_scheme: "apr_md5_crypt"
2019-10-08 18:18:14 +00:00
loop: "{{ radicale_users }}"
- name: Set Radicale user with password hash.
2020-06-04 20:24:05 +00:00
when: item.md5_hash is defined
2019-10-08 18:18:14 +00:00
no_log: true
lineinfile:
path: "{{ radicale_config.auth.htpasswd_filename | default('/var/lib/radicale/users.htpasswd') }}"
2020-06-04 20:24:05 +00:00
line: "{{ item.name }}:{{ item.md5_hash }}"
2019-10-08 18:18:14 +00:00
state: "{{ item.state | default('present') }}"
loop: "{{ radicale_users }}"
2020-01-19 12:41:09 +00:00
- name: create custom systemd folder
file:
path: /etc/systemd/system/radicale.service.d/ # required. Path to the file being managed.
state: directory # not required. choices: absent;directory;file;hard;link;touch. If C(directory), all intermediate subdirectories will be created if they do not exist. Since Ansible 1.7 they will be created with the supplied permissions. If C(file), the file will NOT be created if it does not exist; see the C(touch) value or the M(copy) or M(template) module if you want that behavior. If C(link), the symbolic link will be created or changed. Use C(hard) for hardlinks. If C(absent), directories will be recursively deleted, and files or symlinks will be unlinked. Note that C(absent) will not cause C(file) to fail if the C(path) does not exist as the state did not change. If C(touch) (new in 1.4), an empty file will be created if the C(path) does not exist, while an existing file or directory will receive updated file access and modification times (similar to the way `touch` works from the command line).
- name: apply override file for systemd
template:
dest: /etc/systemd/system/radicale.service.d/override.conf # required. Location to render the template to on the remote machine.
src: systemd/override.j2 # required. Path of a Jinja2 formatted template on the Ansible controller. This can be a relative or absolute path.
notify:
- Restart Radicale.
2019-10-08 18:18:14 +00:00
- name: Start and enable Radicale service.
service:
name: radicale
state: "{{ radicale_service_state }}"
enabled: true
2020-01-19 12:41:09 +00:00