paulbsd-salt/states/nginx/auth.sls

26 lines
684 B
Plaintext
Raw Normal View History

2020-07-10 00:58:55 +02:00
---
{%- from "nginx/map.jinja" import nginx with context %}
{%- from "nginx/map.jinja" import users with context %}
2020-07-10 00:58:55 +02:00
{%- for key, value in users.items() %}
{%- if value.state == 'present' %}
2020-07-10 00:58:55 +02:00
nginx-auth-present-{{ key }}:
2020-07-10 00:58:55 +02:00
webutil.user_exists:
- 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 %}
nginx-auth-absent-{{ key }}:
2020-07-10 00:58:55 +02:00
webutil.user_absent:
- 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 %}