ansible-role-roundcube/tasks/validate_config.yml

52 lines
2.1 KiB
YAML
Raw Normal View History

2023-09-30 19:35:10 +00:00
---
- name: Fail if required Roundcube settings not defined
ansible.builtin.fail:
msg: >
You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''"
with_items:
- roundcube_identifier
- roundcube_uid
- roundcube_gid
- roundcube_hostname
- roundcube_path_prefix
- roundcube_container_network
- roundcube_default_imap_host
- roundcube_smtp_server
- name: Fail if Roundcube database type invalid
ansible.builtin.fail:
msg: >-
roundcube_database_type must be 'postgresql' or 'sqlite'
when: "roundcube_database_type not in ['postgresql', 'sqlite']"
- name: Fail if required Roundcube + Postgres integration settings not defined
ansible.builtin.fail:
msg: >-
You need to define a required configuration setting (`{{ item }}`) when `roundcube_database_type` is `postgresql`
when: "roundcube_database_type == 'postgresql' and vars[item] == ''"
with_items:
- roundcube_database_username
- roundcube_database_password
- when: roundcube_container_labels_traefik_enabled | bool
block:
- name: Fail if required Roundcube Traefik settings not defined
ansible.builtin.fail:
msg: >-
You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''"
with_items:
- roundcube_container_labels_traefik_hostname
- roundcube_container_labels_traefik_path_prefix
# We ensure it doesn't end with a slash, because we handle both (slash and no-slash).
# Knowing that `roundcube_container_labels_traefik_path_prefix` does not end with a slash
# ensures we know how to set these routes up without having to do "does it end with a slash" checks elsewhere.
- name: Fail if roundcube_container_labels_traefik_path_prefix ends with a slash
ansible.builtin.fail:
msg: >-
roundcube_container_labels_traefik_path_prefix (`{{ roundcube_container_labels_traefik_path_prefix }}`) must either be `/` or not end with a slash (e.g. `/roundcube`).
when: "roundcube_container_labels_traefik_path_prefix != '/' and roundcube_container_labels_traefik_path_prefix[-1] == '/'"