2020-07-10 00:58:55 +02:00
|
|
|
---
|
|
|
|
{%- from "nginx/map.jinja" import nginx with context %}
|
2022-02-21 13:52:46 +01:00
|
|
|
{%- from "nginx/map.jinja" import users with context %}
|
2020-07-10 00:58:55 +02:00
|
|
|
|
2022-02-21 13:52:46 +01:00
|
|
|
{%- for key, value in users.items() %}
|
|
|
|
{%- if value.state == 'present' %}
|
2020-07-10 00:58:55 +02:00
|
|
|
|
2022-02-21 13:52:46 +01:00
|
|
|
nginx-auth-present-{{ key }}:
|
2020-07-10 00:58:55 +02:00
|
|
|
webutil.user_exists:
|
2022-02-21 13:52:46 +01:00
|
|
|
- name: {{ key }}
|
|
|
|
{%- if value.password is defined %}
|
|
|
|
- password: {{ value.password }}
|
2020-07-10 00:58:55 +02:00
|
|
|
{%- endif %}
|
|
|
|
- htpasswd_file: {{ nginx.config.dir }}/auth/htpasswd
|
|
|
|
- require:
|
|
|
|
- file: nginx-config-dir-auth
|
|
|
|
|
|
|
|
{%- else %}
|
2022-02-21 13:52:46 +01:00
|
|
|
nginx-auth-absent-{{ key }}:
|
2020-07-10 00:58:55 +02:00
|
|
|
webutil.user_absent:
|
2022-02-21 13:52:46 +01:00
|
|
|
- name: {{ key }}
|
2020-07-10 00:58:55 +02:00
|
|
|
- htpasswd_file: {{ nginx.config.dir }}/auth/htpasswd
|
|
|
|
- require:
|
|
|
|
- file: nginx-config-dir-auth
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|