mirror of
https://github.com/HanXHX/ansible-nginx.git
synced 2026-02-28 09:22:10 +07:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8218e5c972 | ||
|
|
87c1c68949 | ||
|
|
817929beca | ||
|
|
678dff9a1a |
41
.travis.yml
41
.travis.yml
@@ -1,31 +1,22 @@
|
||||
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-jessie' ANSIBLE_VERSION='ansible>=2.5,<2.6'
|
||||
- PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.5,<2.6'
|
||||
- PLATFORM='docker-debian-jessie-dotdeb' ANSIBLE_VERSION='ansible>=2.5,<2.6'
|
||||
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.5,<2.6'
|
||||
- PLATFORM='docker-debian-stretch-sury' ANSIBLE_VERSION='ansible>=2.5,<2.6'
|
||||
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.6,<2.7'
|
||||
- PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.6,<2.7'
|
||||
- PLATFORM='docker-debian-jessie-dotdeb' ANSIBLE_VERSION='ansible>=2.6,<2.7'
|
||||
- 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-jessie' ANSIBLE_VERSION='ansible>=2.7,<2.8'
|
||||
- PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.7,<2.8'
|
||||
- PLATFORM='docker-debian-jessie-dotdeb' ANSIBLE_VERSION='ansible>=2.7,<2.8'
|
||||
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.7,<2.8'
|
||||
- PLATFORM='docker-debian-stretch-sury' 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
|
||||
|
||||
@@ -30,7 +30,7 @@ Supported OS:
|
||||
Requirements
|
||||
------------
|
||||
|
||||
None. If you set true to `nginx_backports`, you must install backports repository before lauching this role.
|
||||
Ansible 2.5+. If you set true to `nginx_backports`, you must install backports repository before lauching this role.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
@@ -15,4 +15,3 @@ Sites not tested
|
||||
----------------
|
||||
|
||||
- BackupPC
|
||||
- Nagios
|
||||
|
||||
@@ -42,7 +42,6 @@ Templates
|
||||
- `_backuppc`: access to [BackupPC](http://backuppc.sourceforge.net/) (be careful: you need to install [fcgiwrap](https://packages.debian.org/jessie/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
|
||||
```
|
||||
|
||||
|
||||
@@ -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.5
|
||||
platforms:
|
||||
- name: Debian
|
||||
versions:
|
||||
- jessie
|
||||
- stretch
|
||||
- name: FreeBSD
|
||||
versions:
|
||||
- 11.0
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
---
|
||||
|
||||
- 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: APT | Update cache
|
||||
apt:
|
||||
update_cache: yes
|
||||
@@ -29,11 +21,10 @@
|
||||
|
||||
- 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
|
||||
ansible_distribution_major_version is version('9', 'ge') or
|
||||
nginx_backports
|
||||
|
||||
- name: APT | Install python-passlib
|
||||
|
||||
@@ -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 }}"
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
|
||||
- name: COMMAND | Restart nginx
|
||||
command: service nginx restart
|
||||
args:
|
||||
warn: false
|
||||
when: fake_site.changed and ansible_virtualization_type == 'docker'
|
||||
|
||||
- name: SHELL | Get certificates
|
||||
|
||||
@@ -44,6 +44,16 @@
|
||||
notify: restart nginx
|
||||
no_log: not nginx_debug_role
|
||||
|
||||
- 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_site_name + '.key' }} -out {{ item | nginx_site_name + '.crt' }}"
|
||||
args:
|
||||
chdir: "{{ nginx_ssl_dir + '/' + item | nginx_site_name }}"
|
||||
creates: "{% if item.force is defined and item.force %}/tmp/dummy{% else %}{{ nginx_ssl_dir + '/' + item | nginx_site_name + '/' + item | nginx_site_name + '.crt' }}{% endif %}"
|
||||
with_items: "{{ nginx_ssl_pairs }}"
|
||||
when: item.self_signed is defined
|
||||
notify: restart nginx
|
||||
no_log: not nginx_debug_role
|
||||
|
||||
- name: Check DH command status
|
||||
async_status:
|
||||
jid: "{{ dh.ansible_job_id }}"
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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,10 +3,10 @@
|
||||
#
|
||||
|
||||
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 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 %};
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains"{% if nginx_version.stdout is version('1.7.5', 'ge') %} always{% endif %};
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
resolver {{ nginx_resolver_hosts | join(' ') }} valid={{ nginx_resolver_valid }};
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
#
|
||||
|
||||
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_protocols TLSv1 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 %};
|
||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains"{% if nginx_version.stdout is version('1.7.5', 'ge') %} always{% endif %};
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
resolver {{ nginx_resolver_hosts | join(' ') }} valid={{ nginx_resolver_valid }};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
user {{ nginx_user }};
|
||||
worker_processes {{ nginx_worker_processes }};
|
||||
pid {{ nginx_pid }};
|
||||
{% if nginx_version.stdout | version_compare('1.9.11', 'ge') %}
|
||||
{% if nginx_version.stdout is version('1.9.11', 'ge') %}
|
||||
include {{ nginx_etc_dir }}/modules-enabled/*.conf;
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ 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 | replace(' always', '') }}"{% if nginx_version.stdout is version('1.7.5', 'ge') and ' always' in value %} always{% endif %};
|
||||
{% endfor %}
|
||||
# <-- Custom headers
|
||||
{% endblock %}
|
||||
|
||||
@@ -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 %}
|
||||
@@ -2,17 +2,12 @@
|
||||
|
||||
- name: APT | Install webapps
|
||||
apt:
|
||||
pkg: "{{ item }}"
|
||||
pkg: "{{ packages }}"
|
||||
state: present
|
||||
install_recommends: no
|
||||
with_items:
|
||||
- backuppc
|
||||
|
||||
- name: APT | Install nagios3 (only on old Debian releases)
|
||||
apt:
|
||||
pkg: nagios3
|
||||
state: present
|
||||
when: ansible_distribution_major_version | version_compare('9', 'lt')
|
||||
vars:
|
||||
packages:
|
||||
- backuppc
|
||||
|
||||
- name: SERVICE | Ensure backuppc is started
|
||||
service:
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
# pkg: "{{ item }}"
|
||||
# state: present
|
||||
# with_items:
|
||||
# - nagios
|
||||
# - backuppc
|
||||
#
|
||||
#- name: COMMAND | Activate backuppc config
|
||||
@@ -19,13 +18,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. :/
|
||||
#
|
||||
|
||||
@@ -45,19 +45,20 @@
|
||||
|
||||
- name: APT | Install needed packages
|
||||
apt:
|
||||
pkg: "{{ item }}"
|
||||
pkg: "{{ packages }}"
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
state: present
|
||||
with_items:
|
||||
- cron
|
||||
- curl
|
||||
- fcgiwrap
|
||||
- jq
|
||||
- nghttp2
|
||||
- strace
|
||||
- vim
|
||||
- unzip
|
||||
vars:
|
||||
packages:
|
||||
- cron
|
||||
- curl
|
||||
- fcgiwrap
|
||||
- jq
|
||||
- nghttp2
|
||||
- strace
|
||||
- vim
|
||||
- unzip
|
||||
|
||||
- name: APT | Install daemonize from Stretch
|
||||
apt:
|
||||
@@ -69,7 +70,7 @@
|
||||
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 +78,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,17 +15,18 @@
|
||||
|
||||
- name: PKGNG | Install needed packages
|
||||
pkgng:
|
||||
pkg: "{{ item }}"
|
||||
pkg: "{{ packages }}"
|
||||
state: present
|
||||
with_items:
|
||||
- curl
|
||||
- daemonize
|
||||
- fcgiwrap
|
||||
- GeoIP
|
||||
- jq
|
||||
- nghttp2
|
||||
- php72
|
||||
- vim
|
||||
vars:
|
||||
packages:
|
||||
- curl
|
||||
- daemonize
|
||||
- fcgiwrap
|
||||
- GeoIP
|
||||
- jq
|
||||
- nghttp2
|
||||
- php72
|
||||
- vim
|
||||
|
||||
- name: COMMAND | Get geoip database
|
||||
command: geoipupdate.sh
|
||||
@@ -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
|
||||
|
||||
@@ -60,11 +60,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 +71,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"
|
||||
@@ -218,12 +216,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'
|
||||
@@ -278,7 +276,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 +285,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 +319,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 +333,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 +343,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 +355,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 +420,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 +430,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 +445,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'
|
||||
|
||||
@@ -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