mirror of
https://github.com/HanXHX/ansible-nginx.git
synced 2026-02-28 09:22:10 +07:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5885c5c55 | ||
|
|
bb5e00d6f5 | ||
|
|
cf010e4a4b | ||
|
|
39d3f5f06a | ||
|
|
247f849b86 | ||
|
|
a03a656b18 | ||
|
|
1239219d90 | ||
|
|
4f94fc2211 | ||
|
|
e89a154bb5 | ||
|
|
c9bda9e95a | ||
|
|
4efc975770 | ||
|
|
20d04015c1 | ||
|
|
98b0de9265 | ||
|
|
95706359c8 | ||
|
|
1437619475 | ||
|
|
7959182bf8 | ||
|
|
5ed17149e5 | ||
|
|
91ca31e676 | ||
|
|
a021888728 | ||
|
|
c12113921c | ||
|
|
74b48fca2c | ||
|
|
3642df1d5f | ||
|
|
c399bf35b5 | ||
|
|
8218e5c972 | ||
|
|
87c1c68949 | ||
|
|
817929beca | ||
|
|
678dff9a1a |
33
.travis.yml
33
.travis.yml
@@ -1,31 +1,13 @@
|
||||
env:
|
||||
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.2,<2.3'
|
||||
- PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.2,<2.3'
|
||||
- PLATFORM='docker-debian-jessie-dotdeb' ANSIBLE_VERSION='ansible>=2.2,<2.3'
|
||||
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.3,<2.4'
|
||||
- PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.3,<2.4'
|
||||
- PLATFORM='docker-debian-jessie-dotdeb' ANSIBLE_VERSION='ansible>=2.3,<2.4'
|
||||
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.3,<2.4'
|
||||
- PLATFORM='docker-debian-stretch-sury' ANSIBLE_VERSION='ansible>=2.3,<2.4'
|
||||
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.4,<2.5'
|
||||
- PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.4,<2.5'
|
||||
- PLATFORM='docker-debian-jessie-dotdeb' ANSIBLE_VERSION='ansible>=2.4,<2.5'
|
||||
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.4,<2.5'
|
||||
- PLATFORM='docker-debian-stretch-sury' ANSIBLE_VERSION='ansible>=2.4,<2.5'
|
||||
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.5b,<2.6'
|
||||
- PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.5b,<2.6'
|
||||
- PLATFORM='docker-debian-jessie-dotdeb' ANSIBLE_VERSION='ansible>=2.5b,<2.6'
|
||||
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.5b,<2.6'
|
||||
- PLATFORM='docker-debian-stretch-sury' ANSIBLE_VERSION='ansible>=2.5b,<2.6'
|
||||
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.6,<2.7'
|
||||
- PLATFORM='docker-debian-stretch-sury' ANSIBLE_VERSION='ansible>=2.6,<2.7'
|
||||
- PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.6,<2.7'
|
||||
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.7,<2.8'
|
||||
- PLATFORM='docker-debian-stretch-sury' ANSIBLE_VERSION='ansible>=2.7,<2.8'
|
||||
- PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.7,<2.8'
|
||||
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- env: PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.5b,<2.6'
|
||||
- env: PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.5b,<2.6'
|
||||
- env: PLATFORM='docker-debian-jessie-dotdeb' ANSIBLE_VERSION='ansible>=2.5b,<2.6'
|
||||
- env: PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.5b,<2.6'
|
||||
- env: PLATFORM='docker-debian-stretch-sury' ANSIBLE_VERSION='ansible>=2.5b,<2.6'
|
||||
|
||||
fast_finish: true
|
||||
|
||||
sudo: required
|
||||
@@ -33,6 +15,7 @@ sudo: required
|
||||
dist: trusty
|
||||
|
||||
language: python
|
||||
python: 2.7
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
@@ -22,15 +22,16 @@ Supported OS:
|
||||
|
||||
| OS | Working | Stable (active support) |
|
||||
| ------------------ | ------- | ----------------------- |
|
||||
| Debian Jessie (8) | Yes | Yes |
|
||||
| Debian Jessie (8) | Yes | Check latest supported version ([1.5.0](https://github.com/HanXHX/ansible-nginx/releases/tag/1.5.0)) |
|
||||
| Debian Stretch (9) | Yes | Yes |
|
||||
| Debian Buster (10) | Yes | No |
|
||||
| FreeBSD 11 | Yes | No |
|
||||
| FreeBSD 12 | Yes | No |
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
None. If you set true to `nginx_backports`, you must install backports repository before lauching this role.
|
||||
Ansible 2.6+. If you set true to `nginx_backports`, you must install backports repository before lauching this role.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
14
Vagrantfile
vendored
14
Vagrantfile
vendored
@@ -6,11 +6,9 @@
|
||||
Vagrant.configure("2") do |config|
|
||||
|
||||
vms_debian = [
|
||||
{ :name => "debian-jessie", :box => "debian/jessie64", :vars => { "nginx_php": [{"version": "5.6"}] }},
|
||||
{ :name => "debian-jessie-backports", :box => "debian/jessie64", :vars => { "nginx_php": [{"version": "5.6"}], "nginx_backports": true }},
|
||||
{ :name => "debian-jessie-dotdeb", :box => "debian/jessie64", :vars => { "nginx_php": [{"version": "7.0"}, {"version": "5.6", "upstream_name": "legacy"} ], "dotdeb": true }},
|
||||
{ :name => "debian-stretch", :box => "debian/stretch64", :vars => { "nginx_php": [{"version": "7.0"}] }},
|
||||
{ :name => "debian-stretch-sury", :box => "debian/stretch64", :vars => { "nginx_php": [{"version": "7.1"}], "sury": true }}
|
||||
{ :name => "debian-stretch-sury", :box => "debian/stretch64", :vars => { "nginx_php": [{"version": "7.1"}], "sury": true }},
|
||||
{ :name => "debian-buster", :box => "debian/buster64", :vars => { "nginx_php": [{"version": "7.3"}] }}
|
||||
]
|
||||
|
||||
vms_freebsd = [
|
||||
@@ -19,11 +17,9 @@ Vagrant.configure("2") do |config|
|
||||
]
|
||||
|
||||
conts = [
|
||||
{ :name => "docker-debian-jessie", :docker => "hanxhx/vagrant-ansible:debian8", :vars => { "nginx_php" => [{"version" => "5.6"}] }},
|
||||
{ :name => "docker-debian-jessie-backports", :docker => "hanxhx/vagrant-ansible:debian8", :vars => { "nginx_php": [{"version": "5.6"}], "nginx_backports": true }},
|
||||
{ :name => "docker-debian-jessie-dotdeb", :docker => "hanxhx/vagrant-ansible:debian8", :vars => { "nginx_php": [{"version": "7.0"}, {"version": "5.6", "upstream_name": "legacy"} ], "dotdeb": true }},
|
||||
{ :name => "docker-debian-stretch", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "nginx_php": [{"version": "7.0"}] }},
|
||||
{ :name => "docker-debian-stretch-sury", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "nginx_php": [{"version": "7.1"}], "sury": true }}
|
||||
{ :name => "docker-debian-stretch-sury", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "nginx_php": [{"version": "7.1"}], "sury": true }},
|
||||
{ :name => "docker-debian-buster", :docker => "hanxhx/vagrant-ansible:debian10", :vars => { "nginx_php": [{"version": "7.3"}] }},
|
||||
]
|
||||
|
||||
config.vm.network "private_network", type: "dhcp"
|
||||
@@ -40,7 +36,7 @@ Vagrant.configure("2") do |config|
|
||||
ansible.playbook = "tests/test.yml"
|
||||
ansible.verbose = 'vv'
|
||||
ansible.become = true
|
||||
ansible.extra_vars = opts[:vars].merge({ "nginx_debug_role": true })
|
||||
ansible.extra_vars = opts[:vars].merge({ "nginx_debug_role": true, is_docker: true })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -115,7 +115,7 @@ nginx_load_modules: []
|
||||
#
|
||||
nginx_dh: null
|
||||
nginx_dh_path: '{{ nginx_ssl_dir }}/dhparam.pem'
|
||||
nginx_dh_length: 2048
|
||||
nginx_dh_length: 4096
|
||||
|
||||
#
|
||||
# acme.sh
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
Auth Basic management
|
||||
=====================
|
||||
|
||||
IMPORTANT
|
||||
---------
|
||||
|
||||
If you use this feature with Debian Stretch, you *MUST* use ansible >= 2.3.2! See: [https://github.com/HanXHX/ansible-nginx/issues/28](#28).
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
|
||||
@@ -15,4 +15,3 @@ Sites not tested
|
||||
----------------
|
||||
|
||||
- BackupPC
|
||||
- Nagios
|
||||
|
||||
@@ -19,6 +19,8 @@ Common
|
||||
- `redirect_https`: (O) Boolean. Redirect HTTP to HTTPS. If "true", you _MUST_ set `proto` to ```['https']```.
|
||||
- `location`: (O) Add new custom locations (it does not overwrite!)
|
||||
- `location_order`: (O) Due to non preditive `location` order, you can provide the good order (see test-location.local in [tests/test.yml](../tests/test.yml)).
|
||||
- `location_before`: (O) Add new custom locations before generated location by template
|
||||
- `location_order_before`: (O) Manages location order for `location_before`
|
||||
- `more`: (O) Add more custom infos.
|
||||
- `upstream_params`: (O) Add upstream params (useful when you want to pass variables to PHP)
|
||||
- `override_try_files`: (O) overrides default try\_files defined in template
|
||||
@@ -39,10 +41,9 @@ Templates
|
||||
---------
|
||||
|
||||
- `_base`: static template
|
||||
- `_backuppc`: access to [BackupPC](http://backuppc.sourceforge.net/) (be careful: you need to install [fcgiwrap](https://packages.debian.org/jessie/fcgiwrap))
|
||||
- `_backuppc`: access to [BackupPC](http://backuppc.sourceforge.net/) (be careful: you need to install [fcgiwrap](https://packages.debian.org/stretch/fcgiwrap))
|
||||
- `_dokuwiki`
|
||||
- `_redirect`: should not be called explicitly
|
||||
- `_nagios3`: access to Nagios3 (be careful: you need to install [fcgiwrap](https://packages.debian.org/jessie/fcgiwrap))
|
||||
- `_phalcon`: Phalcon PHP Framework
|
||||
- `_php`: PHP base template. Can work with many frameworks/tools
|
||||
- `_php_index`: Same as above. But you can only run index.php
|
||||
|
||||
34
doc/ssl.md
34
doc/ssl.md
@@ -15,24 +15,41 @@ Variables
|
||||
Cert/Key pairs
|
||||
--------------
|
||||
|
||||
This list have 3 mandatory keys:
|
||||
Each pair must have a `name`.
|
||||
Note: `name` is used to deploy key/cert. With defaults values dans `name` = "foo", key is -> /etc/nginx/ssl/foo/foo.key
|
||||
|
||||
- `name`: MUST be unique
|
||||
### Content mode
|
||||
|
||||
Key/Cert content is stored in variable. Usefull with vault.
|
||||
|
||||
- `key`: content of the private key
|
||||
- `cert`: content of the public key
|
||||
|
||||
OR
|
||||
### Remote file
|
||||
|
||||
You can use these variables if you use another task/role to manages your certificates.
|
||||
|
||||
- `dest_cert`: remote path where certificate is located
|
||||
- `dest_key`: remote path where key is located
|
||||
|
||||
Note: `name` is used to deploy key/cert. With defaults values dans `name` = "foo", key is -> /etc/nginx/ssl/foo/foo.key
|
||||
### Self signed
|
||||
|
||||
Create a self-signed pair and deploy it. Do not use this feature in production.
|
||||
|
||||
- `self_signed`: set true to use this featrure
|
||||
- `force`: optional feature (default: false), force regen pair (not idempotent)
|
||||
|
||||
### Acme
|
||||
|
||||
Uses acme.sh to create free certificates. It uses HTTP-01 challenge. Use this feature for standalone servers.
|
||||
|
||||
- `acme`: set true to use this feature. It uses `name` (can be a string or string list).
|
||||
|
||||
Have a look to [acme configuratuion](acme.md configuration).
|
||||
|
||||
Tips
|
||||
----
|
||||
|
||||
- Deploying key/cert is not mandatory with this role. You can manage it in other place ([letsencrypt](https://letsencrypt.org/)? :)). You just need to set `dest_cert` and `dest_key`!
|
||||
- In `nginx_sites`, `ssl_name` is mandatory. This role will search in `nginx_ssl_pairs` with site `name` (first in list if it's a list).
|
||||
|
||||
Diffie-Hellman
|
||||
@@ -55,6 +72,10 @@ nginx_sites;
|
||||
- name: 'test-ssl3.local'
|
||||
proto: ['http', 'https']
|
||||
template: '_base'
|
||||
- name: 'test-self-signed.local'
|
||||
proto: ['http', 'https']
|
||||
template: '_base'
|
||||
ssl_name: 'this.is.self.signed'
|
||||
|
||||
nginx_ssl_pairs:
|
||||
- name: mysuperkey
|
||||
@@ -68,5 +89,8 @@ nginx_ssl_pairs:
|
||||
-----END CERTIFICATE-----
|
||||
- name: test-ssl2.local
|
||||
acme: true
|
||||
- name: this.is.self.signed
|
||||
self_signed: true
|
||||
force: false
|
||||
```
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@ Upstream management
|
||||
|
||||
`nginx_upstreams`: List of dict. An upstream has few keys. See bellow.
|
||||
|
||||
Note: Few params are unavailable on old Nginx version. But this role do _not_ put it if your version is too old!
|
||||
|
||||
Upstream params
|
||||
---------------
|
||||
|
||||
|
||||
@@ -10,11 +10,29 @@ def nginx_site_name(site):
|
||||
else:
|
||||
return site['name']
|
||||
|
||||
def nginx_ssl_dir(pair, ssl_dir):
|
||||
return ssl_dir + '/' + nginx_site_filename(pair)
|
||||
|
||||
def nginx_key_path(pair, ssl_dir):
|
||||
if pair.has_key('dest_key'):
|
||||
return pair['dest_key']
|
||||
else:
|
||||
return nginx_ssl_dir(pair, ssl_dir) + '/' + nginx_site_filename(pair) + '.key'
|
||||
|
||||
def nginx_cert_path(pair, ssl_dir):
|
||||
if pair.has_key('dest_cert'):
|
||||
return pair['dest_cert']
|
||||
else:
|
||||
return nginx_ssl_dir(pair, ssl_dir) + '/' + nginx_site_filename(pair) + '.crt'
|
||||
|
||||
class FilterModule(object):
|
||||
''' Nginx module '''
|
||||
|
||||
def filters(self):
|
||||
return {
|
||||
'nginx_site_filename': nginx_site_filename,
|
||||
'nginx_site_name': nginx_site_name
|
||||
'nginx_site_name': nginx_site_name,
|
||||
'nginx_ssl_dir': nginx_ssl_dir,
|
||||
'nginx_key_path': nginx_key_path,
|
||||
'nginx_cert_path': nginx_cert_path
|
||||
}
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
def php_default_upstream_socket(php_version):
|
||||
if php_version == '5.6':
|
||||
return '/run/php5-fpm.sock'
|
||||
else:
|
||||
return '/run/php/php%s-fpm.sock' % php_version
|
||||
|
||||
def php_default_upstream_name(php_version):
|
||||
return 'default_php_%s' % php_version
|
||||
|
||||
def php_fpm_service(php_version):
|
||||
if php_version == '5.6':
|
||||
return 'php5-fpm'
|
||||
else:
|
||||
return 'php%s-fpm' % php_version
|
||||
|
||||
class FilterModule(object):
|
||||
|
||||
@@ -26,10 +26,14 @@
|
||||
|
||||
- name: docker reload nginx
|
||||
command: service nginx reload
|
||||
args:
|
||||
warn: false
|
||||
when: ansible_virtualization_type == 'docker'
|
||||
|
||||
- name: docker restart nginx
|
||||
command: service nginx restart
|
||||
args:
|
||||
warn: false
|
||||
when: ansible_virtualization_type == 'docker'
|
||||
|
||||
- name: restart nginx freebsd
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author: Emilien Mantel
|
||||
description: Nginx for Debian
|
||||
description: Nginx for Debian / FreeBSD
|
||||
company:
|
||||
license: GPLv2
|
||||
min_ansible_version: 2.2
|
||||
min_ansible_version: 2.6
|
||||
platforms:
|
||||
- name: Debian
|
||||
versions:
|
||||
- jessie
|
||||
- stretch
|
||||
- buster
|
||||
- name: FreeBSD
|
||||
versions:
|
||||
- 11.0
|
||||
@@ -25,4 +26,3 @@ galaxy_info:
|
||||
- nginx
|
||||
- cdn
|
||||
dependencies: []
|
||||
|
||||
|
||||
@@ -24,13 +24,14 @@
|
||||
regexp: '{{ item.0.regexp }}'
|
||||
line: '{{ item.0.line }}'
|
||||
dest: '{{ item.1 }}'
|
||||
with_nested:
|
||||
-
|
||||
loop: "{{ list_one | product(list_two) | list }}"
|
||||
vars:
|
||||
list_one:
|
||||
- regexp: '^fastcgi_param SCRIPT_FILENAME'
|
||||
line: 'fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;'
|
||||
- regexp: '^fastcgi_param DOCUMENT_ROOT'
|
||||
line: 'fastcgi_param DOCUMENT_ROOT $realpath_root;'
|
||||
-
|
||||
list_two:
|
||||
- '{{ nginx_etc_dir }}/fastcgi.conf'
|
||||
when: nginx_fastcgi_fix_realpath
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
file:
|
||||
path: "{{ nginx_htpasswd_dir }}/{{ item.name }}"
|
||||
state: absent
|
||||
with_items: "{{ nginx_htpasswd }}"
|
||||
loop: "{{ nginx_htpasswd }}"
|
||||
when: item.state is defined and item.state == 'absent'
|
||||
no_log: not nginx_debug_role
|
||||
|
||||
@@ -12,10 +12,7 @@
|
||||
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
|
||||
loop: "{{ nginx_htpasswd | subelements('users') }}"
|
||||
when: item.0.state is not defined or item.0.state == 'present'
|
||||
no_log: not nginx_debug_role
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
---
|
||||
|
||||
- name: FAIL | Check possible issues
|
||||
fail:
|
||||
msg: "This ansible version ({{ ansible_version.full}}) is not compatible with your needs (Debian Stretch + htpasswd). Please see https://github.com/HanXHX/ansible-nginx/issues/28"
|
||||
when:
|
||||
ansible_distribution_major_version | version_compare('9', 'ge') and
|
||||
ansible_version.full | version_compare('2.3.2', 'lt') and
|
||||
nginx_htpasswd | length > 0
|
||||
- name: SET_FACT | Bypass https://github.com/ansible/ansible/issues/19874
|
||||
set_fact:
|
||||
ansible_distribution_release: 'buster'
|
||||
when: ansible_facts.distribution_major_version == "buster/sid"
|
||||
|
||||
- name: APT | Update cache
|
||||
apt:
|
||||
@@ -14,27 +11,15 @@
|
||||
cache_valid_time: 3600
|
||||
changed_when: false
|
||||
|
||||
- name: APT | Force OpenSSL from backports (fix dependency break)
|
||||
apt:
|
||||
pkg: openssl
|
||||
state: latest
|
||||
default_release: "{{ ansible_distribution_release + '-backports' }}"
|
||||
when: nginx_backports
|
||||
|
||||
- name: APT | Install nginx and dependencies
|
||||
apt:
|
||||
pkg: "{{ nginx_apt_package }}"
|
||||
state: present
|
||||
default_release: "{{ ansible_distribution_release + '-backports' if nginx_backports else ansible_distribution_release }}"
|
||||
|
||||
- name: APT | Install nginx modules
|
||||
apt:
|
||||
pkg: "{{ item }}"
|
||||
pkg: "{{ nginx_module_packages }}"
|
||||
state: present
|
||||
with_items: "{{ nginx_module_packages }}"
|
||||
when:
|
||||
ansible_distribution_major_version | version_compare('9', 'ge') or
|
||||
nginx_backports
|
||||
|
||||
- name: APT | Install python-passlib
|
||||
apt:
|
||||
@@ -57,9 +42,10 @@
|
||||
repo: 'https://github.com/Neilpang/acme.sh.git'
|
||||
dest: '{{ nginx_acmesh_git_dir }}'
|
||||
update: no
|
||||
version: master
|
||||
|
||||
- name: SHELL | Install acme.sh
|
||||
shell: ./acme.sh --install --home {{ nginx_acmesh_dir }} --cert-home {{ nginx_acmesh_dir }}
|
||||
- name: COMMAND | Install acme.sh
|
||||
command: ./acme.sh --install --home "{{ nginx_acmesh_dir }}"
|
||||
args:
|
||||
chdir: "{{ nginx_acmesh_git_dir }}"
|
||||
creates: "{{ nginx_acmesh_dir }}"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
pkgng:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
with_items:
|
||||
loop:
|
||||
- acme.sh
|
||||
- "{{ nginx_pkgng_package }}"
|
||||
- py27-passlib
|
||||
@@ -40,7 +40,7 @@
|
||||
file:
|
||||
path: "{{ nginx_etc_dir }}/{{ item }}"
|
||||
state: directory
|
||||
with_items:
|
||||
loop:
|
||||
- conf.d
|
||||
- sites-available
|
||||
- sites-enabled
|
||||
|
||||
@@ -4,27 +4,27 @@
|
||||
include_vars: "{{ ansible_distribution }}.yml"
|
||||
tags: ['nginx::site', 'nginx::ssl']
|
||||
|
||||
- name: INCLUDE | Install
|
||||
include: "install_{{ ansible_distribution }}.yml"
|
||||
- name: INCLUDE_TASKS | Install
|
||||
include_tasks: "install_{{ ansible_distribution }}.yml"
|
||||
tags: ['nginx::site', 'nginx::ssl']
|
||||
|
||||
- name: INCLUDE | Prepare
|
||||
include: prepare.yml
|
||||
- name: IMPORT_TASKS| Prepare
|
||||
import_tasks: prepare.yml
|
||||
tags: ['nginx::site', 'nginx::ssl']
|
||||
|
||||
- name: INCLUDE | Install
|
||||
include: config.yml
|
||||
- name: IMPORT_TASKS| Install
|
||||
import_tasks: config.yml
|
||||
|
||||
- name: INCLUDE | Upstream configuration
|
||||
include: upstream.yml
|
||||
- name: IMPORT_TASKS| Upstream configuration
|
||||
import_tasks: upstream.yml
|
||||
|
||||
- name: INCLUDE | htpasswd configuration
|
||||
include: htpasswd.yml
|
||||
- name: IMPORT_TASKS| htpasswd configuration
|
||||
import_tasks: htpasswd.yml
|
||||
|
||||
- name: INCLUDE | SSL configuration
|
||||
include: ssl/main.yml
|
||||
- name: IMPORT_TASKS| SSL configuration
|
||||
import_tasks: ssl/main.yml
|
||||
tags: ['nginx::ssl']
|
||||
|
||||
- name: INCLUDE | Sites configuration
|
||||
include: site.yml
|
||||
- name: IMPORT_TASKS| Sites configuration
|
||||
import_tasks: site.yml
|
||||
tags: ['nginx::site']
|
||||
|
||||
@@ -7,14 +7,24 @@
|
||||
register: nginx_version
|
||||
changed_when: false
|
||||
check_mode: no
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
- name: SHELL | Get module list
|
||||
shell: nginx -V 2>&1 | tr -- - '\n' | grep -A 1 with | grep _module | sed -r 's/_module//g; s/\s+//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:
|
||||
executable: /bin/sh
|
||||
register: shell_modules
|
||||
changed_when: false
|
||||
check_mode: no
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
- name: SET_FACT | Save modules
|
||||
set_fact:
|
||||
@@ -26,7 +36,7 @@
|
||||
owner: "{{ item.owner }}"
|
||||
mode: "{{ item.mode }}"
|
||||
state: directory
|
||||
with_items: "{{ nginx_dirs }}"
|
||||
loop: "{{ nginx_dirs }}"
|
||||
|
||||
- name: FILE | Create ansible facts dir
|
||||
file:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
fail:
|
||||
msg: "Forbidden keyword default on site {{ item | nginx_site_name }}"
|
||||
when: item.filename is defined and item.filename == 'default'
|
||||
with_items: "{{ nginx_sites }}"
|
||||
loop: "{{ nginx_sites }}"
|
||||
loop_control:
|
||||
label: "{{ item | nginx_site_name }}"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
when:
|
||||
((item.proto is defined and 'http' in item.proto) or (item.proto is not defined)) and
|
||||
(item.redirect_http is defined and item.redirect_http)
|
||||
with_items: "{{ nginx_sites }}"
|
||||
loop: "{{ nginx_sites }}"
|
||||
loop_control:
|
||||
label: "{{ item | nginx_site_name }}"
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
owner: "{{ item.owner | default(nginx_user) }}"
|
||||
group: "{{ item.group | default(nginx_user) }}"
|
||||
mode: "{{ item.mode | default('0755') }}"
|
||||
with_items: "{{ nginx_sites }}"
|
||||
loop: "{{ nginx_sites }}"
|
||||
when: >
|
||||
item.root is not defined and
|
||||
(item.template is defined and item.template not in nginx_templates_no_dir) and
|
||||
@@ -43,9 +43,9 @@
|
||||
template:
|
||||
src: "etc/nginx/sites-available/{{ item.template if item.redirect_to is not defined else '_redirect' }}.j2"
|
||||
dest: "{{ nginx_etc_dir }}/sites-available/{{ item | nginx_site_filename }}"
|
||||
with_items: "{{ nginx_sites }}"
|
||||
notify: ['reload nginx', 'restart nginx freebsd']
|
||||
when: item.state is not defined or item.state != 'absent'
|
||||
loop: "{{ nginx_sites }}"
|
||||
loop_control:
|
||||
label: "{{ item | nginx_site_name }}"
|
||||
|
||||
@@ -53,11 +53,11 @@
|
||||
file:
|
||||
path: "{{ nginx_etc_dir }}/{{ item.1 }}/{{ item.0 | nginx_site_filename }}"
|
||||
state: absent
|
||||
with_nested:
|
||||
- "{{ nginx_sites }}"
|
||||
- ['sites-available', 'sites-enabled']
|
||||
loop: "{{ nginx_sites | product(dirs) | list }}"
|
||||
notify: ['reload nginx', 'restart nginx freebsd']
|
||||
when: item.0.state is defined and item.0.state == 'absent'
|
||||
vars:
|
||||
dirs: ['sites-available', 'sites-enabled']
|
||||
loop_control:
|
||||
label: "{{ nginx_etc_dir }}/{{ item.1 }}/{{ item.0 | nginx_site_filename }}"
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
src: "{{ nginx_etc_dir }}/sites-available/{{ item | nginx_site_filename }}"
|
||||
dest: "{{ nginx_etc_dir }}/sites-enabled/{{ item | nginx_site_filename }}"
|
||||
state: link
|
||||
with_items: "{{ nginx_sites }}"
|
||||
loop: "{{ nginx_sites }}"
|
||||
notify: ['reload nginx', 'restart nginx freebsd']
|
||||
when: >
|
||||
item.state is not defined or item.state == 'present'
|
||||
@@ -77,7 +77,7 @@
|
||||
file:
|
||||
path: "{{ nginx_etc_dir }}/sites-enabled/{{ item | nginx_site_filename }}"
|
||||
state: absent
|
||||
with_items: "{{ nginx_sites }}"
|
||||
loop: "{{ nginx_sites }}"
|
||||
notify: ['reload nginx', 'restart nginx freebsd']
|
||||
when: item.state is defined and item.state == 'disabled'
|
||||
loop_control:
|
||||
|
||||
@@ -7,28 +7,31 @@
|
||||
- name: STAT | Check if certificates are already installed
|
||||
stat:
|
||||
path: "{{ nginx_ssl_dir }}/{{ item | nginx_site_name }}/{{ item | nginx_site_name }}.crt"
|
||||
with_items: "{{ nginx_ssl_pairs }}"
|
||||
loop: "{{ nginx_ssl_pairs }}"
|
||||
when: item.acme is defined and item.acme
|
||||
register: acme_installed_certs
|
||||
|
||||
- name: SET_FACT | Assign var with certificates to create
|
||||
set_fact:
|
||||
acme_create: "{{ acme_create | default([]) + [ (item.item) ] }}"
|
||||
with_items: "{{ acme_installed_certs.results }}"
|
||||
loop: "{{ acme_installed_certs.results }}"
|
||||
when: item.skipped is not defined and not item.stat.exists
|
||||
|
||||
- name: BLOCK | Start acme
|
||||
block:
|
||||
|
||||
- name: TEMPLATE | Create fake site
|
||||
template:
|
||||
src: "etc/nginx/conf.d/FAKESITE.conf.j2"
|
||||
dest: "{{ nginx_etc_dir }}/conf.d/FAKESITE_{{ item | nginx_site_name }}.conf"
|
||||
with_items: "{{ acme_create }}"
|
||||
loop: "{{ acme_create }}"
|
||||
register: fake_site
|
||||
|
||||
- name: FILE | Delete current site if needed
|
||||
file:
|
||||
path: "{{ nginx_etc_dir }}/sites-enabled/{{ item | nginx_site_name }}"
|
||||
state: absent
|
||||
with_items: "{{ acme_create }}"
|
||||
loop: "{{ acme_create }}"
|
||||
when: fake_site.changed
|
||||
|
||||
- name: SERVICE | Restart nginx
|
||||
@@ -39,13 +42,20 @@
|
||||
|
||||
- name: COMMAND | Restart nginx
|
||||
command: service nginx restart
|
||||
args:
|
||||
warn: false
|
||||
when: fake_site.changed and ansible_virtualization_type == 'docker'
|
||||
|
||||
- name: SHELL | Get certificates
|
||||
shell: '{{ nginx_acmesh_bin }} --issue{% if item.name is string %} -d {{ item.name }}{% else %}{% for name in item.name %} -d {{ name }}{% endfor %}{% endif %} --nginx {% if nginx_acmesh_test %}--test{% endif %}'
|
||||
- name: COMMAND | Get certificates
|
||||
command: |
|
||||
{{ nginx_acmesh_bin }}
|
||||
--home {{ nginx_acmesh_dir }}
|
||||
--issue{% if item.name is string %} -d {{ item.name }}{% else %}{% for name in item.name %} -d {{ name }}{% endfor %}{% endif %}
|
||||
--nginx
|
||||
{% if nginx_acmesh_test %}--test{% endif %}
|
||||
args:
|
||||
creates: "/root/.acme.sh/{{ item | nginx_site_name }}/{{ item | nginx_site_name }}.key"
|
||||
with_items: "{{ acme_create }}"
|
||||
creates: "{{ nginx_acmesh_dir }}/{{ item | nginx_site_name }}/{{ item | nginx_site_name }}.key"
|
||||
loop: "{{ acme_create }}"
|
||||
register: acme_get
|
||||
failed_when: acme_get.rc != 0 and acme_get.rc != 2
|
||||
no_log: not nginx_debug_role
|
||||
@@ -53,18 +63,36 @@
|
||||
- name: FILE | Create SSL dir per site
|
||||
file:
|
||||
path: "{{ nginx_ssl_dir }}/{{ item | nginx_site_name }}"
|
||||
with_items: "{{ acme_create }}"
|
||||
loop: "{{ acme_create }}"
|
||||
|
||||
- name: SHELL | Install certificates
|
||||
shell: '{{ nginx_acmesh_bin }} --install-cert -d {{ item | nginx_site_name }} --fullchain-file {{ nginx_ssl_dir }}/{{ item | nginx_site_name }}/{{ item | nginx_site_name }}.crt --key-file {{ nginx_ssl_dir }}/{{ item | nginx_site_name }}/{{ item | nginx_site_name }}.key --reloadcmd "service nginx restart"'
|
||||
- name: COMMAND | Install certificates
|
||||
command: |
|
||||
{{ nginx_acmesh_bin }}
|
||||
--home {{ nginx_acmesh_dir }}
|
||||
--install-cert -d {{ item | nginx_site_name }}
|
||||
--fullchain-file {{ nginx_ssl_dir }}/{{ item | nginx_site_name }}/{{ item | nginx_site_name }}.crt
|
||||
--key-file {{ nginx_ssl_dir }}/{{ item | nginx_site_name }}/{{ item | nginx_site_name }}.key
|
||||
--reloadcmd "service nginx reload"
|
||||
args:
|
||||
creates: "{{ nginx_ssl_dir }}/{{ item | nginx_site_name }}/{{ item | nginx_site_name }}.key"
|
||||
with_items: "{{ nginx_ssl_pairs }}"
|
||||
loop: "{{ nginx_ssl_pairs }}"
|
||||
when: item.acme is defined and item.acme
|
||||
notify: restart nginx
|
||||
|
||||
rescue:
|
||||
|
||||
- name: FAIL | Explicit
|
||||
fail:
|
||||
msg: "Something is bad... Auto crash!"
|
||||
|
||||
always:
|
||||
|
||||
- name: FILE | Delete fake sites
|
||||
file:
|
||||
path: "{{ nginx_etc_dir }}/conf.d/FAKESITE_{{ item | nginx_site_name }}.conf"
|
||||
state: absent
|
||||
with_items: "{{ acme_create }}"
|
||||
loop: "{{ acme_create }}"
|
||||
notify: restart nginx
|
||||
|
||||
- name: META | Flush handlers
|
||||
meta: flush_handlers
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
|
||||
- name: INCLUDE | standard.yml
|
||||
include: standard.yml
|
||||
- name: IMPORT_TASKS | standard.yml
|
||||
import_tasks: standard.yml
|
||||
|
||||
- name: INCLUDE | acme.yml
|
||||
include: acme.yml
|
||||
- name: IMPORT_TASKS | acme.yml
|
||||
import_tasks: acme.yml
|
||||
when: nginx_acmesh
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
---
|
||||
|
||||
- block:
|
||||
|
||||
- name: STAT | Get info ajout DH file
|
||||
stat:
|
||||
path: "{{ nginx_dh_path }}"
|
||||
get_checksum: no
|
||||
register: stat_dh_file
|
||||
|
||||
- name: SHELL | Get info about DH file
|
||||
shell: openssl dhparam -in {{ nginx_dh_path }} -text -noout 2>&1 | awk '/DH Parameters/ { print substr($3, 2) }'
|
||||
changed_when: false
|
||||
register: dh_info
|
||||
when: stat_dh_file.stat.exists
|
||||
|
||||
- name: COMMAND | Generate DH file
|
||||
command: openssl dhparam -out {{ nginx_dh_path }} {{ nginx_dh_length }}
|
||||
args:
|
||||
creates: "{{ nginx_dh_path }}"
|
||||
when: nginx_dh is not string
|
||||
when: not stat_dh_file.stat.exists or (dh_info.stdout | int != nginx_dh_length | int)
|
||||
notify: restart nginx
|
||||
async: 1000
|
||||
register: dh
|
||||
|
||||
when: nginx_dh is not string
|
||||
|
||||
- name: COPY | Deploy DH file from vars
|
||||
copy:
|
||||
@@ -18,18 +30,18 @@
|
||||
|
||||
- name: FILE | Create SSL directories
|
||||
file:
|
||||
path: "{{ nginx_ssl_dir + '/' + item | nginx_site_name }}"
|
||||
path: "{{ item | nginx_ssl_dir(nginx_ssl_dir) }}"
|
||||
state: directory
|
||||
with_items: "{{ nginx_ssl_pairs }}"
|
||||
loop: "{{ nginx_ssl_pairs }}"
|
||||
when: item.dest_key is not defined or item.dest_cert is not defined
|
||||
no_log: not nginx_debug_role
|
||||
|
||||
- name: COPY | Deploy SSL keys
|
||||
copy:
|
||||
content: "{{ item.key }}"
|
||||
dest: "{{ nginx_ssl_dir + '/' + item | nginx_site_name + '/' + item | nginx_site_name + '.key' if item.dest_key is not defined else item.dest_key }}"
|
||||
dest: "{{ item | nginx_key_path(nginx_ssl_dir) }}"
|
||||
mode: 0640
|
||||
with_items: "{{ nginx_ssl_pairs }}"
|
||||
loop: "{{ nginx_ssl_pairs }}"
|
||||
when: item.key is defined
|
||||
notify: restart nginx
|
||||
no_log: not nginx_debug_role
|
||||
@@ -37,17 +49,24 @@
|
||||
- name: COPY | Deploy SSL certs
|
||||
copy:
|
||||
content: "{{ item.cert }}"
|
||||
dest: "{{ nginx_ssl_dir + '/' + item | nginx_site_name + '/' + item | nginx_site_name + '.crt' if item.dest_cert is not defined else item.dest_cert }}"
|
||||
dest: "{{ item | nginx_cert_path(nginx_ssl_dir) }}"
|
||||
mode: 0644
|
||||
with_items: "{{ nginx_ssl_pairs }}"
|
||||
loop: "{{ nginx_ssl_pairs }}"
|
||||
when: item.cert is defined
|
||||
notify: restart nginx
|
||||
no_log: not nginx_debug_role
|
||||
|
||||
- name: Check DH command status
|
||||
async_status:
|
||||
jid: "{{ dh.ansible_job_id }}"
|
||||
register: job_result
|
||||
until: job_result.finished
|
||||
retries: 30
|
||||
when: not ansible_check_mode and nginx_dh is not string
|
||||
- name: COMMAND | Create self-signed certificates
|
||||
command: |
|
||||
openssl req
|
||||
-new -newkey rsa:2048 -sha256 -days 3650 -nodes -x509
|
||||
-subj '/CN={{ item | nginx_site_name }}'
|
||||
-keyout {{ item | nginx_key_path(nginx_ssl_dir) }}
|
||||
-out {{ item | nginx_cert_path(nginx_ssl_dir) }}
|
||||
args:
|
||||
chdir: "{{ item | nginx_ssl_dir(nginx_ssl_dir) }}"
|
||||
creates: "{{ '/tmp/dummy' if item.force is defined and item.force else item | nginx_cert_path(nginx_ssl_dir) }}"
|
||||
loop: "{{ nginx_ssl_pairs }}"
|
||||
when: item.self_signed is defined
|
||||
notify: restart nginx
|
||||
no_log: not nginx_debug_role
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
template:
|
||||
src: "etc/nginx/conf.d/_upstream.conf.j2"
|
||||
dest: "{{ nginx_etc_dir }}/conf.d/upstream-{{ item.name }}.conf"
|
||||
with_items: "{{ nginx_upstreams }}"
|
||||
loop: "{{ nginx_upstreams }}"
|
||||
when: item.state is not defined or item.state == 'present'
|
||||
notify: reload nginx
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
file:
|
||||
path: "{{ nginx_etc_dir }}/conf.d/upstream-{{ item.name }}.conf"
|
||||
state: absent
|
||||
with_items: "{{ nginx_upstreams }}"
|
||||
loop: "{{ nginx_upstreams }}"
|
||||
when: item.state is defined and item.state == 'absent'
|
||||
notify: reload nginx
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{%- macro s(key, value, is_bool, min_version) %}
|
||||
{% if nginx_version.stdout | version_compare(min_version, 'ge') %}
|
||||
{% if nginx_version.stdout is version(min_version, 'ge') %}
|
||||
{% if is_bool and value %} {{ key }}{% elif not is_bool %} {{ key }}={{ value }}{% endif %}
|
||||
{% endif %}
|
||||
{%- endmacro -%}
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
#
|
||||
|
||||
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:ECDHE-RSA-AES128-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA128:DHE-RSA-AES128-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA128:ECDHE-RSA-AES128-SHA384:ECDHE-RSA-AES128-SHA128:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA384:AES128-GCM-SHA128:AES128-SHA128:AES128-SHA128:AES128-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2{% if nginx_version.stdout | version_compare('1.13.0', 'ge') %} TLSv1.3{% endif %};
|
||||
ssl_protocols TLSv1.1 TLSv1.2{% if nginx_version.stdout is version('1.13.0', 'ge') %} TLSv1.3{% endif %};
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains"{% if nginx_version.stdout | version_compare('1.7.5', 'ge') %} always{% endif %};
|
||||
ssl_session_tickets off;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;
|
||||
resolver {{ nginx_resolver_hosts | join(' ') }} valid={{ nginx_resolver_valid }};
|
||||
resolver_timeout {{ nginx_resolver_timeout }};
|
||||
ssl_dhparam {{ nginx_dh_path }};
|
||||
|
||||
@@ -2,13 +2,16 @@
|
||||
# {{ ansible_managed }}
|
||||
#
|
||||
|
||||
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2{% if nginx_version.stdout | version_compare('1.13.0', 'ge') %} TLSv1.3{% endif %};
|
||||
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384";
|
||||
ssl_protocols TLSv1.2{% if nginx_version.stdout is version('1.13.0', 'ge') %} TLSv1.3{% endif %};
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ecdh_curve secp384r1;
|
||||
ssl_session_timeout 10m;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains"{% if nginx_version.stdout | version_compare('1.7.5', 'ge') %} always{% endif %};
|
||||
ssl_session_tickets off;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;
|
||||
resolver {{ nginx_resolver_hosts | join(' ') }} valid={{ nginx_resolver_valid }};
|
||||
resolver_timeout {{ nginx_resolver_timeout }};
|
||||
ssl_dhparam {{ nginx_dh_path }};
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
user {{ nginx_user }};
|
||||
worker_processes {{ nginx_worker_processes }};
|
||||
pid {{ nginx_pid }};
|
||||
{% if nginx_version.stdout | version_compare('1.9.11', 'ge') %}
|
||||
include {{ nginx_etc_dir }}/modules-enabled/*.conf;
|
||||
{% endif %}
|
||||
|
||||
events {
|
||||
worker_connections {{ nginx_events_worker_connections }};
|
||||
|
||||
@@ -5,9 +5,32 @@
|
||||
{% set __http_proxy_protocol_port = item.http_proxy_protocol_port | default([]) %}
|
||||
{% set __https_proxy_protocol_port = item.https_proxy_protocol_port | default([]) %}
|
||||
{% set __location = item.location | default({}) %}
|
||||
{% set __location_before = item.location_before | default({}) %}
|
||||
{% set __headers = item.headers | default(nginx_servers_default_headers) %}
|
||||
{% set __ssl_name = item.ssl_name | default(item.name if item.name is string else item.name[0]) %}
|
||||
{% set __location_order = item.location_order | default(__location.keys()) %}
|
||||
{% set __location_order_before = item.location_order_before | default(__location_before.keys()) %}
|
||||
{% macro server_name(name) %}
|
||||
{% if name is string %}{{ name }}{% else %}{{ name | join(" ") }}{% endif %}
|
||||
{% endmacro %}
|
||||
{% macro locations(list, order) %}
|
||||
{% if order | length > 0 %}
|
||||
# --> Custom locations
|
||||
{% for location in order %}
|
||||
location {{ location }} {
|
||||
{% set opts = list[location] %}
|
||||
{% for opt in opts %}
|
||||
{% if opt.htpasswd is defined %}
|
||||
{{ htpasswd(opt.htpasswd, 2) }}
|
||||
{% else %}
|
||||
{{ opt }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
}
|
||||
{% endfor %}
|
||||
# <-- Custom locations
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
{% macro htpasswd(htpasswd_name, indent=1) -%}
|
||||
{%- if htpasswd_name != false %}
|
||||
{%- for ht in nginx_htpasswd if ht.name == htpasswd_name %}
|
||||
@@ -18,8 +41,8 @@
|
||||
{%- endmacro %}
|
||||
{% macro ssl(ssl_name) %}
|
||||
{% for sn in nginx_ssl_pairs if ((sn.name is string and sn.name == ssl_name) or (sn.name.0 == ssl_name)) %}
|
||||
ssl_certificate {{ nginx_ssl_dir + '/' + ssl_name + '/' + ssl_name + '.crt' if sn.dest_cert is not defined else sn.dest_cert }};
|
||||
ssl_certificate_key {{ nginx_ssl_dir + '/' + ssl_name + '/' + ssl_name + '.key' if sn.dest_key is not defined else sn.dest_key }};
|
||||
ssl_certificate {{ sn | nginx_cert_path(nginx_ssl_dir) }};
|
||||
ssl_certificate_key {{ sn | nginx_key_path(nginx_ssl_dir) }};
|
||||
{% endfor %}
|
||||
{%- endmacro %}
|
||||
{% macro httpsredirect(name) %}
|
||||
@@ -27,7 +50,7 @@ server {
|
||||
{% for port in __listen %}
|
||||
listen {{ port }}{% if port | int in __http_proxy_protocol_port %} proxy_protocol{% endif %};
|
||||
{% endfor %}
|
||||
server_name {{ name }};
|
||||
server_name {{ server_name(name) }};
|
||||
location / {
|
||||
return 301 https://{{ name }}{% if '443' not in __listen_ssl and 443 not in __listen_ssl %}:{{ __listen_ssl[0] }}{% endif %}$request_uri;
|
||||
}
|
||||
@@ -56,7 +79,7 @@ server {
|
||||
include {{ nginx_helper_dir + '/ssl-' + item.ssl_template | default('strong') }};
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
server_name {% if item.name is string %}{{ item.name }}{% else %}{{ "\n\t\t" }}{{ item.name | join("\n\t\t") }}{% endif %};
|
||||
server_name {{ server_name(item.name) }};
|
||||
{% block root %}
|
||||
{% if item.root is defined %}
|
||||
root {{ item.root }};
|
||||
@@ -83,15 +106,17 @@ server {
|
||||
{% block template_headers %}
|
||||
# --> Custom headers
|
||||
{% for key, value in __headers.iteritems() %}
|
||||
add_header {{ key }} "{{ value | replace(' always', '') }}"{% if nginx_version.stdout | version_compare('1.7.5', 'ge') and ' always' in value %} always{% endif %};
|
||||
add_header {{ key }} "{{ value }}";
|
||||
{% endfor %}
|
||||
# <-- Custom headers
|
||||
{% endblock %}
|
||||
|
||||
{{ locations(__location_before, __location_order_before) }}
|
||||
|
||||
{% if not __location.has_key('/') %}
|
||||
location / {
|
||||
{% block template_try_files %}
|
||||
try_files {{ override_try_files | default('$uri $uri/ =404') }};
|
||||
try_files {{ item.override_try_files | default('$uri $uri/ =404') }};
|
||||
{% endblock %}
|
||||
}
|
||||
{% endif %}
|
||||
@@ -101,19 +126,7 @@ server {
|
||||
{% block template_custom_location %}
|
||||
{% endblock %}
|
||||
|
||||
{% if __location_order | length > 0 %}
|
||||
# --> Custom locations
|
||||
{% for location in __location_order %}
|
||||
location {{ location }} {
|
||||
{% set opts = __location[location] %}
|
||||
{% for opt in opts %}
|
||||
{% if opt.htpasswd is defined %}{{ htpasswd(opt.htpasswd, 2) }}{% else %}
|
||||
{{ opt }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
}
|
||||
{% endfor %} # <-- Custom locations
|
||||
{% endif %}
|
||||
{{ locations(__location, __location_order) }}
|
||||
|
||||
{% block template_local_content %}
|
||||
{% if item.manage_local_content is not defined or item.manage_local_content %}
|
||||
@@ -127,7 +140,7 @@ server {
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
location ~* \.(txt|js|css|png|jpe?g|gif|ico|svg)$ {
|
||||
location ~* \.(txt|js|css|png|jpe?g|gif|ico|svg|(o|t)tf|woff2?|eot)$ {
|
||||
expires 30d;
|
||||
log_not_found off;
|
||||
}
|
||||
@@ -171,7 +184,7 @@ server {
|
||||
{% for port in __listen %}
|
||||
listen {{ port }}{% if port | int in __http_proxy_protocol_port %} proxy_protocol{% endif %};
|
||||
{% endfor %}
|
||||
server_name {% if item.redirect_from is string %}{{ item.redirect_from }}{% else %}{{ "\n\t\t" }}{{ item.redirect_from | join("\n\t\t") }}{% endif %};
|
||||
server_name {{ server_name(item.redirect_from) }};
|
||||
location / {
|
||||
return 301 $scheme://{{ item.name if item.name is string else item.name[0] }}$request_uri;
|
||||
}
|
||||
@@ -186,7 +199,7 @@ server {
|
||||
{% if item.ssl_template is not defined or item.ssl_template != false %}
|
||||
include {{ nginx_helper_dir + '/ssl-' + item.ssl_template | default('strong') }};
|
||||
{% endif %}
|
||||
server_name {% if item.redirect_from is string %}{{ item.redirect_from }}{% else %}{{ "\n\t\t" }}{{ item.redirect_from | join("\n\t\t") }}{% endif %};
|
||||
server_name {{ server_name(item.redirect_from) }};
|
||||
location / {
|
||||
return 301 https://{{ item.name if item.name is string else item.name[0] }}{% if '443' not in __listen_ssl and 443 not in __listen_ssl %}:{{ __listen_ssl[0] }}{% endif %}$request_uri;
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
{% extends "_php.j2" %}
|
||||
|
||||
{% block root %}
|
||||
root {{ nginx_nagios_root }};
|
||||
{% endblock %}
|
||||
|
||||
{% block template_try_files %}
|
||||
{% endblock %}
|
||||
|
||||
{% block template_index %}
|
||||
index index.php index.html;
|
||||
{% endblock %}
|
||||
|
||||
{% block template_headers %}
|
||||
# --> Custom headers
|
||||
{% for key, value in __headers.iteritems() %}
|
||||
{% if key == "X-Frame-Options" %}
|
||||
# X-Frame-Options forced by Ansible
|
||||
add_header {{ key }} "SAMEORIGIN"{% if nginx_version.stdout | version_compare('1.7.5', 'ge') %} always{% endif %};
|
||||
{% else %}
|
||||
add_header {{ key }} "{{ value | replace(' always', '') }}"{% if nginx_version.stdout | version_compare('1.7.5', 'ge') and ' always' in value %} always{% endif %};
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
# <-- Custom headers
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block template_local_content %}
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
|
||||
location /stylesheets {
|
||||
{% if nginx_nagios_stylesheets is defined %}
|
||||
alias {{ nginx_nagios_stylesheets }};
|
||||
{% endif %}
|
||||
expires 60d;
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block template_upstream_location %}
|
||||
{% if ansible_distribution == 'Debian' %}
|
||||
location /cgi-bin/nagios3 {
|
||||
root /usr/lib;
|
||||
{% elif ansible_distribution == 'FreeBSD' %}
|
||||
location /cgi-bin {
|
||||
{% endif %}
|
||||
try_files $uri =404;
|
||||
include fastcgi.conf;
|
||||
fastcgi_pass unix:{{ nginx_fcgiwrap_sock }};
|
||||
fastcgi_param AUTH_USER $remote_user;
|
||||
fastcgi_param REMOTE_USER $remote_user;
|
||||
}
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass {{ php_upstream }};
|
||||
fastcgi_index index.php;
|
||||
include fastcgi.conf;
|
||||
}
|
||||
{% endblock %}
|
||||
@@ -16,7 +16,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block template_try_files %}
|
||||
try_files {{ override_try_files | default('$uri $uri/ =404') }};
|
||||
try_files {{ item.override_try_files | default('$uri $uri/ =404') }};
|
||||
{% endblock %}
|
||||
|
||||
{% block template_upstream_location %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "_php.j2" %}
|
||||
|
||||
{% block template_try_files %}
|
||||
try_files {{ override_try_files | default('$uri $uri/ /index.php') }};
|
||||
try_files {{ item.override_try_files | default('$uri $uri/ /index.php') }};
|
||||
{% endblock %}
|
||||
|
||||
{% block template_upstream_location %}
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
---
|
||||
|
||||
- name: APT | Install webapps
|
||||
- name: APT | Install webapps and related tools
|
||||
apt:
|
||||
pkg: "{{ item }}"
|
||||
pkg: "{{ packages }}"
|
||||
state: present
|
||||
install_recommends: no
|
||||
with_items:
|
||||
vars:
|
||||
packages:
|
||||
- backuppc
|
||||
|
||||
- name: APT | Install nagios3 (only on old Debian releases)
|
||||
apt:
|
||||
pkg: nagios3
|
||||
state: present
|
||||
when: ansible_distribution_major_version | version_compare('9', 'lt')
|
||||
- samba-common-bin
|
||||
- smbclient
|
||||
|
||||
- name: SERVICE | Ensure backuppc is started
|
||||
service:
|
||||
name: backuppc
|
||||
state: started
|
||||
register: b
|
||||
failed_when: b.failed and 'Another BackupPC is running' not in b.msg
|
||||
|
||||
@@ -2,11 +2,8 @@
|
||||
|
||||
#- name: APT | Install web apps
|
||||
# pkgng:
|
||||
# pkg: "{{ item }}"
|
||||
# name: "backuppc"
|
||||
# state: present
|
||||
# with_items:
|
||||
# - nagios
|
||||
# - backuppc
|
||||
#
|
||||
#- name: COMMAND | Activate backuppc config
|
||||
# command: >
|
||||
@@ -19,13 +16,6 @@
|
||||
# owner: backuppc
|
||||
# group: backuppc
|
||||
#
|
||||
#- name: FILE | Fix fcgiwrap permission
|
||||
# file:
|
||||
# path: "{{ nginx_fcgiwrap_sock }}"
|
||||
# mode: 0640
|
||||
# owner: "{{ nginx_user }}"
|
||||
# group: "{{ nginx_user }}"
|
||||
|
||||
#
|
||||
# We don't manage BackupPC on FreeBSD... too dirty. :/
|
||||
#
|
||||
|
||||
@@ -6,25 +6,6 @@
|
||||
state: present
|
||||
when: nginx_backports
|
||||
|
||||
- block:
|
||||
|
||||
- name: APT | Install DotDeb key
|
||||
apt_key:
|
||||
url: 'http://www.dotdeb.org/dotdeb.gpg'
|
||||
state: present
|
||||
|
||||
- name: APT_REPOSITORY | Install dotdeb (PHP 7)
|
||||
apt_repository:
|
||||
repo: 'deb http://packages.dotdeb.org {{ ansible_distribution_release }} all'
|
||||
state: present
|
||||
|
||||
- name: LINEFILEFILE | Dotdeb priority (prevent install nginx from dotdeb)
|
||||
copy:
|
||||
content: "Package: *\nPin: release o=packages.dotdeb.org\nPin-Priority: 100"
|
||||
dest: /etc/apt/preferences
|
||||
|
||||
when: ansible_distribution_release == 'jessie' and dotdeb | default(false)
|
||||
|
||||
- block:
|
||||
|
||||
- name: APT | Install apt-transport-https
|
||||
@@ -45,13 +26,15 @@
|
||||
|
||||
- name: APT | Install needed packages
|
||||
apt:
|
||||
pkg: "{{ item }}"
|
||||
pkg: "{{ packages }}"
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
state: present
|
||||
with_items:
|
||||
vars:
|
||||
packages:
|
||||
- cron
|
||||
- curl
|
||||
- daemonize
|
||||
- fcgiwrap
|
||||
- jq
|
||||
- nghttp2
|
||||
@@ -59,17 +42,13 @@
|
||||
- vim
|
||||
- unzip
|
||||
|
||||
- name: APT | Install daemonize from Stretch
|
||||
apt:
|
||||
deb: http://ftp.us.debian.org/debian/pool/main/d/daemonize/daemonize_1.7.7-1+b1_amd64.deb
|
||||
|
||||
- name: APT | Install PHP
|
||||
apt:
|
||||
pkg: "{{ item.version | php_fpm_package }}"
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
state: present
|
||||
with_items: "{{ nginx_php }}"
|
||||
loop: "{{ nginx_php }}"
|
||||
register: apt_php
|
||||
|
||||
- name: SERVICE | Force start fcgiwrap
|
||||
@@ -77,11 +56,13 @@
|
||||
name: "fcgiwrap"
|
||||
state: started
|
||||
|
||||
# Bypasses Ansible 2.4 issue (cannot use service module)... With service module... php is not really started!
|
||||
# Bypasses Ansible+Docker issue. With service module... php is not really started!
|
||||
- name: COMMAND | Force start PHP
|
||||
command: "service {{ item.version | php_fpm_service }} start"
|
||||
with_items: "{{ nginx_php }}"
|
||||
when: apt_php.changed
|
||||
args:
|
||||
creates: "{{ item.version | php_default_upstream_socket }}"
|
||||
warn: false
|
||||
loop: "{{ nginx_php }}"
|
||||
|
||||
- name: GET_URL | Download ngrok
|
||||
get_url:
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
|
||||
- name: PKGNG | Install needed packages
|
||||
pkgng:
|
||||
pkg: "{{ item }}"
|
||||
pkg: "{{ packages }}"
|
||||
state: present
|
||||
with_items:
|
||||
vars:
|
||||
packages:
|
||||
- curl
|
||||
- daemonize
|
||||
- fcgiwrap
|
||||
@@ -38,7 +39,7 @@
|
||||
state: started
|
||||
enabled: yes
|
||||
register: sf
|
||||
with_items:
|
||||
loop:
|
||||
- php-fpm
|
||||
- fcgiwrap
|
||||
|
||||
|
||||
@@ -14,5 +14,16 @@
|
||||
|
||||
- name: SHELL | Get ngrok public address
|
||||
shell: curl 'http://127.0.0.1:4040/api/tunnels/command_line' | jq '.public_url' | grep -oE '[[:alnum:]]+\.ngrok\.io'
|
||||
args:
|
||||
warn: false
|
||||
register: ngrok
|
||||
changed_when: false
|
||||
|
||||
- name: LINEINFILE | Tune vimrc
|
||||
lineinfile:
|
||||
line: "set mouse="
|
||||
dest: "{{ item }}/.vimrc"
|
||||
create: yes
|
||||
loop:
|
||||
- /root
|
||||
- /home/vagrant
|
||||
|
||||
110
tests/test.yml
110
tests/test.yml
@@ -2,11 +2,11 @@
|
||||
|
||||
- hosts: all
|
||||
pre_tasks:
|
||||
- name: INCLUDE | Pre_tasks related to OS version
|
||||
include: "includes/pre_{{ ansible_distribution }}.yml"
|
||||
- name: INCLUDE_TASKS | Pre_tasks related to OS version
|
||||
include_tasks: "includes/pre_{{ ansible_distribution }}.yml"
|
||||
|
||||
- name: INCLUDE | Pre_tasks common
|
||||
include: "includes/pre_common.yml"
|
||||
- name: IMPORT_TASKS | Pre_tasks common
|
||||
import_tasks: "includes/pre_common.yml"
|
||||
|
||||
- name: FILE | Create an internal SSL dir
|
||||
file:
|
||||
@@ -23,10 +23,20 @@
|
||||
src: "file/test.key"
|
||||
dest: "{{ int_ansible_ssl_dir }}/test.key"
|
||||
|
||||
- name: LINEINFILE | Add all hosts in /etc/hosts
|
||||
lineinfile:
|
||||
line: "127.0.0.1\tlocalhost {% for s in nginx_sites %}{% if s.name is string %}{{ s.name }}{% else %}{% for n in s.name %}{{ n }} {% endfor %}{% endif %} {% if s.redirect_from is defined %}{% for rf in s.redirect_from %}{{ rf }} {% endfor %}{% endif %}{% endfor %}"
|
||||
regexp: '^127\.0\.0\.1'
|
||||
- name: COPY | Add all hosts in /etc/hosts
|
||||
copy:
|
||||
content: |
|
||||
127.0.0.1 localhost
|
||||
{% for s in nginx_sites %}
|
||||
{% if s.name is string %}
|
||||
127.0.0.1 {{ s.name }}
|
||||
{% else %}
|
||||
127.0.0.1 {% for n in s.name %}{{ n }} {% endfor %}
|
||||
{% endif %}
|
||||
{% if s.redirect_from is defined %}
|
||||
127.0.0.1 {% for rf in s.redirect_from %}{{ rf }} {% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
dest: "/etc/hosts"
|
||||
unsafe_writes: yes
|
||||
|
||||
@@ -60,11 +70,6 @@
|
||||
state: 'absent'
|
||||
- name: 'hanx'
|
||||
password: 'qwerty'
|
||||
- name: 'nagios'
|
||||
description: 'Please login to Nagios!'
|
||||
users:
|
||||
- name: 'nagiosadmin'
|
||||
password: 'nagios'
|
||||
- name: 'deleteme'
|
||||
description: 'Please login!'
|
||||
users: []
|
||||
@@ -76,6 +81,9 @@
|
||||
- '{{ ngrok.stdout }}'
|
||||
acme: true
|
||||
acme_port: 8888
|
||||
- name: 'test-ssl-selfsigned.local'
|
||||
self_signed: true
|
||||
force: false
|
||||
- name: 'test-ssl-predeployed.local'
|
||||
dest_key: "{{ int_ansible_ssl_dir }}/test.key"
|
||||
dest_cert: "{{ int_ansible_ssl_dir }}/test.crt"
|
||||
@@ -146,7 +154,7 @@
|
||||
- 'test2-alias.local'
|
||||
template: '_base'
|
||||
filename : 'first-test'
|
||||
override_try_files: '$uri $uri index.htm index.html'
|
||||
override_try_files: '$uri $uri /index.htm /index.html'
|
||||
headers:
|
||||
'X-Frame-Options': 'deny always'
|
||||
'X-ansible-default': '1'
|
||||
@@ -166,9 +174,10 @@
|
||||
- 'deny all;'
|
||||
- name: 'test-htpasswd.local'
|
||||
template: '_base'
|
||||
location:
|
||||
location_before:
|
||||
'/hello':
|
||||
- htpasswd: 'hello'
|
||||
location:
|
||||
'/public':
|
||||
- htpasswd: false
|
||||
use_error_log: true
|
||||
@@ -177,20 +186,22 @@
|
||||
htpasswd: 'hello'
|
||||
- name: 'test-location.local'
|
||||
template: '_base'
|
||||
location_before:
|
||||
'/b':
|
||||
- 'alias /var/tmp;'
|
||||
'/c':
|
||||
- 'alias /var/tmp;'
|
||||
location:
|
||||
'/':
|
||||
- 'alias /var/tmp;'
|
||||
'/a':
|
||||
- 'alias /var/tmp;'
|
||||
'/b':
|
||||
- 'alias /var/tmp;'
|
||||
'/c':
|
||||
- 'alias /var/tmp;'
|
||||
location_order_before:
|
||||
- '/b'
|
||||
- '/c'
|
||||
location_order:
|
||||
- '/'
|
||||
- '/a'
|
||||
- '/b'
|
||||
- '/c'
|
||||
- name: 'test-php.local'
|
||||
php_version: "{{ nginx_php.1.version if nginx_php.1 is defined else nginx_php.0.version }}"
|
||||
upstream_params:
|
||||
@@ -218,12 +229,12 @@
|
||||
- name: 'backuppc.local'
|
||||
template: '_backuppc'
|
||||
htpasswd: 'hello'
|
||||
- name: 'nagios3.local'
|
||||
template: '_nagios3'
|
||||
htpasswd: 'nagios'
|
||||
- name: 'test-ssl.local'
|
||||
proto: ['http', 'https']
|
||||
template: '_base'
|
||||
- name: 'test-ssl-selfsigned.local'
|
||||
proto: ['http', 'https']
|
||||
template: '_base'
|
||||
- name: 'test-ssl-predeployed.local'
|
||||
proto: ['http', 'https']
|
||||
template: '_base'
|
||||
@@ -268,8 +279,8 @@
|
||||
# --------------------------------
|
||||
# Apps
|
||||
# --------------------------------
|
||||
- name: INCLUDE | Post_tasks related to OS version
|
||||
include: "includes/post_{{ ansible_distribution }}.yml"
|
||||
- name: INCLUDE_TASKS | Post_tasks related to OS version
|
||||
include_tasks: "includes/post_{{ ansible_distribution }}.yml"
|
||||
|
||||
# --------------------------------
|
||||
# Deploy index files
|
||||
@@ -278,7 +289,7 @@
|
||||
copy:
|
||||
dest: "{{ nginx_root }}/{{ item }}/public/index.php"
|
||||
content: "<?php phpinfo();"
|
||||
with_items:
|
||||
loop:
|
||||
- 'test-php.local'
|
||||
- 'test-php-index.local'
|
||||
- 'test-php-index2.local'
|
||||
@@ -287,11 +298,12 @@
|
||||
copy:
|
||||
dest: "{{ item }}/index.html"
|
||||
content: "Index HTML test OK\n"
|
||||
with_items:
|
||||
loop:
|
||||
- '{{ nginx_root }}/first-test/public'
|
||||
- '/var/tmp'
|
||||
- '{{ nginx_root }}/test-htpasswd-all.local/public'
|
||||
- '{{ nginx_root }}/test-ssl.local/public'
|
||||
- '{{ nginx_root }}/test-ssl-selfsigned.local/public'
|
||||
- '{{ nginx_root }}/test-ssl-predeployed.local/public'
|
||||
- '{{ nginx_root }}/test-ssl-proxy-protocol.local/public'
|
||||
- '{{ nginx_root }}/{{ ngrok.stdout }}/public'
|
||||
@@ -320,7 +332,7 @@
|
||||
url: "http://{{ item | nginx_site_name }}{% if item.listen is defined %}:{{ item.listen[0] }}{% endif %}/"
|
||||
status_code: '200,301,302,401,403'
|
||||
follow_redirects: none
|
||||
with_items: "{{ nginx_sites }}"
|
||||
loop: "{{ nginx_sites }}"
|
||||
when: item.state is undefined or item.state != "absent"
|
||||
changed_when: false
|
||||
|
||||
@@ -334,7 +346,7 @@
|
||||
url: "http://{{ item.redirect_from[0] }}/"
|
||||
status_code: 301
|
||||
follow_redirects: none
|
||||
with_items: "{{ nginx_sites }}"
|
||||
loop: "{{ nginx_sites }}"
|
||||
when: item.redirect_from is defined and (item.state is undefined or item.state != "absent") and (item.proto is not defined or 'https' not in item.proto)
|
||||
changed_when: false
|
||||
|
||||
@@ -344,7 +356,7 @@
|
||||
status_code: 301
|
||||
follow_redirects: none
|
||||
validate_certs: no
|
||||
with_items: "{{ nginx_sites }}"
|
||||
loop: "{{ nginx_sites }}"
|
||||
when: item.redirect_from is defined and (item.state is undefined or item.state != "absent") and item.proto is defined and 'https' in item.proto
|
||||
changed_when: false
|
||||
|
||||
@@ -356,7 +368,7 @@
|
||||
url: "http://{{ item.name }}/"
|
||||
return_content: yes
|
||||
register: p
|
||||
with_items: "{{ nginx_sites }}"
|
||||
loop: "{{ nginx_sites }}"
|
||||
when: >
|
||||
item.template is defined and
|
||||
(item.template == '_php' or item.template == '_php_index' or item.template == '_php_index2')
|
||||
@@ -421,33 +433,6 @@
|
||||
when: ansible_distribution != 'FreeBSD'
|
||||
failed_when: authbpc.content.find('BackupPC Server Status') == -1
|
||||
|
||||
# --------------------------------
|
||||
# Nagios (not avaiblable on Debian >= 9 and not tested on FreeBSD)
|
||||
# --------------------------------
|
||||
- block:
|
||||
|
||||
- name: -- VERIFY NAGIOS3 PHP --
|
||||
uri:
|
||||
url: "http://nagios3.local/side.php"
|
||||
user: "nagiosadmin"
|
||||
password: "nagios"
|
||||
force_basic_auth: yes
|
||||
return_content: yes
|
||||
register: nagios_php
|
||||
failed_when: nagios_php.content.find('Nagios Core') == -1
|
||||
|
||||
- name: -- VERIFY NAGIOS3 CGI --
|
||||
uri:
|
||||
url: "http://nagios3.local/cgi-bin{% if ansible_distribution == 'Debian' %}/nagios3{% endif %}/summary.cgi"
|
||||
user: "nagiosadmin"
|
||||
password: "nagios"
|
||||
force_basic_auth: yes
|
||||
return_content: yes
|
||||
register: nagios_cgi
|
||||
failed_when: nagios_cgi.content.find('Nagios Event Summary') == -1
|
||||
|
||||
when: ansible_distribution == 'Debian' and ansible_distribution_major_version | version_compare('9', 'lt')
|
||||
|
||||
# --------------------------------
|
||||
# SSL
|
||||
# --------------------------------
|
||||
@@ -458,8 +443,9 @@
|
||||
validate_certs: no
|
||||
register: sslok
|
||||
failed_when: sslok.content.find('Index HTML test OK') == -1
|
||||
with_items:
|
||||
loop:
|
||||
- 'test-ssl-predeployed.local'
|
||||
- 'test-ssl-selfsigned.local'
|
||||
- 'test-ssl.local'
|
||||
- '{{ ngrok.stdout }}'
|
||||
|
||||
@@ -472,7 +458,7 @@
|
||||
follow_redirects: none
|
||||
register: sslredirok
|
||||
failed_when: '"https://%s%s" % (item.name, ":" + item.port if item.port is defined else "") not in sslredirok.location'
|
||||
with_items:
|
||||
loop:
|
||||
- name: 'test-ssl-redirect.local'
|
||||
- name: 'test-ssl-redirect-many.local'
|
||||
port: '8443'
|
||||
@@ -534,3 +520,5 @@
|
||||
executable: /bin/sh
|
||||
changed_when: false
|
||||
when: nginx_auto_config_httpv2 and 'http_v2' in nginx_modules
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
@@ -3,6 +3,4 @@ nginx_pid: '/run/nginx.pid'
|
||||
nginx_etc_dir: '/etc/nginx'
|
||||
|
||||
# Specific sites
|
||||
nginx_nagios_root: '/usr/share/nagios3/htdocs'
|
||||
nginx_nagios_stylesheets: '/etc/nagios3/stylesheets'
|
||||
nginx_fcgiwrap_sock: '/var/run/fcgiwrap.socket'
|
||||
|
||||
@@ -3,7 +3,6 @@ nginx_pid: '/var/run/nginx.pid'
|
||||
nginx_etc_dir: '/usr/local/etc/nginx'
|
||||
|
||||
# Specific sites
|
||||
nginx_nagios_root: '/usr/local/www/nagios'
|
||||
nginx_fcgiwrap_sock: '/var/run/fcgiwrap/fcgiwrap.sock'
|
||||
|
||||
nginx_acmesh_bin: '/usr/local/sbin/acme.sh'
|
||||
|
||||
@@ -41,7 +41,6 @@ nginx_dirs:
|
||||
|
||||
nginx_templates_no_dir:
|
||||
- '_backuppc'
|
||||
- '_nagios3'
|
||||
- '_proxy'
|
||||
|
||||
nginx_servers_default_headers:
|
||||
|
||||
Reference in New Issue
Block a user