Saltstack Official Nginx Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
642B

  1. {% from "nginx/map.jinja" import nginx with context %}
  2. {% set htauth = nginx.get('htpasswd', '/etc/nginx/.htpasswd') -%}
  3. htpasswd:
  4. pkg.installed:
  5. - name: {{ nginx.apache_utils }}
  6. touch /etc/nginx/.htpasswd:
  7. cmd.run:
  8. - creates: /etc/nginx/.htpasswd
  9. make sure {{ htauth }} exists:
  10. file.exists:
  11. - name: {{ htauth }}
  12. {% for name, user in pillar.get('users', {}).items() %}
  13. {% if user['webauth'] is defined -%}
  14. nginx_user_{{name}}:
  15. module.run:
  16. - name: basicauth.adduser
  17. - user: {{ name }}
  18. - passwd: {{ user['webauth'] }}
  19. - path: {{ htauth }}
  20. - require:
  21. - pkg: htpasswd
  22. {% endif -%}
  23. {% endfor %}