summaryrefslogtreecommitdiff
path: root/roles/whawty/auth/store/tasks/main.yml
blob: 9a0ea26be28698adfa76da4a808946ac7d57ef02 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
---
- name: make sure config directory exists
  file:
    path: /etc/whawty/auth/
    state: directory

- name: create store base directory
  loop: "{{ whawty_auth_store_instances | dict2items }}"
  loop_control:
    label: "{{ item.key }}"
  file:
    path: "{{ item.value.config.basedir }}"
    state: directory
    mode: "{{ item.value.permissions['dir-mode'] | default(omit) }}"
    owner: "{{ item.value.permissions.owner | default(omit) }}"
    group: "{{ item.value.permissions.group | default(omit) }}"

- name: generate store config file
  loop: "{{ whawty_auth_store_instances | dict2items }}"
  loop_control:
    label: "{{ item.key }}"
  copy:
    content: "{{ item.value.config | to_nice_yaml(indent=2) }}"
    dest: "/etc/whawty/auth/store-{{ item.key }}.yml"
    mode: "{{ item.value.permissions['file-mode'] | default(omit) }}"
    owner: "{{ item.value.permissions.owner | default(omit) }}"
    group: "{{ item.value.permissions.group | default(omit) }}"

- name: install rsync
  when: "(whawty_auth_store_instances | dict2items | selectattr('value.sync', 'defined') | length) > 0"
  apt:
    name: rsync
    state: present

- name: configure sync
  loop: "{{ whawty_auth_store_instances | dict2items }}"
  loop_control:
    label: "{{ item.key }}"
  when: "'sync' in item.value"
  include_tasks: "sync-{{ item.value.sync.type }}.yml"