nginx-formula/nginx/users.sls

31 lines
648 B
Plaintext
Raw Normal View History

{% from "nginx/map.jinja" import nginx with context %}
{% set htauth = nginx.get('htpasswd', '/etc/nginx/.htpasswd') -%}
htpasswd:
pkg.installed:
- name: {{ nginx.apache_utils }}
2018-01-24 16:56:43 +01:00
touch {{ htauth }}:
2018-01-24 16:44:51 +01:00
cmd.run:
2018-01-24 16:56:43 +01:00
- creates: {{ htauth }}
2018-01-24 16:44:51 +01:00
make sure {{ htauth }} exists:
file.managed:
- name: {{ htauth }}
- makedirs: True
{% for name, user in pillar.get('users', {}).items() %}
{% if user['webauth'] is defined -%}
nginx_user_{{name}}:
module.run:
- name: basicauth.adduser
- user: {{ name }}
- passwd: {{ user['webauth'] }}
- path: {{ htauth }}
- require:
- pkg: htpasswd
{% endif -%}
{% endfor %}