31 Commits
1.4.0 ... 1.5.0

Author SHA1 Message Date
Emilien M
8218e5c972 Fix deprecations (#35)
* Drop Nagios support
* Fix start PHP-FPM on Docker
* Fix deprecations on Ansible 2.7

- with_ -> loop
- fix filters as test
- test version_compare -> version
- set min_version to 2.5
2019-01-24 11:05:46 +01:00
Emilien Mantel
87c1c68949 Add Ansible 2.5 + 2.6 to travis 2018-10-03 14:09:20 +02:00
Emilien Mantel
817929beca Add self-signed cert feature 2018-04-20 09:32:46 +02:00
Emilien Mantel
678dff9a1a Tune vimrc (mouse is boring on stretch) 2018-04-20 09:20:39 +02:00
Emilien Mantel
3da65983bd Fix acme create 2018-03-22 20:35:51 +01:00
Emilien Mantel
3fb8f092fb Fake site + force IPv6 2018-03-22 20:30:10 +01:00
Emilien Mantel
19a85ca381 Autoconfigure ipv6 on fakesite 2018-03-22 19:48:41 +01:00
Emilien Mantel
2bab49221a Autoconfigure IPv6 on each server 2018-03-22 19:47:30 +01:00
Emilien Mantel
6e877c070e Configure nginx restart with acme.sh 2018-03-22 19:03:33 +01:00
Emilien Mantel
c165f88126 Manage multiple names with acme.sh 2018-03-22 18:43:44 +01:00
Emilien Mantel
59dd3997de Acme uses light fake sites 2018-03-22 18:39:10 +01:00
Emilien Mantel
ae6dc88bc4 Delete current site when playing with acme.sh 2018-03-22 17:49:02 +01:00
Emilien Mantel
6719b415ab Fix playbook crash whith acme and multiple domain 2018-03-22 17:47:53 +01:00
Emilien Mantel
fd21603a4d Fix FreeBSD version for galaxy 2018-03-18 12:37:27 +01:00
Emilien Mantel
f52be2bbf3 Add FreeBSD in meta/main.yml 2018-03-17 14:52:14 +01:00
Emilien Mantel
a4aeec0a94 Drop check legacy nginx version 2018-03-17 14:08:48 +01:00
Emilien Mantel
713a2241de Drop owncloud code 2018-03-17 14:04:48 +01:00
Emilien Mantel
6cae501266 Drop fastcgi_params supprort 2018-03-17 14:02:08 +01:00
Emilien Mantel
dd7834e8ce Fix daemonize lock file (ngrok)
It overwrited ngrok binary on Debian
2018-03-17 14:01:07 +01:00
Emilien Mantel
cb031c4014 Force shell for FreeBSD 2018-03-17 14:00:01 +01:00
Emilien Mantel
db97fe84f8 Add doc for FreeBSD 2018-03-17 12:54:57 +01:00
Emilien Mantel
c9629e385f Working on FreeBSD 11/12 2018-03-17 12:24:19 +01:00
Emilien Mantel
5843d695b3 Manage FreeBSD 11 2018-03-16 21:56:15 +01:00
Emilien Mantel
8c7d581131 Fix php upstream with TCP socket 2018-03-16 18:53:53 +01:00
Emilien Mantel
0b85d81991 Better redirect management
Fixes renew with letsencrypt (always redirect and never handle
challenge)
2018-03-15 18:30:01 +01:00
Emilien Mantel
7fe08beb9a Enable TLSv1.3 on nginx v1.13.0 2018-03-15 18:13:13 +01:00
Emilien Mantel
33ef161623 Ansible 2.4 must not fail now 2018-03-15 18:07:36 +01:00
Emilien Mantel
c2685732a4 Manages Ansible 2.4+ with Docker
Closes #30
2018-03-15 18:06:38 +01:00
Emilien Mantel
737dfbeb30 Add debug mode 2018-03-15 16:10:37 +01:00
Emilien Mantel
def13392a7 Add Ansible 2.5 on travis 2018-03-15 12:56:12 +01:00
Emilien Mantel
6897f66344 redirect_from manages now https sites 2018-03-15 12:54:12 +01:00
39 changed files with 449 additions and 487 deletions

View File

@@ -1,25 +1,22 @@
env: env:
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.2,<2.3' - PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.5,<2.6'
- PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.2,<2.3' - PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.5,<2.6'
- PLATFORM='docker-debian-jessie-dotdeb' ANSIBLE_VERSION='ansible>=2.2,<2.3' - PLATFORM='docker-debian-jessie-dotdeb' ANSIBLE_VERSION='ansible>=2.5,<2.6'
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.3,<2.4' - PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.5,<2.6'
- PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.3,<2.4' - PLATFORM='docker-debian-stretch-sury' ANSIBLE_VERSION='ansible>=2.5,<2.6'
- PLATFORM='docker-debian-jessie-dotdeb' ANSIBLE_VERSION='ansible>=2.3,<2.4' - PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.3,<2.4' - PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-debian-stretch-sury' ANSIBLE_VERSION='ansible>=2.3,<2.4' - PLATFORM='docker-debian-jessie-dotdeb' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.4,<2.5' - PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.4,<2.5' - PLATFORM='docker-debian-stretch-sury' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-debian-jessie-dotdeb' ANSIBLE_VERSION='ansible>=2.4,<2.5' - PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.7,<2.8'
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.4,<2.5' - PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.7,<2.8'
- PLATFORM='docker-debian-stretch-sury' ANSIBLE_VERSION='ansible>=2.4,<2.5' - 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: matrix:
allow_failures:
- env: PLATFORM='docker-debian-jessie' ANSIBLE_VERSION='ansible>=2.4,<2.5'
- env: PLATFORM='docker-debian-jessie-backports' ANSIBLE_VERSION='ansible>=2.4,<2.5'
- env: PLATFORM='docker-debian-jessie-dotdeb' ANSIBLE_VERSION='ansible>=2.4,<2.5'
- env: PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.4,<2.5'
- env: PLATFORM='docker-debian-stretch-sury' ANSIBLE_VERSION='ansible>=2.4,<2.5'
fast_finish: true fast_finish: true
sudo: required sudo: required

View File

@@ -18,10 +18,19 @@ Features:
- Can listen with proxy protocol - Can listen with proxy protocol
- Generate certificates with acme.sh (let's encrypt) -- *EXPERIMENTAL* - Generate certificates with acme.sh (let's encrypt) -- *EXPERIMENTAL*
Supported OS:
| OS | Working | Stable (active support) |
| ------------------ | ------- | ----------------------- |
| Debian Jessie (8) | Yes | Yes |
| Debian Stretch (9) | Yes | Yes |
| FreeBSD 11 | Yes | No |
| FreeBSD 12 | Yes | No |
Requirements 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 Role Variables
-------------- --------------
@@ -54,7 +63,12 @@ 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_module_packages`: package list module to install - `nginx_module_packages`: package list module to install (Debian)
- `nginx_load_modules`: module list to load (full path), should be used only on FreeBSD
### Misc
- `nginx_debug_role`: set _true_ if you need to see output of no\_log tasks
About modules About modules
------------- -------------

50
Vagrantfile vendored
View File

@@ -14,7 +14,8 @@ Vagrant.configure("2") do |config|
] ]
vms_freebsd = [ vms_freebsd = [
{ :name => "freebsd-10.2", :box => "freebsd/FreeBSD-10.2-STABLE" } { :name => "freebsd-11", :box => "freebsd/FreeBSD-11.1-STABLE", :vars => {} },
{ :name => "freebsd-12", :box => "freebsd/FreeBSD-12.0-CURRENT", :vars => {} }
] ]
conts = [ conts = [
@@ -26,6 +27,7 @@ Vagrant.configure("2") do |config|
] ]
config.vm.network "private_network", type: "dhcp" config.vm.network "private_network", type: "dhcp"
config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
conts.each do |opts| conts.each do |opts|
config.vm.define opts[:name] do |m| config.vm.define opts[:name] do |m|
@@ -38,7 +40,7 @@ Vagrant.configure("2") do |config|
ansible.playbook = "tests/test.yml" ansible.playbook = "tests/test.yml"
ansible.verbose = 'vv' ansible.verbose = 'vv'
ansible.become = true ansible.become = true
ansible.extra_vars = opts[:vars] ansible.extra_vars = opts[:vars].merge({ "nginx_debug_role": true })
end end
end end
end end
@@ -54,32 +56,28 @@ Vagrant.configure("2") do |config|
ansible.playbook = "tests/test.yml" ansible.playbook = "tests/test.yml"
ansible.verbose = 'vv' ansible.verbose = 'vv'
ansible.become = true ansible.become = true
ansible.extra_vars = opts[:vars] ansible.extra_vars = opts[:vars].merge({ "nginx_debug_role": true })
end
end
end
vms_freebsd.each do |opts|
config.vm.base_mac = "080027D14C66"
config.vm.define opts[:name] do |m|
m.vm.box = opts[:box]
m.vm.provider "virtualbox" do |v, override|
override.ssh.shell = "csh"
v.cpus = 2
v.memory = 512
end
m.vm.provision "shell", inline: "pkg install -y python bash"
m.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/test.yml"
ansible.verbose = 'vv'
ansible.become = true
ansible.extra_vars = opts[:vars].merge({ "nginx_debug_role": true, "ansible_python_interpreter": '/usr/local/bin/python' })
end end
end end
end end
# See: https://forums.freebsd.org/threads/52717/
# vms_freebsd.each do |opts|
# config.vm.define opts[:name] do |m|
# m.vm.box = opts[:box]
# m.vm.provider "virtualbox" do |v|
# v.vm.cpus = 1
# v.vm.memory = 256
# v.vm.guest = :freebsd
# v.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
# v.vm.base_mac = "080027D14C66"
# end
# config.ssh.shell = "sh"
# m.vm.provision "shell", inline: "pkg install -y python bash"
# m.vm.provision "ansible" do |ansible|
# ansible.playbook = "tests/test.yml"
# ansible.verbose = 'vv'
# ansible.become = true
# ansible.extra_vars = {
# ansible_python_interpreter: '/usr/local/bin/python'
# }
# end
# end
# end
end end

View File

@@ -108,6 +108,7 @@ nginx_ssl_pairs: []
# Dynamic modules # Dynamic modules
# #
nginx_module_packages: [] nginx_module_packages: []
nginx_load_modules: []
# #
# Diffie-Hellman # Diffie-Hellman
@@ -124,9 +125,7 @@ nginx_acmesh_dir: "/opt/acme.sh"
nginx_acmesh_git_dir: "/tmp/acme.sh" nginx_acmesh_git_dir: "/tmp/acme.sh"
nginx_acmesh_test: false nginx_acmesh_test: false
# Extra #
# Debug
# Note: #
# - On Debian, if you use Owncloud from Upstream repository, you must set this var to "/var/www/owncloud" nginx_debug_role: false
# - TODO: force this var in vars/FreeBSD.yml
nginx_owncloud_root: '/usr/share/owncloud'

View File

@@ -1,4 +1,17 @@
Freebsd Freebsd
======= =======
Limitations
-----------
Due to Ansible + FreeBSD limitations (`ansible_processor_vcpus`), You must explicitely set `nginx_worker_processes`. Due to Ansible + FreeBSD limitations (`ansible_processor_vcpus`), You must explicitely set `nginx_worker_processes`.
About modules
-------------
Dynamic modules must be set with full path (see `nginx_load_modules` path).
Sites not tested
----------------
- BackupPC

View File

@@ -42,8 +42,6 @@ Templates
- `_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/jessie/fcgiwrap))
- `_dokuwiki` - `_dokuwiki`
- `_redirect`: should not be called explicitly - `_redirect`: should not be called explicitly
- `_nagios3`: access to Nagios3 (be careful: you need to install [fcgiwrap](https://packages.debian.org/jessie/fcgiwrap))
- `_owncloud`: access to Owncloud (note: you must set `nginx_apt_package` to //nginx-extras//) **UNSTABLE**
- `_phalcon`: Phalcon PHP Framework - `_phalcon`: Phalcon PHP Framework
- `_php`: PHP base template. Can work with many frameworks/tools - `_php`: PHP base template. Can work with many frameworks/tools
- `_php_index`: Same as above. But you can only run index.php - `_php_index`: Same as above. But you can only run index.php

View File

@@ -15,24 +15,41 @@ Variables
Cert/Key pairs 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 - `key`: content of the private key
- `cert`: content of the public 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_cert`: remote path where certificate is located
- `dest_key`: remote path where key 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 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). - 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 Diffie-Hellman
@@ -55,6 +72,10 @@ nginx_sites;
- name: 'test-ssl3.local' - name: 'test-ssl3.local'
proto: ['http', 'https'] proto: ['http', 'https']
template: '_base' template: '_base'
- name: 'test-self-signed.local'
proto: ['http', 'https']
template: '_base'
ssl_name: 'this.is.self.signed'
nginx_ssl_pairs: nginx_ssl_pairs:
- name: mysuperkey - name: mysuperkey
@@ -68,5 +89,8 @@ nginx_ssl_pairs:
-----END CERTIFICATE----- -----END CERTIFICATE-----
- name: test-ssl2.local - name: test-ssl2.local
acme: true acme: true
- name: this.is.self.signed
self_signed: true
force: false
``` ```

View File

@@ -2,21 +2,35 @@
- name: reload nginx - name: reload nginx
command: nginx -t command: nginx -t
notify: real-reload nginx notify:
- real-reload nginx
- docker reload nginx
- name: restart nginx - name: restart nginx
command: nginx -t command: nginx -t
notify: real-restart nginx notify:
- real-restart nginx
- docker restart nginx
- name: real-reload nginx - name: real-reload nginx
service: service:
name: nginx name: nginx
state: reloaded state: reloaded
when: ansible_virtualization_type != 'docker'
- name: real-restart nginx - name: real-restart nginx
service: service:
name: nginx name: nginx
state: restarted state: restarted
when: ansible_virtualization_type != 'docker'
- name: docker reload nginx
command: service nginx reload
when: ansible_virtualization_type == 'docker'
- name: docker restart nginx
command: service nginx restart
when: ansible_virtualization_type == 'docker'
- name: restart nginx freebsd - name: restart nginx freebsd
service: service:

View File

@@ -1,17 +1,20 @@
--- ---
galaxy_info: galaxy_info:
author: Emilien Mantel author: Emilien Mantel
description: Nginx for Debian description: Nginx for Debian / FreeBSD
company: company:
license: GPLv2 license: GPLv2
min_ansible_version: 2.2 min_ansible_version: 2.5
platforms: platforms:
- name: Debian - name: Debian
versions: versions:
- jessie - jessie
- stretch
- name: FreeBSD - name: FreeBSD
versions: versions:
- 10.2 - 11.0
- 11.1
- 12.0
galaxy_tags: galaxy_tags:
- web - web
- proxy - proxy

View File

@@ -24,11 +24,22 @@
regexp: '{{ item.0.regexp }}' regexp: '{{ item.0.regexp }}'
line: '{{ item.0.line }}' line: '{{ item.0.line }}'
dest: '{{ item.1 }}' dest: '{{ item.1 }}'
with_nested: loop: "{{ list_one | product(list_two) | list }}"
- vars:
list_one:
- regexp: '^fastcgi_param SCRIPT_FILENAME' - regexp: '^fastcgi_param SCRIPT_FILENAME'
line: 'fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;' line: 'fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;'
- regexp: '^fastcgi_param DOCUMENT_ROOT' - regexp: '^fastcgi_param DOCUMENT_ROOT'
line: 'fastcgi_param DOCUMENT_ROOT $realpath_root;' line: 'fastcgi_param DOCUMENT_ROOT $realpath_root;'
- [ '/etc/nginx/fastcgi_params', '/etc/nginx/fastcgi.conf' ] list_two:
- '{{ nginx_etc_dir }}/fastcgi.conf'
when: nginx_fastcgi_fix_realpath when: nginx_fastcgi_fix_realpath
- name: COPY | Add modules manually
copy:
content: |
{% for m in nginx_load_modules %}
load_module {{ m }};
{% endfor %}
dest: "{{ nginx_etc_dir }}/modules-enabled/000-modules.conf"
notify: reload nginx

View File

@@ -6,7 +6,7 @@
state: absent state: absent
with_items: "{{ nginx_htpasswd }}" with_items: "{{ nginx_htpasswd }}"
when: item.state is defined and item.state == 'absent' when: item.state is defined and item.state == 'absent'
no_log: true no_log: not nginx_debug_role
- name: HTPASSWD | Manage files - name: HTPASSWD | Manage files
htpasswd: htpasswd:
@@ -18,4 +18,4 @@
- "{{ nginx_htpasswd }}" - "{{ nginx_htpasswd }}"
- users - users
when: item.0.state is not defined or item.0.state == 'present' when: item.0.state is not defined or item.0.state == 'present'
no_log: true no_log: not nginx_debug_role

View File

@@ -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 - name: APT | Update cache
apt: apt:
update_cache: yes update_cache: yes
@@ -29,14 +21,38 @@
- name: APT | Install nginx modules - name: APT | Install nginx modules
apt: apt:
pkg: "{{ item }}" pkg: "{{ nginx_module_packages }}"
state: present state: present
with_items: "{{ nginx_module_packages }}"
when: when:
ansible_distribution_major_version | version_compare('9', 'ge') or ansible_distribution_major_version is version('9', 'ge') or
nginx_backports nginx_backports
- name: APT | Install python-passlib - name: APT | Install python-passlib
apt: apt:
pkg: python-passlib pkg: python-passlib
state: present state: present
- name: STAT | Check acme.sh is installed
stat:
path: "{{ nginx_acmesh_dir }}"
register: acme
- block:
- name: APT | Install git
apt:
pkg: git
- name: GIT | Get acme.sh
git:
repo: 'https://github.com/Neilpang/acme.sh.git'
dest: '{{ nginx_acmesh_git_dir }}'
update: no
- name: SHELL | Install acme.sh
shell: ./acme.sh --install --home {{ nginx_acmesh_dir }} --cert-home {{ nginx_acmesh_dir }}
args:
chdir: "{{ nginx_acmesh_git_dir }}"
creates: "{{ nginx_acmesh_dir }}"
when: not acme.stat.exists

View File

@@ -5,10 +5,37 @@
name: "{{ item }}" name: "{{ item }}"
state: present state: present
with_items: with_items:
- acme.sh
- "{{ nginx_pkgng_package }}" - "{{ nginx_pkgng_package }}"
- py27-passlib - py27-passlib
- curl - curl
#
# Bypass https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224166#c1
#
- block:
- name: COMMAND | Create /usr/local/etc/fdfs/http.conf
command: touch /usr/local/etc/fdfs/http.conf
args:
creates: /usr/local/etc/fdfs/http.conf
register: fd1
- name: LINEINFILE | Tune fdfs
lineinfile:
regexp: ^load_fdfs_parameters_from_tracker
line: load_fdfs_parameters_from_tracker=false
path: /usr/local/etc/fdfs/mod_fastdfs.conf
register: fd2
- name: SERVICE | Restart nginx when fdfs is tuned
service:
name: nginx
state: restarted
when: fd1.changed or fd2.changed
when: true
- name: FILE | Create configuration dir (like Debian) - name: FILE | Create configuration dir (like Debian)
file: file:
path: "{{ nginx_etc_dir }}/{{ item }}" path: "{{ nginx_etc_dir }}/{{ item }}"
@@ -18,27 +45,6 @@
- sites-available - sites-available
- sites-enabled - sites-enabled
- name: STAT | Check fastcgi.conf
stat:
path: "{{ nginx_etc_dir }}/fastcgi.conf"
register: conf
- name: COPY | config
command: "cp {{ nginx_etc_dir }}/fastcgi_params {{ nginx_etc_dir }}/fastcgi.conf"
when: not conf.stat.exists
notify: reload nginx
- name: LINEINFILE | Add fastcgi config
lineinfile:
line: "fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;"
dest: "{{ nginx_etc_dir }}/fastcgi.conf"
notify: reload nginx
- name: COPY | Populate proxy_params
copy:
content: "proxy_set_header Host $http_host;\nproxy_set_header X-Real-IP $remote_addr;\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;"
dest: "{{ nginx_etc_dir }}/proxy_params"
- name: FILE | Create log directory - name: FILE | Create log directory
file: file:
path: "{{ nginx_log_dir }}" path: "{{ nginx_log_dir }}"

View File

@@ -30,7 +30,7 @@
owner: "{{ item.owner | default(nginx_user) }}" owner: "{{ item.owner | default(nginx_user) }}"
group: "{{ item.group | default(nginx_user) }}" group: "{{ item.group | default(nginx_user) }}"
mode: "{{ item.mode | default('0755') }}" mode: "{{ item.mode | default('0755') }}"
with_items: "{{ nginx_sites }}" loop: "{{ nginx_sites }}"
when: > when: >
item.root is not defined and item.root is not defined and
(item.template is defined and item.template not in nginx_templates_no_dir) and (item.template is defined and item.template not in nginx_templates_no_dir) and
@@ -43,9 +43,9 @@
template: template:
src: "etc/nginx/sites-available/{{ item.template if item.redirect_to is not defined else '_redirect' }}.j2" 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 }}" dest: "{{ nginx_etc_dir }}/sites-available/{{ item | nginx_site_filename }}"
with_items: "{{ nginx_sites }}"
notify: ['reload nginx', 'restart nginx freebsd'] notify: ['reload nginx', 'restart nginx freebsd']
when: item.state is not defined or item.state != 'absent' when: item.state is not defined or item.state != 'absent'
loop: "{{ nginx_sites }}"
loop_control: loop_control:
label: "{{ item | nginx_site_name }}" label: "{{ item | nginx_site_name }}"

View File

@@ -1,33 +1,9 @@
--- ---
- name: APT | Install git
apt: pkg=git
- name: SET_FACT | Assign default.. - name: SET_FACT | Assign default..
set_fact: set_fact:
acme_create: [] acme_create: []
- name: STAT | Check acme.sh is installed
stat:
path: "{{ nginx_acmesh_dir }}"
register: acme
- block:
- name: GIT | Get acme.sh
git:
repo: 'https://github.com/Neilpang/acme.sh.git'
dest: '{{ nginx_acmesh_git_dir }}'
update: no
- name: SHELL | Install acme.sh
shell: ./acme.sh --install --home {{ nginx_acmesh_dir }} --cert-home {{ nginx_acmesh_dir }}
args:
chdir: "{{ nginx_acmesh_git_dir }}"
creates: "{{ nginx_acmesh_dir }}"
when: not acme.stat.exists
- name: STAT | Check if certificates are already installed - name: STAT | Check if certificates are already installed
stat: stat:
path: "{{ nginx_ssl_dir }}/{{ item | nginx_site_name }}/{{ item | nginx_site_name }}.crt" path: "{{ nginx_ssl_dir }}/{{ item | nginx_site_name }}/{{ item | nginx_site_name }}.crt"
@@ -37,22 +13,35 @@
- name: SET_FACT | Assign var with certificates to create - name: SET_FACT | Assign var with certificates to create
set_fact: set_fact:
acme_create: "{{ acme_create | default([]) + [ (item.item | combine({'listen': ([item.item.acme_port|default(80)]) }) ) ] }}" acme_create: "{{ acme_create | default([]) + [ (item.item) ] }}"
with_items: "{{ acme_installed_certs.results }}" with_items: "{{ acme_installed_certs.results }}"
when: item.skipped is not defined and not item.stat.exists when: item.skipped is not defined and not item.stat.exists
- name: TEMPLATE | Create fake site - name: TEMPLATE | Create fake site
template: template:
src: "etc/nginx/sites-available/_base.j2" src: "etc/nginx/conf.d/FAKESITE.conf.j2"
dest: "{{ nginx_etc_dir }}/conf.d/FAKESITE_{{ item | nginx_site_name }}.conf" dest: "{{ nginx_etc_dir }}/conf.d/FAKESITE_{{ item | nginx_site_name }}.conf"
with_items: "{{ acme_create }}" with_items: "{{ acme_create }}"
register: fake_site register: fake_site
- name: SERVICE | Reload nginx - name: FILE | Delete current site if needed
file:
path: "{{ nginx_etc_dir }}/sites-enabled/{{ item | nginx_site_name }}"
state: absent
with_items: "{{ acme_create }}"
when: fake_site.changed
- name: SERVICE | Restart nginx
service: service:
name: nginx name: nginx
state: reloaded state: restarted
when: fake_site.changed when: fake_site.changed and ansible_virtualization_type != 'docker'
- name: COMMAND | Restart nginx
command: service nginx restart
args:
warn: false
when: fake_site.changed and ansible_virtualization_type == 'docker'
- name: SHELL | Get certificates - 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 %}' 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 %}'
@@ -61,7 +50,7 @@
with_items: "{{ acme_create }}" with_items: "{{ acme_create }}"
register: acme_get register: acme_get
failed_when: acme_get.rc != 0 and acme_get.rc != 2 failed_when: acme_get.rc != 0 and acme_get.rc != 2
no_log: true no_log: not nginx_debug_role
- name: FILE | Create SSL dir per site - name: FILE | Create SSL dir per site
file: file:
@@ -69,7 +58,7 @@
with_items: "{{ acme_create }}" with_items: "{{ acme_create }}"
- name: SHELL | Install certificates - 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' 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"'
args: args:
creates: "{{ nginx_ssl_dir }}/{{ item | nginx_site_name }}/{{ item | nginx_site_name }}.key" creates: "{{ nginx_ssl_dir }}/{{ item | nginx_site_name }}/{{ item | nginx_site_name }}.key"
with_items: "{{ nginx_ssl_pairs }}" with_items: "{{ nginx_ssl_pairs }}"

View File

@@ -18,31 +18,41 @@
- name: FILE | Create SSL directories - name: FILE | Create SSL directories
file: file:
path: "{{ nginx_ssl_dir + '/' + item.name }}" path: "{{ nginx_ssl_dir + '/' + item | nginx_site_name }}"
state: directory state: directory
with_items: "{{ nginx_ssl_pairs }}" with_items: "{{ nginx_ssl_pairs }}"
when: item.dest_key is not defined or item.dest_cert is not defined when: item.dest_key is not defined or item.dest_cert is not defined
no_log: true no_log: not nginx_debug_role
- name: COPY | Deploy SSL keys - name: COPY | Deploy SSL keys
copy: copy:
content: "{{ item.key }}" content: "{{ item.key }}"
dest: "{{ nginx_ssl_dir + '/' + item.name + '/' + item.name + '.key' if item.dest_key is not defined else item.dest_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 }}"
mode: 0640 mode: 0640
with_items: "{{ nginx_ssl_pairs }}" with_items: "{{ nginx_ssl_pairs }}"
when: item.key is defined when: item.key is defined
notify: restart nginx notify: restart nginx
no_log: true no_log: not nginx_debug_role
- name: COPY | Deploy SSL certs - name: COPY | Deploy SSL certs
copy: copy:
content: "{{ item.cert }}" content: "{{ item.cert }}"
dest: "{{ nginx_ssl_dir + '/' + item.name + '/' + item.name + '.crt' if item.dest_cert is not defined else item.dest_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 }}"
mode: 0644 mode: 0644
with_items: "{{ nginx_ssl_pairs }}" with_items: "{{ nginx_ssl_pairs }}"
when: item.cert is defined when: item.cert is defined
notify: restart nginx notify: restart nginx
no_log: true 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 - name: Check DH command status
async_status: async_status:

View File

@@ -17,7 +17,7 @@
template: template:
src: "etc/nginx/conf.d/_upstream.conf.j2" src: "etc/nginx/conf.d/_upstream.conf.j2"
dest: "{{ nginx_etc_dir }}/conf.d/upstream-{{ item.name }}.conf" 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' when: item.state is not defined or item.state == 'present'
notify: reload nginx notify: reload nginx

View File

@@ -0,0 +1,10 @@
server {
listen {{ item.acme_port | default('80') }};
listen [::]:{{ item.acme_port | default('80') }};
server_name {% if item.name is string %}{{ item.name }}{% else %}{{ item.name | join(" ") }}{% endif %}{% if item.redirect_from is defined %} {% if item.redirect_from is string %}{{ item.redirect_from }}{% else %}{{ item.redirect_from | join(" ") }}{% endif %}{% endif %};
location / {
return 503;
}
}

View File

@@ -1,5 +1,5 @@
{%- macro s(key, value, is_bool, min_version) %} {%- 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 %} {% if is_bool and value %} {{ key }}{% elif not is_bool %} {{ key }}={{ value }}{% endif %}
{% endif %} {% endif %}
{%- endmacro -%} {%- endmacro -%}

View File

@@ -5,7 +5,7 @@
{% for php in nginx_php %} {% for php in nginx_php %}
upstream {{ php.upstream_name | default((php.version | php_default_upstream_name)) }} { upstream {{ php.upstream_name | default((php.version | php_default_upstream_name)) }} {
{% for sock in php.sockets | default([]) %} {% for sock in php.sockets | default([]) %}
{% if php.host is defined %} {% if sock.host is defined %}
server {{ sock.host }}:{{ sock.port }} weight={{ sock.weight | default('1') }} max_fails={{ sock.max_fails | default('5') }} fail_timeout={{ sock.fail_timeout | default('10s') }}; server {{ sock.host }}:{{ sock.port }} weight={{ sock.weight | default('1') }} max_fails={{ sock.max_fails | default('5') }} fail_timeout={{ sock.fail_timeout | default('10s') }};
{% else %} {% else %}
server unix:{{ sock.unix | default((php.version | php_default_upstream_socket)) }} weight={{ sock.weight | default('1') }}; server unix:{{ sock.unix | default((php.version | php_default_upstream_socket)) }} weight={{ sock.weight | default('1') }};

View File

@@ -3,14 +3,12 @@
# #
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_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; 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_prefer_server_ciphers on;
ssl_session_cache shared:SSL: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 %}; add_header Strict-Transport-Security "max-age=63072000; includeSubDomains"{% if nginx_version.stdout is version('1.7.5', 'ge') %} always{% endif %};
{% if nginx_version.stdout | version_compare('1.3.7', 'ge') %}
ssl_stapling on; ssl_stapling on;
ssl_stapling_verify on; ssl_stapling_verify on;
{% endif %}
resolver {{ nginx_resolver_hosts | join(' ') }} valid={{ nginx_resolver_valid }}; resolver {{ nginx_resolver_hosts | join(' ') }} valid={{ nginx_resolver_valid }};
resolver_timeout {{ nginx_resolver_timeout }}; resolver_timeout {{ nginx_resolver_timeout }};
ssl_dhparam {{ nginx_dh_path }}; ssl_dhparam {{ nginx_dh_path }};

View File

@@ -3,14 +3,12 @@
# #
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"; ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 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_prefer_server_ciphers on;
ssl_session_cache shared:SSL: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 %}; add_header Strict-Transport-Security "max-age=63072000; includeSubDomains"{% if nginx_version.stdout is version('1.7.5', 'ge') %} always{% endif %};
{% if nginx_version.stdout | version_compare('1.3.7', 'ge') %}
ssl_stapling on; ssl_stapling on;
ssl_stapling_verify on; ssl_stapling_verify on;
{% endif %}
resolver {{ nginx_resolver_hosts | join(' ') }} valid={{ nginx_resolver_valid }}; resolver {{ nginx_resolver_hosts | join(' ') }} valid={{ nginx_resolver_valid }};
resolver_timeout {{ nginx_resolver_timeout }}; resolver_timeout {{ nginx_resolver_timeout }};
ssl_dhparam {{ nginx_dh_path }}; ssl_dhparam {{ nginx_dh_path }};

View File

@@ -5,7 +5,7 @@
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.11', 'ge') %} {% if nginx_version.stdout is version('1.9.11', 'ge') %}
include {{ nginx_etc_dir }}/modules-enabled/*.conf; include {{ nginx_etc_dir }}/modules-enabled/*.conf;
{% endif %} {% endif %}

View File

@@ -25,7 +25,7 @@
{% block template_upstream_location %} {% block template_upstream_location %}
location ~ \.cgi$ { location ~ \.cgi$ {
gzip off; gzip off;
include {{ nginx_etc_dir }}/fastcgi_params; include fastcgi.conf;
fastcgi_pass unix:/var/run/fcgiwrap.socket; fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index BackupPC_Admin; fastcgi_index BackupPC_Admin;
fastcgi_param SCRIPT_FILENAME /usr/share/backuppc/cgi-bin$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME /usr/share/backuppc/cgi-bin$fastcgi_script_name;

View File

@@ -1,7 +1,7 @@
{% set __proto = item.proto | default(['http']) %} {% set __proto = item.proto | default(['http']) %}
{% set __main_name = item | nginx_site_filename %} {% set __main_name = item | nginx_site_filename %}
{% set __listen = item.listen | default([80]) %} {% set __listen = item.listen | default(['80', '[::]:80']) %}
{% set __listen_ssl = item.listen_ssl | default([443]) %} {% set __listen_ssl = item.listen_ssl | default(['443', '[::]:443']) %}
{% set __http_proxy_protocol_port = item.http_proxy_protocol_port | default([]) %} {% set __http_proxy_protocol_port = item.http_proxy_protocol_port | default([]) %}
{% set __https_proxy_protocol_port = item.https_proxy_protocol_port | default([]) %} {% set __https_proxy_protocol_port = item.https_proxy_protocol_port | default([]) %}
{% set __location = item.location | default({}) %} {% set __location = item.location | default({}) %}
@@ -17,7 +17,7 @@
{%- endif %} {%- endif %}
{%- endmacro %} {%- endmacro %}
{% macro ssl(ssl_name) %} {% macro ssl(ssl_name) %}
{% for sn in nginx_ssl_pairs if sn.name == 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 {{ 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_key {{ nginx_ssl_dir + '/' + ssl_name + '/' + ssl_name + '.key' if sn.dest_key is not defined else sn.dest_key }};
{% endfor %} {% endfor %}
@@ -28,8 +28,10 @@ server {
listen {{ port }}{% if port | int in __http_proxy_protocol_port %} proxy_protocol{% endif %}; listen {{ port }}{% if port | int in __http_proxy_protocol_port %} proxy_protocol{% endif %};
{% endfor %} {% endfor %}
server_name {{ 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; return 301 https://{{ name }}{% if '443' not in __listen_ssl and 443 not in __listen_ssl %}:{{ __listen_ssl[0] }}{% endif %}$request_uri;
} }
}
{% endmacro %} {% endmacro %}
# #
@@ -81,7 +83,7 @@ server {
{% block template_headers %} {% block template_headers %}
# --> Custom headers # --> Custom headers
{% for key, value in __headers.iteritems() %} {% 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 %} {% endfor %}
# <-- Custom headers # <-- Custom headers
{% endblock %} {% endblock %}
@@ -170,8 +172,27 @@ server {
listen {{ port }}{% if port | int in __http_proxy_protocol_port %} proxy_protocol{% endif %}; listen {{ port }}{% if port | int in __http_proxy_protocol_port %} proxy_protocol{% endif %};
{% endfor %} {% 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 {% if item.redirect_from is string %}{{ item.redirect_from }}{% else %}{{ "\n\t\t" }}{{ item.redirect_from | join("\n\t\t") }}{% endif %};
location / {
return 301 $scheme://{{ item.name if item.name is string else item.name[0] }}$request_uri; return 301 $scheme://{{ item.name if item.name is string else item.name[0] }}$request_uri;
} }
}
{% if 'https' in __proto %}
server {
{% for port in __listen_ssl %}
listen {{ port }}{% if nginx_default_site_ssl == __main_name %} default_server{% endif %} ssl{% if nginx_auto_config_httpv2 and 'http_v2' in nginx_modules %} http2{% endif %}{% if port | int in __https_proxy_protocol_port %} proxy_protocol{% endif %};
{% endfor %}
{{ ssl(__ssl_name) }}
{% 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 %};
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;
}
}
{% endif %}
{% endif %} {% endif %}
# vim:filetype=nginx # vim:filetype=nginx

View File

@@ -1,67 +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;
{% if nginx_version.stdout | version_compare('1.6.1', 'lt') %}
include fastcgi_params;
{% else %}
include fastcgi.conf;
{% endif %}
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;
{% if nginx_version.stdout | version_compare('1.6.1', 'lt') %}
include fastcgi_params;
{% else %}
include fastcgi.conf;
{% endif %}
}
{% endblock %}

View File

@@ -1,87 +0,0 @@
{% extends "_php.j2" %}
{% block root %}
root {{ nginx_owncloud_root }};
{% endblock %}
{% block template_index %}
index index.php;
{% endblock %}
{% block template_more %}
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;
gzip off;
client_max_body_size 10G;
fastcgi_buffers 64 4K;
rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
{% endblock %}
{% block template_headers %}
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Content-Type-Options nosniff;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
add_header X-Frame-Options SAMEORIGIN;
{% endblock %}
{% block template_try_files %}
try_files $uri $uri/ =404;
{% endblock %}
{% block template_upstream_location %}
location ~ /remote.php {
dav_methods PUT DELETE MKCOL COPY MOVE;
dav_ext_methods PROPFIND OPTIONS;
fastcgi_pass {{ php_upstream }};
fastcgi_param HOME {{ nginx_owncloud_root }};
fastcgi_param HTTP_HOME {{ nginx_owncloud_root }};
fastcgi_param PATH /usr/local/bin:/usr/bin:/bin;
fastcgi_param modHeadersAvailable true;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
{% if nginx_version.stdout | version_compare('1.6.1', 'lt') %}
include fastcgi_params;
{% else %}
include fastcgi.conf;
{% endif %}
}
location ~ \.php(?:$|/) {
fastcgi_pass {{ php_upstream }};
fastcgi_index index.php;
fastcgi_param HOME {{ nginx_owncloud_root }};
fastcgi_param HTTP_HOME {{ nginx_owncloud_root }};
fastcgi_param PATH /usr/local/bin:/usr/bin:/bin;
fastcgi_param modHeadersAvailable true;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
{% if nginx_version.stdout | version_compare('1.6.1', 'lt') %}
include fastcgi_params;
{% else %}
include fastcgi.conf;
{% endif %}
}
{% endblock %}
{% block template_local_content %}
location ~* \.(?:css|js)$ {
try_files $uri /index.php$is_args$args;
expires 2h;
}
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|swf)$ {
expires 2d;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ ^/(?:\.ht|data|config|db_structure\.xml|README){
deny all;
}
{% endblock %}

View File

@@ -29,10 +29,6 @@
{{ param }} {{ param }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if nginx_version.stdout | version_compare('1.6.1', 'lt') %}
include fastcgi_params;
{% else %}
include fastcgi.conf; include fastcgi.conf;
{% endif %}
} }
{% endblock %} {% endblock %}

View File

@@ -10,11 +10,7 @@
{{ param }} {{ param }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if nginx_version.stdout | version_compare('1.6.1', 'lt') %}
include fastcgi_params;
{% else %}
include fastcgi.conf; include fastcgi.conf;
{% endif %}
} }
{% endblock %} {% endblock %}

View File

@@ -14,10 +14,6 @@
{{ param }} {{ param }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if nginx_version.stdout | version_compare('1.6.1', 'lt') %}
include fastcgi_params;
{% else %}
include fastcgi.conf; include fastcgi.conf;
{% endif %}
} }
{% endblock %} {% endblock %}

View File

@@ -2,18 +2,12 @@
- name: APT | Install webapps - name: APT | Install webapps
apt: apt:
pkg: "{{ item }}" pkg: "{{ packages }}"
state: present state: present
install_recommends: no install_recommends: no
with_items: vars:
packages:
- backuppc - backuppc
# - owncloud
- name: APT | Install nagios3 (only on old Debian releases)
apt:
pkg: nagios3
state: present
when: ansible_distribution_major_version | version_compare('9', 'lt')
- name: SERVICE | Ensure backuppc is started - name: SERVICE | Ensure backuppc is started
service: service:

View File

@@ -1,31 +1,23 @@
--- ---
- name: APT | Install web apps #- name: APT | Install web apps
pkgng: # pkgng:
pkg: "{{ item }}" # pkg: "{{ item }}"
state: present # state: present
with_items: # with_items:
- nagios # - backuppc
- backuppc #
#- name: COMMAND | Activate backuppc config
- name: COMMAND | Activate backuppc config # command: >
command: > # cp /usr/local/etc/backuppc/config.pl.sample /usr/local/etc/backuppc/config.pl
cp /usr/local/etc/backuppc/config.pl.sample /usr/local/etc/backuppc/config.pl # creates=/usr/local/etc/backuppc/config.pl
creates=/usr/local/etc/backuppc/config.pl #
#- name: FILE | Fix backuppc permissions
- name: FILE | Fix backuppc permissions # file:
file: # path: /usr/local/etc/backuppc/config.pl
path: /usr/local/etc/backuppc/config.pl # owner: backuppc
owner: backuppc # group: 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. :/ # We don't manage BackupPC on FreeBSD... too dirty. :/
# #

View File

@@ -45,11 +45,12 @@
- name: APT | Install needed packages - name: APT | Install needed packages
apt: apt:
pkg: "{{ item }}" pkg: "{{ packages }}"
update_cache: yes update_cache: yes
cache_valid_time: 3600 cache_valid_time: 3600
state: present state: present
with_items: vars:
packages:
- cron - cron
- curl - curl
- fcgiwrap - fcgiwrap
@@ -69,7 +70,7 @@
update_cache: yes update_cache: yes
cache_valid_time: 3600 cache_valid_time: 3600
state: present state: present
with_items: "{{ nginx_php }}" loop: "{{ nginx_php }}"
register: apt_php register: apt_php
- name: SERVICE | Force start fcgiwrap - name: SERVICE | Force start fcgiwrap
@@ -77,11 +78,13 @@
name: "fcgiwrap" name: "fcgiwrap"
state: started 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 - name: COMMAND | Force start PHP
command: "service {{ item.version | php_fpm_service }} start" command: "service {{ item.version | php_fpm_service }} start"
with_items: "{{ nginx_php }}" args:
when: apt_php.changed creates: "{{ item.version | php_default_upstream_socket }}"
warn: false
loop: "{{ nginx_php }}"
- name: GET_URL | Download ngrok - name: GET_URL | Download ngrok
get_url: get_url:
@@ -94,25 +97,6 @@
dest: "/tmp" dest: "/tmp"
remote_src: yes remote_src: yes
- name: SHELL | Check if ngrok is started - name: SET_FACT | ngrok_path
shell: ps aux | grep -q [n]grok set_fact:
register: psngrok ngrok_path: '/tmp/ngrok'
changed_when: false
failed_when: false
- block:
- name: SHELL | Start ngrok
shell: daemonize /tmp/ngrok http 8888 -bind-tls=false
- name: WAIT_FOR | ngrok started
wait_for:
delay: 2
port: 4040
when: psngrok.rc > 0
- 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'
register: ngrok
changed_when: false

View File

@@ -2,23 +2,36 @@
- name: SET_FACT | FreeBSD web user - name: SET_FACT | FreeBSD web user
set_fact: set_fact:
nginx_pkgng_package: 'nginx-devel' nginx_pkgng_package: 'nginx-full'
nginx_user: 'www' nginx_user: 'www'
nginx_php: nginx_php:
- version: '5.6' - version: '7.2'
sockets: sockets:
- host: '127.0.0.1' - host: '127.0.0.1'
port: 9000 port: 9000
nginx_load_modules:
- /usr/local/libexec/nginx/ngx_http_geoip_module.so
ngrok_path: '/usr/local/bin/ngrok'
- name: PKGNG | Install needed packages - name: PKGNG | Install needed packages
pkgng: pkgng:
pkg: "{{ item }}" pkg: "{{ packages }}"
state: present state: present
with_items: vars:
- php56 packages:
- curl - curl
- daemonize
- fcgiwrap - fcgiwrap
- GeoIP
- jq
- nghttp2 - nghttp2
- php72
- vim
- name: COMMAND | Get geoip database
command: geoipupdate.sh
args:
creates: /usr/local/share/GeoIP/GeoIP.dat
- name: SERVICE | Force start services - name: SERVICE | Force start services
service: service:
@@ -26,6 +39,28 @@
state: started state: started
enabled: yes enabled: yes
register: sf register: sf
with_items: loop:
- php-fpm - php-fpm
- fcgiwrap - fcgiwrap
- name: STAT | Check ports
stat:
path: /usr/ports
register: ports
- block:
- name: COMMAND | Get ports
command: portsnap fetch --interactive
- name: COMMAND | Extract ports
command: portsnap extract
no_log: true
when: not ports.stat.exists
- name: SHELL | Install ngrok
shell: make install clean DISABLE_LICENSES=yes
args:
chdir: /usr/ports/security/ngrok
creates: "{{ ngrok_path }}"

View File

@@ -0,0 +1,29 @@
---
- name: SHELL | Start ngrok
shell: daemonize -l /tmp/ngrok.lock {{ ngrok_path }} http 8888 -bind-tls=false
failed_when: false
changed_when: ngrok.stderr.find("Can't lock the lock file") == -1
register: ngrok
- name: WAIT_FOR | ngrok started
wait_for:
delay: 2
port: 4040
when: ngrok.changed
- 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

View File

@@ -4,22 +4,29 @@
pre_tasks: pre_tasks:
- name: INCLUDE | Pre_tasks related to OS version - name: INCLUDE | Pre_tasks related to OS version
include: "includes/pre_{{ ansible_distribution }}.yml" include: "includes/pre_{{ ansible_distribution }}.yml"
- name: INCLUDE | Pre_tasks common
include: "includes/pre_common.yml"
- name: FILE | Create an internal SSL dir - name: FILE | Create an internal SSL dir
file: file:
path: "{{ int_ansible_ssl_dir }}" path: "{{ int_ansible_ssl_dir }}"
state: directory state: directory
- name: COPY | Deploy test certificate - name: COPY | Deploy test certificate
copy: copy:
src: "file/test.crt" src: "file/test.crt"
dest: "{{ int_ansible_ssl_dir }}/test.crt" dest: "{{ int_ansible_ssl_dir }}/test.crt"
- name: COPY | Deploy test key - name: COPY | Deploy test key
copy: copy:
src: "file/test.key" src: "file/test.key"
dest: "{{ int_ansible_ssl_dir }}/test.key" dest: "{{ int_ansible_ssl_dir }}/test.key"
- name: LINEINFILE | Add all hosts in /etc/hosts - name: LINEINFILE | Add all hosts in /etc/hosts
lineinfile: lineinfile:
line: "127.0.2.1\t{% 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 %}" 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\.2' regexp: '^127\.0\.0\.1'
dest: "/etc/hosts" dest: "/etc/hosts"
unsafe_writes: yes unsafe_writes: yes
@@ -53,11 +60,6 @@
state: 'absent' state: 'absent'
- name: 'hanx' - name: 'hanx'
password: 'qwerty' password: 'qwerty'
- name: 'nagios'
description: 'Please login to Nagios!'
users:
- name: 'nagiosadmin'
password: 'nagios'
- name: 'deleteme' - name: 'deleteme'
description: 'Please login!' description: 'Please login!'
users: [] users: []
@@ -65,9 +67,13 @@
nginx_acmesh: true nginx_acmesh: true
nginx_acmesh_test: true nginx_acmesh_test: true
nginx_ssl_pairs: nginx_ssl_pairs:
- name: '{{ ngrok.stdout }}' - name:
- '{{ ngrok.stdout }}'
acme: true acme: true
acme_port: 8888 acme_port: 8888
- name: 'test-ssl-selfsigned.local'
self_signed: true
force: false
- name: 'test-ssl-predeployed.local' - name: 'test-ssl-predeployed.local'
dest_key: "{{ int_ansible_ssl_dir }}/test.key" dest_key: "{{ int_ansible_ssl_dir }}/test.key"
dest_cert: "{{ int_ansible_ssl_dir }}/test.crt" dest_cert: "{{ int_ansible_ssl_dir }}/test.crt"
@@ -122,7 +128,7 @@
-----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;' - 'geoip_country {% if ansible_distribution == "Debian" %}/usr/share/GeoIP/GeoIP.dat{% else %}/usr/local/share/GeoIP/GeoIP.dat{% endif %};'
- 'map $geoip_country_code $allowed_country {' - 'map $geoip_country_code $allowed_country {'
- ' default yes;' - ' default yes;'
- ' MA no;' - ' MA no;'
@@ -210,12 +216,12 @@
- name: 'backuppc.local' - name: 'backuppc.local'
template: '_backuppc' template: '_backuppc'
htpasswd: 'hello' htpasswd: 'hello'
- name: 'nagios3.local'
template: '_nagios3'
htpasswd: 'nagios'
- name: 'test-ssl.local' - name: 'test-ssl.local'
proto: ['http', 'https'] proto: ['http', 'https']
template: '_base' template: '_base'
- name: 'test-ssl-selfsigned.local'
proto: ['http', 'https']
template: '_base'
- name: 'test-ssl-predeployed.local' - name: 'test-ssl-predeployed.local'
proto: ['http', 'https'] proto: ['http', 'https']
template: '_base' template: '_base'
@@ -236,6 +242,9 @@
template: '_base' template: '_base'
ssl_name: 'test-ssl.local' ssl_name: 'test-ssl.local'
redirect_https: true redirect_https: true
redirect_from:
- 'www.test-ssl-redirect-many.local'
- 'www.test-ssl-redirect-many2.local'
- name: 'test-ssl-proxy-protocol.local' - name: 'test-ssl-proxy-protocol.local'
proto: ['http', 'https'] proto: ['http', 'https']
listen: [80, 20080] listen: [80, 20080]
@@ -267,7 +276,7 @@
copy: copy:
dest: "{{ nginx_root }}/{{ item }}/public/index.php" dest: "{{ nginx_root }}/{{ item }}/public/index.php"
content: "<?php phpinfo();" content: "<?php phpinfo();"
with_items: loop:
- 'test-php.local' - 'test-php.local'
- 'test-php-index.local' - 'test-php-index.local'
- 'test-php-index2.local' - 'test-php-index2.local'
@@ -276,11 +285,12 @@
copy: copy:
dest: "{{ item }}/index.html" dest: "{{ item }}/index.html"
content: "Index HTML test OK\n" content: "Index HTML test OK\n"
with_items: loop:
- '{{ nginx_root }}/first-test/public' - '{{ nginx_root }}/first-test/public'
- '/var/tmp' - '/var/tmp'
- '{{ nginx_root }}/test-htpasswd-all.local/public' - '{{ nginx_root }}/test-htpasswd-all.local/public'
- '{{ nginx_root }}/test-ssl.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-predeployed.local/public'
- '{{ nginx_root }}/test-ssl-proxy-protocol.local/public' - '{{ nginx_root }}/test-ssl-proxy-protocol.local/public'
- '{{ nginx_root }}/{{ ngrok.stdout }}/public' - '{{ nginx_root }}/{{ ngrok.stdout }}/public'
@@ -309,7 +319,7 @@
url: "http://{{ item | nginx_site_name }}{% if item.listen is defined %}:{{ item.listen[0] }}{% endif %}/" url: "http://{{ item | nginx_site_name }}{% if item.listen is defined %}:{{ item.listen[0] }}{% endif %}/"
status_code: '200,301,302,401,403' status_code: '200,301,302,401,403'
follow_redirects: none follow_redirects: none
with_items: "{{ nginx_sites }}" loop: "{{ nginx_sites }}"
when: item.state is undefined or item.state != "absent" when: item.state is undefined or item.state != "absent"
changed_when: false changed_when: false
@@ -323,8 +333,18 @@
url: "http://{{ item.redirect_from[0] }}/" url: "http://{{ item.redirect_from[0] }}/"
status_code: 301 status_code: 301
follow_redirects: none 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") 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
- name: -- VERIFY REDIRECT HTTPS SITES --
uri:
url: "https://{{ item.redirect_from[0] }}:{{ item.listen_ssl[0] | default(443) }}/"
status_code: 301
follow_redirects: none
validate_certs: no
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 changed_when: false
# -------------------------------- # --------------------------------
@@ -335,7 +355,7 @@
url: "http://{{ item.name}}/" url: "http://{{ item.name}}/"
return_content: yes return_content: yes
register: p register: p
with_items: "{{ nginx_sites }}" loop: "{{ nginx_sites }}"
when: > when: >
item.template is defined and item.template is defined and
(item.template == '_php' or item.template == '_php_index' or item.template == '_php_index2') (item.template == '_php' or item.template == '_php_index' or item.template == '_php_index2')
@@ -400,55 +420,6 @@
when: ansible_distribution != 'FreeBSD' when: ansible_distribution != 'FreeBSD'
failed_when: authbpc.content.find('BackupPC Server Status') == -1 failed_when: authbpc.content.find('BackupPC Server Status') == -1
# --------------------------------
# Nagios (not avaiblable on Debian >= 9)
# --------------------------------
- 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_major_version | version_compare('9', 'lt')
# --------------------------------
# Owncloud
# --------------------------------
# - block:
# - name: -- VERIFY OWNCLOUD --
# command: "curl -H 'Host: owncloud.local' http://127.0.0.1/"
# changed_when: false
# register: ownsimple
# failed_when: ownsimple.stdout.find('ownCloud') == -1
# - name: -- VERIFY OWNCLOUD JS (FROM PHP)--
# command: "curl -H 'Host: owncloud.local' http://127.0.0.1/index.php/core/js/oc.js"
# changed_when: false
# register: ownjsphp
# failed_when: ownjsphp.stdout.find('var oc_debug=false') == -1
# - name: -- VERIFY OWNCLOUD JS --
# command: "curl -H 'Host: owncloud.local' http://127.0.0.1/core/js/js.js"
# changed_when: false
# register: ownjs
# failed_when: ownjs.stdout.find('var oc_debug') == -1
# when: ansible_distribution != 'FreeBSD'
# -------------------------------- # --------------------------------
# SSL # SSL
# -------------------------------- # --------------------------------
@@ -459,8 +430,9 @@
validate_certs: no validate_certs: no
register: sslok register: sslok
failed_when: sslok.content.find('Index HTML test OK') == -1 failed_when: sslok.content.find('Index HTML test OK') == -1
with_items: loop:
- 'test-ssl-predeployed.local' - 'test-ssl-predeployed.local'
- 'test-ssl-selfsigned.local'
- 'test-ssl.local' - 'test-ssl.local'
- '{{ ngrok.stdout }}' - '{{ ngrok.stdout }}'
@@ -473,7 +445,7 @@
follow_redirects: none follow_redirects: none
register: sslredirok register: sslredirok
failed_when: '"https://%s%s" % (item.name, ":" + item.port if item.port is defined else "") not in sslredirok.location' 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.local'
- name: 'test-ssl-redirect-many.local' - name: 'test-ssl-redirect-many.local'
port: '8443' port: '8443'

View File

@@ -3,6 +3,4 @@ nginx_pid: '/run/nginx.pid'
nginx_etc_dir: '/etc/nginx' nginx_etc_dir: '/etc/nginx'
# Specific sites # Specific sites
nginx_nagios_root: '/usr/share/nagios3/htdocs'
nginx_nagios_stylesheets: '/etc/nagios3/stylesheets'
nginx_fcgiwrap_sock: '/var/run/fcgiwrap.socket' nginx_fcgiwrap_sock: '/var/run/fcgiwrap.socket'

View File

@@ -3,5 +3,6 @@ nginx_pid: '/var/run/nginx.pid'
nginx_etc_dir: '/usr/local/etc/nginx' nginx_etc_dir: '/usr/local/etc/nginx'
# Specific sites # Specific sites
nginx_nagios_root: '/usr/local/www/nagios'
nginx_fcgiwrap_sock: '/var/run/fcgiwrap/fcgiwrap.sock' nginx_fcgiwrap_sock: '/var/run/fcgiwrap/fcgiwrap.sock'
nginx_acmesh_bin: '/usr/local/sbin/acme.sh'

View File

@@ -32,11 +32,15 @@ nginx_dirs:
- dir: "{{ nginx_helper_dir }}" - dir: "{{ nginx_helper_dir }}"
mode: "0755" mode: "0755"
owner: "root" owner: "root"
- dir: "{{ nginx_etc_dir }}/modules-available"
mode: "0755"
owner: "root"
- dir: "{{ nginx_etc_dir }}/modules-enabled"
mode: "0755"
owner: "root"
nginx_templates_no_dir: nginx_templates_no_dir:
- '_backuppc' - '_backuppc'
- '_nagios3'
- '_owncloud'
- '_proxy' - '_proxy'
nginx_servers_default_headers: nginx_servers_default_headers: