Dynamic module management (closes #23)
parent
ef3440a015
commit
42bb4a3e2b
|
@ -13,6 +13,7 @@ Features:
|
||||||
- Fast PHP configuration
|
- Fast PHP configuration
|
||||||
- Preconfigured vhost templates (should work on many app)
|
- Preconfigured vhost templates (should work on many app)
|
||||||
- Auto-configure HTTP2 on SSL/TLS vhosts
|
- Auto-configure HTTP2 on SSL/TLS vhosts
|
||||||
|
- Manage dynamic modules (install and loading)
|
||||||
|
|
||||||
Requirements
|
Requirements
|
||||||
------------
|
------------
|
||||||
|
@ -50,6 +51,7 @@ FreeBSD:
|
||||||
- `nginx_events_*`: all variables in events block
|
- `nginx_events_*`: all variables in events block
|
||||||
- `nginx_http_*`: all variables in http block
|
- `nginx_http_*`: all variables in http block
|
||||||
- `nginx_custom_http`: instructions list (will put data in `/etc/nginx/conf.d/custom.conf`)
|
- `nginx_custom_http`: instructions list (will put data in `/etc/nginx/conf.d/custom.conf`)
|
||||||
|
- `nginx_dyn_modules`: dynamic module list to load
|
||||||
|
|
||||||
Fine configuration
|
Fine configuration
|
||||||
------------------
|
------------------
|
||||||
|
|
|
@ -105,6 +105,11 @@ nginx_htpasswd: []
|
||||||
#
|
#
|
||||||
nginx_ssl_pairs: []
|
nginx_ssl_pairs: []
|
||||||
|
|
||||||
|
#
|
||||||
|
# Dynamic modules
|
||||||
|
#
|
||||||
|
nginx_dyn_modules: []
|
||||||
|
|
||||||
#
|
#
|
||||||
# Diffie-Hellman
|
# Diffie-Hellman
|
||||||
#
|
#
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: FAIL | If Dynamic module is not available
|
||||||
|
fail: msg="{{ item }} dynamic module is not available"
|
||||||
|
with_items: "{{ nginx_dyn_modules }}"
|
||||||
|
when: "'{{ item }}=dynamic' not in nginx_modules"
|
||||||
|
|
||||||
|
- name: APT | Install nginx modules
|
||||||
|
apt: >
|
||||||
|
pkg="libnginx-mod-{{ item | replace('_', '-') }}"
|
||||||
|
state=present
|
||||||
|
default_release={{ ansible_distribution_release + '-backports' if nginx_backports else ansible_distribution_release }}
|
||||||
|
with_items: "{{ nginx_dyn_modules }}"
|
||||||
|
when: ansible_distribution == 'Debian'
|
||||||
|
|
||||||
|
# TODO: manage freebsd
|
|
@ -9,6 +9,10 @@
|
||||||
- name: INCLUDE | Prepare
|
- name: INCLUDE | Prepare
|
||||||
include: prepare.yml
|
include: prepare.yml
|
||||||
|
|
||||||
|
- name: INCLUDE | Manage dynamic modules
|
||||||
|
include: dyn_modules.yml
|
||||||
|
when: nginx_version.stdout | version_compare('1.9.1', 'ge')
|
||||||
|
|
||||||
- name: INCLUDE | Install
|
- name: INCLUDE | Install
|
||||||
include: config.yml
|
include: config.yml
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: SHELL | Get module list
|
- name: SHELL | Get module list
|
||||||
shell: nginx -V 2>&1 | tr -- - '\n' | grep -A 1 with | grep _module | sed 's/_module[[:space:]]*//g' | sort
|
shell: nginx -V 2>&1 | tr -- - '\n' | grep -A 1 with | grep _module | sed -r 's/_module//g; s/\s+//g' | sort
|
||||||
args:
|
args:
|
||||||
executable: /bin/sh
|
executable: /bin/sh
|
||||||
register: shell_modules
|
register: shell_modules
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
user {{ nginx_user }};
|
user {{ nginx_user }};
|
||||||
worker_processes {{ nginx_worker_processes }};
|
worker_processes {{ nginx_worker_processes }};
|
||||||
pid {{ nginx_pid }};
|
pid {{ nginx_pid }};
|
||||||
|
{% if nginx_version.stdout | version_compare('1.9.1', 'ge') %}
|
||||||
|
{% for module in nginx_dyn_modules -%}
|
||||||
|
load_module "modules/ngx_{{ module }}_module.so";
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
events {
|
events {
|
||||||
worker_connections {{ nginx_events_worker_connections }};
|
worker_connections {{ nginx_events_worker_connections }};
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
nginx_backports: true
|
nginx_backports: true
|
||||||
nginx_php56: true
|
nginx_php56: true
|
||||||
nginx_php70: true
|
nginx_php70: true
|
||||||
|
nginx_dyn_modules: ['http_geoip']
|
||||||
nginx_upstreams:
|
nginx_upstreams:
|
||||||
- name: 'test'
|
- name: 'test'
|
||||||
servers:
|
servers:
|
||||||
|
@ -106,6 +107,13 @@
|
||||||
-----END CERTIFICATE-----
|
-----END CERTIFICATE-----
|
||||||
nginx_custom_http:
|
nginx_custom_http:
|
||||||
- 'add_header X-ansible 1;'
|
- 'add_header X-ansible 1;'
|
||||||
|
- 'geoip_country /usr/share/GeoIP/GeoIP.dat;'
|
||||||
|
- 'map $geoip_country_code $allowed_country {'
|
||||||
|
- ' default yes;'
|
||||||
|
- ' MA no;'
|
||||||
|
- ' DZ no;'
|
||||||
|
- ' TN no;'
|
||||||
|
- '}'
|
||||||
nginx_default_vhost: 'first-test'
|
nginx_default_vhost: 'first-test'
|
||||||
nginx_default_vhost_ssl: 'test-ssl-predeployed.local'
|
nginx_default_vhost_ssl: 'test-ssl-predeployed.local'
|
||||||
nginx_vhosts:
|
nginx_vhosts:
|
||||||
|
|
Loading…
Reference in New Issue