paulbsd-salt/states/nginx/auth.sls
Paul Lecuq 201263a0af
All checks were successful
continuous-integration/drone/push Build is passing
updated nginx state
2022-11-08 11:10:53 +01:00

24 lines
682 B
Plaintext

---
{%- from "nginx/map.jinja" import nginx with context %}
{%- from "nginx/map.jinja" import users with context %}
{%- for key, value in users.items() %}
{%- if value.state == 'present' %}
nginx-auth-present-{{ key }}:
webutil.user_exists:
- name: {{ key }}
{%- if value.password is defined %}
- password: {{ value.password }}
{%- endif %}
- htpasswd_file: {{ nginx.config.dir }}/auth/htpasswd
- require:
- file: nginx-config-dir-auth
{%- else %}
nginx-auth-absent-{{ key }}:
webutil.user_absent:
- name: {{ key }}
- htpasswd_file: {{ nginx.config.dir }}/auth/htpasswd
- require:
- file: nginx-config-dir-auth
{%- endif %}
{%- endfor %}