mirror of
https://github.com/HanXHX/ansible-nginx.git
synced 2026-02-24 09:03:29 +07:00
Meilleure gestion des dossiers et htpasswd par location
This commit is contained in:
19
tasks/htpasswd.yml
Normal file
19
tasks/htpasswd.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
|
||||
- name: FILE | Delete htpasswd file
|
||||
file: >
|
||||
path={{ nginx_htpasswd_dir }}/{{ item.name }}
|
||||
state=absent
|
||||
with_items: nginx_htpasswd
|
||||
when: item.state is defined and item.state == 'absent'
|
||||
|
||||
- name: HTPASSWD | Manage files
|
||||
htpasswd: >
|
||||
name={{ item.1.name }}
|
||||
password={{ item.1.password }}
|
||||
state={{ item.1.state | default('present') }}
|
||||
path={{ nginx_htpasswd_dir }}/{{ item.0.name }}
|
||||
with_subelements:
|
||||
- nginx_htpasswd
|
||||
- users
|
||||
when: item.0.state is not defined or item.0.state == 'present'
|
||||
4
tasks/legacy.yml
Normal file
4
tasks/legacy.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
|
||||
- name: FILE | Remove old directories
|
||||
file: path=/etc/nginx/helpers state=absent
|
||||
@@ -1,7 +1,10 @@
|
||||
---
|
||||
|
||||
- name: APT | Install nginx
|
||||
apt: pkg={{ nginx_apt_package }} state=latest update_cache=yes cache_valid_time=3600
|
||||
- name: APT | Install nginx and dependencies
|
||||
apt: pkg={{ item }} state=latest update_cache=yes cache_valid_time=3600
|
||||
with_items:
|
||||
- "{{ nginx_apt_package }}"
|
||||
- python-passlib
|
||||
|
||||
- name: SHELL | Get Nginx version
|
||||
shell: nginx -v 2>&1 | sed -r 's#.*/##;' | cut -d ' ' -f 1
|
||||
@@ -14,11 +17,12 @@
|
||||
dest=/etc/nginx/nginx.conf
|
||||
notify: reload nginx
|
||||
|
||||
- name: FILE | Create /etc/nginx/helpers
|
||||
file: dest=/etc/nginx/helpers owner=root mode=0755 state=directory
|
||||
- name: INCLUDE | Fix legacy
|
||||
include: legacy.yml
|
||||
|
||||
- name: FILE | Create /etc/nginx/ssl
|
||||
file: dest=/etc/nginx/ssl owner=root mode=0755 state=directory
|
||||
- name: FILE | Create folders
|
||||
file: dest={{ item }} owner=root mode=0755 state=directory
|
||||
with_items: "{{ nginx_dirs }}"
|
||||
|
||||
#- name: COMMAND | Creates DH file
|
||||
# command: openssl dhparam -out {{ nginx_dh_path }} {{ nginx_dh_length }}
|
||||
@@ -28,14 +32,17 @@
|
||||
- name: TEMPLATE | Deploy all helpers
|
||||
template: >
|
||||
src={{ item }}
|
||||
dest=/etc/nginx/helpers/{{ item | basename | regex_replace('\.j2$','') }}
|
||||
with_fileglob: '../templates/etc/nginx/helpers/*.j2'
|
||||
dest={{ nginx_helper_dir }}/{{ item | basename | regex_replace('\.j2$','') }}
|
||||
with_fileglob: '../templates/etc/nginx/helper/*.j2'
|
||||
notify: reload nginx
|
||||
|
||||
- name: INCLUDE | Upstream configuration
|
||||
include: upstream.yml
|
||||
when: nginx_php
|
||||
|
||||
- name: INCLUDE | htpasswd configuration
|
||||
include: htpasswd.yml
|
||||
|
||||
- name: INCLUDE | Vhosts configuration
|
||||
include: vhost.yml
|
||||
|
||||
|
||||
Reference in New Issue
Block a user