52 lines
1.5 KiB
YAML
52 lines
1.5 KiB
YAML
---
|
|
# tasks file for mlmmj-newlist
|
|
- name: register a list_domain variable/fact
|
|
set_fact:
|
|
list_domain: "{{ mailinglist.split('@') }}"
|
|
|
|
- name: find mailinglist folder according to ansible config
|
|
stat:
|
|
path: '{{ spool_dir }}/{{ list_domain[1] }}/{{ list_domain[0] }}'
|
|
register: listpath
|
|
|
|
- name: fail if listpath does not exists
|
|
fail:
|
|
msg: 'It seems the mailinglist folder does not exists'
|
|
when: not listpath.stat.exists
|
|
|
|
- name: setting boolean config vars for list
|
|
file:
|
|
path: '{{ listpath.stat.path }}/control/{{ item.name }}'
|
|
owner: '{{ user|default("mlmmj") }}'
|
|
group: '{{ group|default("root") }}'
|
|
mode: '0640'
|
|
state: 'touch'
|
|
loop: '{{ mlmmj_config.boolean }}'
|
|
when: item.value
|
|
|
|
- name: make sure boolean config vars for list removed
|
|
file:
|
|
path: '{{ listpath.stat.path }}/control/{{ item.name }}'
|
|
state: 'absent'
|
|
loop: '{{ mlmmj_config.boolean }}'
|
|
when: not item.value
|
|
|
|
- name: setting complex config vars for list via templates
|
|
template:
|
|
src: 'templates/control/{{ item.name }}.j2'
|
|
dest: '{{ listpath.stat.path }}/control/{{ item.name }}'
|
|
owner: '{{ user|default("mlmmj") }}'
|
|
group: '{{ group|default("root") }}'
|
|
mode: '0640'
|
|
loop: '{{ mlmmj_config.templates }}'
|
|
when: item.value
|
|
|
|
- name: make sure complex config vars for list are removed
|
|
file:
|
|
path: '{{ listpath.stat.path }}/control/{{ item.name }}'
|
|
state: 'absent'
|
|
loop: '{{ mlmmj_config.templates }}'
|
|
when: not item.value
|
|
|
|
|