summaryrefslogtreecommitdiff
path: root/roles/nginx/auth/basic/tasks/main.yml
blob: 6de2c43390dded2c848deaee49cddc9e0c8f186e (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', (user~'@'~inventory_hostname~'/nginx') | apr_md5_crypt_salt) }}
      {% endfor %}