summaryrefslogtreecommitdiff
path: root/roles/nginx/auth/whawty-sso/auth/tasks/main.yml
blob: 5ae64b9b52727453e531c3bb9cfececab3beb540 (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
---
- name: create configuration directory
  file:
    path: /etc/nginx/auth/whawty-sso
    state: directory

- name: make sure store backend directories exist
  loop: "{{ whawty_nginx_sso_auths | dict2items | selectattr('value.config.cookie.backend.bolt', 'defined') }}"
  loop_control:
    label: "{{ item.key }}"
  file:
    path: "{{ item.value.config.cookie.backend.bolt.path | default('/var/lib/whawty/nginx-sso/'~item.key~'.bolt') | dirname }}"
    state: directory
    mode: 0700

- name: generate configuration file
  loop: "{{ whawty_nginx_sso_auths | dict2items }}"
  loop_control:
    label: "{{ item.key }}"
  copy:
    content: |
      # ansible generated
      {% set ssoconf = item.value.config %}
      {% if 'bolt' in ssoconf.cookie.backend and 'path' not in ssoconf.cookie.backend.bolt %}
      {%   set _dummy = ssoconf.cookie.backend.bolt.update({'path': '/var/lib/whawty/nginx-sso/'~item.key~'.bolt'}) %}
      {% endif %}
      {{ ssoconf | to_nice_yaml(indent=2) }}
    dest: "/etc/nginx/auth/whawty-sso/{{ item.key }}.yml"
    mode: 0400
  notify: restart whawty-nginx-sso

- name: make sure nginx-sso services are enabled and started
  loop: "{{ whawty_nginx_sso_auths | list }}"
  systemd:
    name: "whawty-nginx-sso@{{ item }}.service"
    daemon_reload: yes
    state: started
    enabled: yes