paulbsd-salt/states/nginx/auth.sls
2020-07-10 00:58:55 +02:00

25 lines
661 B
Plaintext

---
{%- from "nginx/map.jinja" import nginx with context %}
{%- for user in salt['pillar.get']('htpasswds') %}
{%- if user.state == 'present' %}
nginx-auth-present-{{ user.name }}:
webutil.user_exists:
- name: {{ user.name }}
{%- if user.password is defined %}
- password: {{ user.password }}
{%- endif %}
- htpasswd_file: {{ nginx.config.dir }}/auth/htpasswd
- require:
- file: nginx-config-dir-auth
{%- else %}
nginx-auth-absent-{{ user.name }}:
webutil.user_absent:
- name: {{ user.name }}
- htpasswd_file: {{ nginx.config.dir }}/auth/htpasswd
- require:
- file: nginx-config-dir-auth
{%- endif %}
{%- endfor %}