2014-06-18 11:57:05 +02:00
|
|
|
{% from "nginx/map.jinja" import nginx with context %}
|
2013-08-21 21:01:51 +02:00
|
|
|
{% set htauth = nginx.get('htpasswd', '/etc/nginx/.htpasswd') -%}
|
|
|
|
|
|
|
|
htpasswd:
|
|
|
|
pkg.installed:
|
2014-06-18 11:57:05 +02:00
|
|
|
- name: {{ nginx.apache_utils }}
|
2013-08-21 21:01:51 +02:00
|
|
|
|
2016-11-16 11:18:15 +01:00
|
|
|
make sure {{ htauth }} exists:
|
2018-04-24 11:20:08 +02:00
|
|
|
file.managed:
|
2016-11-16 11:18:15 +01:00
|
|
|
- name: {{ htauth }}
|
2018-04-24 11:01:29 +02:00
|
|
|
- makedirs: True
|
2016-11-16 11:18:15 +01:00
|
|
|
|
2013-08-21 21:01:51 +02:00
|
|
|
{% 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 -%}
|
2016-11-16 11:18:15 +01:00
|
|
|
{% endfor %}
|