summaryrefslogtreecommitdiff
path: root/roles/nginx/auth/basic/tasks/main.yml
blob: 1eb991836f616fccf6b6a4c1e87927ab3e97ba7c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
---
- name: create authentication directory
  file:
    state: directory
    path: /etc/nginx/auth/
    owner: root
    group: www-data
    mode: 0750

- name: generate user entries
  copy:
    dest: "/etc/nginx/auth/{{ nginx_auth_basic_filename }}.htpasswd"
    owner: root
    group: www-data
    mode: 0640
    content: |
      {% for user,password in nginx_auth_basic_users.items() %}
      {{ user }}:{{ password | password_hash('apr_md5_crypt', 65534 | random(seed=(inventory_hostname+user)) | string) }}
      {% endfor %}