mirror of
https://github.com/HanXHX/ansible-nginx.git
synced 2026-02-28 09:22:10 +07:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e2f988beb | ||
|
|
6aea2bcb5f | ||
|
|
8c6c4dc813 | ||
|
|
a2780d3d95 | ||
|
|
6c7e0c2a47 | ||
|
|
bdddb06fcc | ||
|
|
6e5fce00e7 | ||
|
|
8268eb266a | ||
|
|
8b73a835c6 | ||
|
|
40ebe61c57 | ||
|
|
0f8688f290 | ||
|
|
204e95725e | ||
|
|
da08953a27 |
2
.ansible-lint
Normal file
2
.ansible-lint
Normal file
@@ -0,0 +1,2 @@
|
||||
enable_list:
|
||||
- fqcn-builtins
|
||||
48
.travis.yml
48
.travis.yml
@@ -1,35 +1,35 @@
|
||||
---
|
||||
|
||||
env:
|
||||
- PLATFORM='docker-debian-stretch' 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-buster' ANSIBLE_VERSION='ansible>=2.7,<2.8'
|
||||
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.8,<2.9'
|
||||
- PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.8,<2.9'
|
||||
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.9,<2.10'
|
||||
- PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.9,<2.10'
|
||||
global:
|
||||
- VAGRANT_VERSION='2.2.18'
|
||||
jobs:
|
||||
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||
- PLATFORM='docker-debian-bullseye' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||
- PLATFORM='docker-debian-buster' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
sudo: required
|
||||
|
||||
dist: trusty
|
||||
os:
|
||||
- linux
|
||||
dist: focal
|
||||
|
||||
language: python
|
||||
python:
|
||||
- 2.7
|
||||
- 3.6
|
||||
- 3.8
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
- wget https://releases.hashicorp.com/vagrant/2.0.1/vagrant_2.0.1_x86_64.deb
|
||||
- sudo dpkg -i vagrant_2.0.1_x86_64.deb
|
||||
- sudo apt-get -q update
|
||||
- sudo apt-get install -y yamllint
|
||||
- sudo wget -nv https://releases.hashicorp.com/vagrant/${VAGRANT_VERSION}/vagrant_${VAGRANT_VERSION}_x86_64.deb
|
||||
- sudo dpkg -i vagrant_${VAGRANT_VERSION}_x86_64.deb
|
||||
|
||||
install:
|
||||
- pip install "$ANSIBLE_VERSION"
|
||||
- ansible-galaxy install -p ./tests HanXHX.php,master
|
||||
- sudo pip install "ansible-core$ANSIBLE_VERSION"
|
||||
- sudo pip install ansible-lint
|
||||
- ansible-galaxy collection install community.general
|
||||
- ansible-galaxy install -p ./tests HanXHX.php
|
||||
|
||||
script:
|
||||
- VAGRANT_DEFAULT_PROVIDER=docker vagrant up $PLATFORM
|
||||
@@ -39,6 +39,14 @@ script:
|
||||
&& (echo 'Idempotence test: pass' && exit 0)
|
||||
|| (echo 'Idempotence test: fail' && exit 1)
|
||||
- VAGRANT_DEFAULT_PROVIDER=docker vagrant status
|
||||
- >
|
||||
yamllint .
|
||||
&& (echo 'YAML lint test: pass' && exit 0)
|
||||
|| (echo 'YAML lint test: fail' && exit 1)
|
||||
- >
|
||||
ansible-lint -v tests/test.yml
|
||||
&& (echo 'Ansible lint test: pass' && exit 0)
|
||||
|| (echo 'Ansible lint test: fail' && exit 1)
|
||||
|
||||
notifications:
|
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||
|
||||
6
.yamllint.yml
Normal file
6
.yamllint.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
|
||||
extends: default
|
||||
|
||||
rules:
|
||||
line-length: disable
|
||||
23
README.md
23
README.md
@@ -1,7 +1,7 @@
|
||||
Nginx for Debian/FreeBSD Ansible role
|
||||
=====================================
|
||||
|
||||
[](https://galaxy.ansible.com/HanXHX/nginx/) [](https://travis-ci.org/HanXHX/ansible-nginx)
|
||||
[](https://galaxy.ansible.com/HanXHX/nginx/) [](https://app.travis-ci.com/HanXHX/ansible-nginx)
|
||||
|
||||
Install and configure Nginx on Debian/FreeBSD.
|
||||
|
||||
@@ -20,18 +20,20 @@ Features:
|
||||
|
||||
Supported OS:
|
||||
|
||||
| OS | Working | Stable (active support) |
|
||||
| ------------------ | ------- | ----------------------- |
|
||||
| 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 |
|
||||
| OS | Working | Stable (active support) |
|
||||
| -------------------- | ------- | ----------------------- |
|
||||
| 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 | Yes |
|
||||
| Debian Bullseye (11) | Yes | Yes |
|
||||
| FreeBSD 11 | Yes | No |
|
||||
| FreeBSD 12 | Yes | No |
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Ansible 2.6+. If you set true to `nginx_backports`, you must install backports repository before lauching this role.
|
||||
- Ansible >=2.11
|
||||
- If you set true to `nginx_backports`, you must install backports repository before lauching this role.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
@@ -70,7 +72,7 @@ FreeBSD:
|
||||
|
||||
### Misc
|
||||
|
||||
- `nginx_debug_role`: set _true_ if you need to see output of no\_log tasks
|
||||
- `nginx_debug_role`: set _true_ if you need to see output of no\_log tasks
|
||||
|
||||
About modules
|
||||
-------------
|
||||
@@ -99,7 +101,6 @@ Note
|
||||
|
||||
- Active support for Debian.
|
||||
- FreeBSD support is experimental (no Travis). I only test (for the moment) 10.2 (but it can work on other versions).
|
||||
- I don't manage BackupPC for FreeBSD (PR welcome).
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
14
Vagrantfile
vendored
14
Vagrantfile
vendored
@@ -7,7 +7,8 @@ Vagrant.configure("2") do |config|
|
||||
|
||||
vms_debian = [
|
||||
{ :name => "debian-stretch", :box => "debian/stretch64", :vars => {} },
|
||||
{ :name => "debian-buster", :box => "debian/buster64", :vars => {} }
|
||||
{ :name => "debian-buster", :box => "debian/buster64", :vars => {} },
|
||||
{ :name => "debian-bullseye", :box => "debian/bullseye64", :vars => {} }
|
||||
]
|
||||
|
||||
vms_freebsd = [
|
||||
@@ -18,6 +19,7 @@ Vagrant.configure("2") do |config|
|
||||
conts = [
|
||||
{ :name => "docker-debian-stretch", :docker => "hanxhx/vagrant-ansible:debian9", :vars => {} },
|
||||
{ :name => "docker-debian-buster", :docker => "hanxhx/vagrant-ansible:debian10", :vars => {} },
|
||||
{ :name => "docker-debian-bullseye", :docker => "hanxhx/vagrant-ansible:debian11", :vars => {} },
|
||||
]
|
||||
|
||||
config.vm.network "private_network", type: "dhcp"
|
||||
@@ -30,6 +32,11 @@ Vagrant.configure("2") do |config|
|
||||
d.remains_running = true
|
||||
d.has_ssh = true
|
||||
end
|
||||
|
||||
if opts[:name].include? "bullseye"
|
||||
m.vm.provision "shell", inline: "[ -f '/root/first_provision' ] || (apt-get update -qq && apt-get -y dist-upgrade && touch /root/first_provision)"
|
||||
end
|
||||
|
||||
m.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "tests/test.yml"
|
||||
ansible.verbose = 'vv'
|
||||
@@ -46,6 +53,11 @@ Vagrant.configure("2") do |config|
|
||||
v.cpus = 1
|
||||
v.memory = 256
|
||||
end
|
||||
|
||||
if opts[:name].include? "bullseye"
|
||||
m.vm.provision "shell", inline: "[ -f '/root/first_provision' ] || (apt-get update -qq && apt-get -y dist-upgrade && touch /root/first_provision)"
|
||||
end
|
||||
|
||||
m.vm.provision "ansible" do |ansible|
|
||||
ansible.playbook = "tests/test.yml"
|
||||
ansible.verbose = 'vv'
|
||||
|
||||
@@ -14,7 +14,7 @@ nginx_log_dir: '/var/log/nginx'
|
||||
nginx_resolver_hosts: ['8.8.8.8', '8.8.4.4']
|
||||
nginx_resolver_valid: '300s'
|
||||
nginx_resolver_timeout: '5s'
|
||||
nginx_error_log_level: 'warn' # http://nginx.org/en/docs/ngx_core_module.html#error_log
|
||||
nginx_error_log_level: 'warn' # http://nginx.org/en/docs/ngx_core_module.html#error_log
|
||||
nginx_auto_config_httpv2: true
|
||||
nginx_default_site: null
|
||||
nginx_default_site_ssl: null
|
||||
|
||||
@@ -10,8 +10,3 @@ About modules
|
||||
-------------
|
||||
|
||||
Dynamic modules must be set with full path (see `nginx_load_modules` path).
|
||||
|
||||
Sites not tested
|
||||
----------------
|
||||
|
||||
- BackupPC
|
||||
|
||||
96
doc/site.md
96
doc/site.md
@@ -9,14 +9,30 @@ Common
|
||||
------
|
||||
|
||||
- `name`: (M) Domain or list of domain used.
|
||||
- `template`: (D) template used to create site. Optional if you set `state`=`absent` or using `redirect_to`.
|
||||
- `filename`: (O) Specify filename in /etc/nginx/sites-*. Do NOT specify default (reserved keyword). It will be used for log filenames and directories creation.
|
||||
- `state`: (O) Site status. Can be "present" (default), "absent" and "disabled".
|
||||
- `filename`: (O) Specify filename in `/etc/nginx/sites-*`. Do NOT specify default (reserved keyword). It will be used for log filenames and directories creation.
|
||||
|
||||
(O): Optional
|
||||
(M): Mandatory
|
||||
(D): Depends other keys...
|
||||
|
||||
You can use 2 config (at the same time time):
|
||||
|
||||
- pre-built: Some configuration are templated (Wordpress, Symfony...), auto create root dir, perform an "A+" on ssllabs for https... etc
|
||||
- custom: Push your own site config template. Usefull when you have a complex configuration.
|
||||
|
||||
|
||||
Pre-built site config
|
||||
---------------------
|
||||
|
||||
# Keys
|
||||
|
||||
- `template`: (M) template used to create site. Optional if you set `state`=`absent` or using `redirect_to`.
|
||||
- `redirect_from`: (O) Domain list to redirect to the first `name`. You can use this key to redirect non-www to www
|
||||
- `redirect_to`: (O) Redirect all requests to this domain. Please set scheme (http:// or https:// or $sheme).
|
||||
- `headers`: (O) Set additionals header as key/value list. You can append "always" to the value. Show [nginx doc](http://nginx.org/en/docs/http/ngx_http_headers_module.html).
|
||||
- `redirect_to_code`: Redirect code (default: 302)
|
||||
- `redirect_https`: (O) Boolean. Redirect HTTP to HTTPS. If "true", you _MUST_ set `proto` to ```['https']```.
|
||||
- `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
|
||||
@@ -33,15 +49,9 @@ Common
|
||||
- `listen_proxy_protocol_ssl` (O) Enable proxy protocol on https port.
|
||||
- `hsts` (O) overwrite default header for hsts
|
||||
|
||||
(O): Optional
|
||||
(M): Mandatory
|
||||
(D): Depends other keys...
|
||||
|
||||
Templates
|
||||
---------
|
||||
### Templates
|
||||
|
||||
- `_base`: static template
|
||||
- `_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
|
||||
- `_phalcon`: Phalcon PHP Framework
|
||||
@@ -52,8 +62,7 @@ Templates
|
||||
|
||||
Templates works as parent-child.
|
||||
|
||||
About proxy template
|
||||
--------------------
|
||||
### About proxy template
|
||||
|
||||
Proxy template allow you to use Nginx as reverse proxy. Usefull when you have an application service such as Redmine, Jenkins...
|
||||
|
||||
@@ -64,10 +73,69 @@ You have many key added to site key:
|
||||
|
||||
(O) : Optional
|
||||
|
||||
Default sites
|
||||
--------------
|
||||
### Default sites
|
||||
|
||||
You can manage default site by setting domain name to these variables.
|
||||
|
||||
- `nginx_default_site`
|
||||
- `nginx_default_site_ssl`
|
||||
|
||||
*IT WORKS ONLY WITH PRE-BUIT SITES*
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
|
||||
```yaml
|
||||
- nginx_sites:
|
||||
- name: 'mywebsite.com'
|
||||
template: '_wordpress'
|
||||
headers:
|
||||
x-ansibled: '1'
|
||||
manage_local_content: false
|
||||
```
|
||||
|
||||
|
||||
Custom site config
|
||||
------------------
|
||||
|
||||
### Keys
|
||||
|
||||
- `custom_template`: (M) template path used
|
||||
|
||||
You can add some extra infos if needed.
|
||||
|
||||
### Example:
|
||||
|
||||
```yaml
|
||||
- nginx_sites:
|
||||
- name: 'mycustom-website.com'
|
||||
custom_template: 'my/template_dir/the-template.conf.j2'
|
||||
allow_admin: '192.168.0.0/24'
|
||||
```
|
||||
|
||||
In `my/template_dir/the-template.conf.j2`:
|
||||
|
||||
```
|
||||
#
|
||||
# {{ ansible_managed }} - {{ item.name }}
|
||||
#
|
||||
|
||||
server {
|
||||
listen 8080 http2 proxy_protocol;
|
||||
server_name {{ item.name }};
|
||||
index index.html;
|
||||
root /var/www/{{ item.name }};
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location /admin {
|
||||
allow {{ item.allow_admin }};
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
---
|
||||
|
||||
- name: reload nginx
|
||||
command: nginx -t
|
||||
ansible.builtin.command: nginx -t
|
||||
notify:
|
||||
- real-reload nginx
|
||||
- docker reload nginx
|
||||
|
||||
- name: restart nginx
|
||||
command: nginx -t
|
||||
ansible.builtin.command: nginx -t
|
||||
notify:
|
||||
- real-restart nginx
|
||||
- docker restart nginx
|
||||
|
||||
- name: real-reload nginx
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: nginx
|
||||
state: reloaded
|
||||
when: ansible_virtualization_type != 'docker'
|
||||
|
||||
- name: real-restart nginx
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: nginx
|
||||
state: restarted
|
||||
when: ansible_virtualization_type != 'docker'
|
||||
|
||||
- name: docker reload nginx
|
||||
command: service nginx reload
|
||||
ansible.builtin.command: service nginx reload
|
||||
args:
|
||||
warn: false
|
||||
when: ansible_virtualization_type == 'docker'
|
||||
|
||||
- name: docker restart nginx
|
||||
command: service nginx restart
|
||||
ansible.builtin.command: service nginx restart
|
||||
args:
|
||||
warn: false
|
||||
when: ansible_virtualization_type == 'docker'
|
||||
|
||||
- name: restart nginx freebsd
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: nginx
|
||||
state: restarted
|
||||
when: ansible_distribution == "FreeBSD"
|
||||
|
||||
- name: setup
|
||||
action: setup
|
||||
ansible.builtin.setup:
|
||||
|
||||
@@ -1,28 +1,33 @@
|
||||
---
|
||||
|
||||
galaxy_info:
|
||||
author: Emilien Mantel
|
||||
namespace: hanxhx
|
||||
role_name: nginx
|
||||
description: Nginx for Debian / FreeBSD
|
||||
company:
|
||||
license: GPLv2
|
||||
min_ansible_version: 2.6
|
||||
min_ansible_version: 2.11
|
||||
platforms:
|
||||
- name: Debian
|
||||
versions:
|
||||
- stretch
|
||||
- buster
|
||||
- name: FreeBSD
|
||||
versions:
|
||||
- 11.0
|
||||
- 11.1
|
||||
- 12.0
|
||||
- name: Debian
|
||||
versions:
|
||||
- stretch
|
||||
- buster
|
||||
- bullseye
|
||||
- name: FreeBSD
|
||||
versions:
|
||||
- 11.0
|
||||
- 11.1
|
||||
- 12.0
|
||||
galaxy_tags:
|
||||
- web
|
||||
- proxy
|
||||
- http
|
||||
- http2
|
||||
- https
|
||||
- ssl
|
||||
- tls
|
||||
- nginx
|
||||
- cdn
|
||||
- web
|
||||
- debian
|
||||
- proxy
|
||||
- http
|
||||
- http2
|
||||
- https
|
||||
- ssl
|
||||
- tls
|
||||
- nginx
|
||||
- cdn
|
||||
dependencies: []
|
||||
|
||||
@@ -1,26 +1,35 @@
|
||||
---
|
||||
|
||||
- name: TEMPLATE | Deploy nginx.conf
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "etc/nginx/nginx.conf.j2"
|
||||
dest: "{{ nginx_etc_dir }}/nginx.conf"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
notify: reload nginx
|
||||
|
||||
- name: TEMPLATE | Deploy all helpers
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ nginx_helper_dir }}/{{ item | basename | regex_replace('.j2$','') }}"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
with_fileglob: '../templates/etc/nginx/helper/*.j2'
|
||||
notify: reload nginx
|
||||
|
||||
- name: TEMPLATE | Deploy custom http configuration
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "etc/nginx/conf.d/custom.conf.j2"
|
||||
dest: "{{ nginx_etc_dir }}/conf.d/custom.conf"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
notify: reload nginx
|
||||
|
||||
- name: LINEINFILE | Fix path
|
||||
lineinfile:
|
||||
ansible.builtin.lineinfile:
|
||||
regexp: '{{ item.0.regexp }}'
|
||||
line: '{{ item.0.line }}'
|
||||
dest: '{{ item.1 }}'
|
||||
@@ -36,10 +45,13 @@
|
||||
when: nginx_fastcgi_fix_realpath
|
||||
|
||||
- name: COPY | Add modules manually
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
content: |
|
||||
{% for m in nginx_load_modules %}
|
||||
load_module {{ m }};
|
||||
{% endfor %}
|
||||
dest: "{{ nginx_etc_dir }}/modules-enabled/000-modules.conf"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
notify: reload nginx
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
---
|
||||
|
||||
- name: FILE | Delete htpasswd file
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ nginx_htpasswd_dir }}/{{ item.name }}"
|
||||
state: absent
|
||||
loop: "{{ nginx_htpasswd }}"
|
||||
when: item.state is defined and item.state == 'absent'
|
||||
no_log: not nginx_debug_role
|
||||
no_log: "{{ not nginx_debug_role }}"
|
||||
|
||||
- name: HTPASSWD | Manage files
|
||||
htpasswd:
|
||||
ansible.builtin.htpasswd:
|
||||
name: "{{ item.1.name }}"
|
||||
password: "{{ item.1.password }}"
|
||||
path: "{{ nginx_htpasswd_dir }}/{{ item.0.name }}"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
loop: "{{ nginx_htpasswd | subelements('users') }}"
|
||||
when: item.0.state is not defined or item.0.state == 'present'
|
||||
no_log: not nginx_debug_role
|
||||
no_log: "{{ not nginx_debug_role }}"
|
||||
|
||||
@@ -1,54 +1,53 @@
|
||||
---
|
||||
|
||||
- name: SET_FACT | Bypass https://github.com/ansible/ansible/issues/19874
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
ansible_distribution_release: 'buster'
|
||||
when: ansible_facts.distribution_major_version == "buster/sid"
|
||||
|
||||
- name: APT | Update cache
|
||||
apt:
|
||||
update_cache: yes
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
changed_when: false
|
||||
|
||||
- name: APT | Install nginx and dependencies
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
pkg: "{{ nginx_apt_package }}"
|
||||
default_release: "{{ ansible_distribution_release + '-backports' if nginx_backports else ansible_distribution_release }}"
|
||||
|
||||
- name: APT | Install nginx modules
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
pkg: "{{ nginx_module_packages }}"
|
||||
state: present
|
||||
|
||||
- name: APT | Install python-passlib
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
pkg: "python{% if ansible_python_version is version('3', '>=') %}3{% endif %}-passlib"
|
||||
state: present
|
||||
|
||||
- name: STAT | Check acme.sh is installed
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ nginx_acmesh_dir }}"
|
||||
register: acme
|
||||
|
||||
- block:
|
||||
|
||||
- name: APT | Install git
|
||||
apt:
|
||||
pkg: git
|
||||
- name: APT | Install git
|
||||
ansible.builtin.apt:
|
||||
pkg: git
|
||||
|
||||
- name: GIT | Get acme.sh
|
||||
git:
|
||||
repo: 'https://github.com/Neilpang/acme.sh.git'
|
||||
dest: '{{ nginx_acmesh_git_dir }}'
|
||||
update: no
|
||||
version: master
|
||||
- name: GIT | Get acme.sh
|
||||
ansible.builtin.git:
|
||||
repo: 'https://github.com/Neilpang/acme.sh.git'
|
||||
dest: '{{ nginx_acmesh_git_dir }}'
|
||||
update: false
|
||||
version: master
|
||||
|
||||
- name: COMMAND | Install acme.sh
|
||||
command: ./acme.sh --install --home "{{ nginx_acmesh_dir }}"
|
||||
args:
|
||||
chdir: "{{ nginx_acmesh_git_dir }}"
|
||||
creates: "{{ nginx_acmesh_dir }}"
|
||||
- name: COMMAND | Install acme.sh
|
||||
ansible.builtin.command: ./acme.sh --install --home "{{ nginx_acmesh_dir }}"
|
||||
args:
|
||||
chdir: "{{ nginx_acmesh_git_dir }}"
|
||||
creates: "{{ nginx_acmesh_dir }}"
|
||||
|
||||
when: not acme.stat.exists
|
||||
|
||||
|
||||
@@ -16,20 +16,20 @@
|
||||
- block:
|
||||
|
||||
- name: COMMAND | Create /usr/local/etc/fdfs/http.conf
|
||||
command: touch /usr/local/etc/fdfs/http.conf
|
||||
ansible.builtin.command: touch /usr/local/etc/fdfs/http.conf
|
||||
args:
|
||||
creates: /usr/local/etc/fdfs/http.conf
|
||||
register: fd1
|
||||
|
||||
- name: LINEINFILE | Tune fdfs
|
||||
lineinfile:
|
||||
ansible.builtin.lineinansible.builtin.file:
|
||||
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:
|
||||
ansible.builtin.service:
|
||||
name: nginx
|
||||
state: restarted
|
||||
when: fd1.changed or fd2.changed
|
||||
@@ -37,16 +37,19 @@
|
||||
when: true
|
||||
|
||||
- name: FILE | Create configuration dir (like Debian)
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ nginx_etc_dir }}/{{ item }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: root
|
||||
loop:
|
||||
- conf.d
|
||||
- sites-available
|
||||
- sites-enabled
|
||||
|
||||
- name: FILE | Create log directory
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ nginx_log_dir }}"
|
||||
owner: "{{ nginx_user }}"
|
||||
group: wheel
|
||||
@@ -54,6 +57,6 @@
|
||||
state: directory
|
||||
|
||||
- name: SERVICE | Enable nginx
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: nginx
|
||||
enabled: yes
|
||||
enabled: true
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
---
|
||||
|
||||
- name: INCLUDE_VARS | Related to OS
|
||||
include_vars: "{{ ansible_distribution }}.yml"
|
||||
ansible.builtin.include_vars: "{{ ansible_distribution }}.yml"
|
||||
tags: ['nginx::site', 'nginx::ssl']
|
||||
|
||||
- name: INCLUDE_TASKS | Install
|
||||
include_tasks: "install_{{ ansible_distribution }}.yml"
|
||||
ansible.builtin.include_tasks: "install_{{ ansible_distribution }}.yml"
|
||||
tags: ['nginx::site', 'nginx::ssl']
|
||||
|
||||
- name: IMPORT_TASKS| Prepare
|
||||
import_tasks: prepare.yml
|
||||
ansible.builtin.import_tasks: prepare.yml
|
||||
tags: ['nginx::site', 'nginx::ssl']
|
||||
|
||||
- name: IMPORT_TASKS| Install
|
||||
import_tasks: config.yml
|
||||
ansible.builtin.import_tasks: config.yml
|
||||
|
||||
- name: IMPORT_TASKS| Upstream configuration
|
||||
import_tasks: upstream.yml
|
||||
ansible.builtin.import_tasks: upstream.yml
|
||||
|
||||
- name: IMPORT_TASKS| htpasswd configuration
|
||||
import_tasks: htpasswd.yml
|
||||
ansible.builtin.import_tasks: htpasswd.yml
|
||||
|
||||
- name: IMPORT_TASKS| SSL configuration
|
||||
import_tasks: ssl/main.yml
|
||||
ansible.builtin.import_tasks: ssl/main.yml
|
||||
tags: ['nginx::ssl']
|
||||
|
||||
- name: IMPORT_TASKS| Sites configuration
|
||||
import_tasks: site.yml
|
||||
ansible.builtin.import_tasks: site.yml
|
||||
tags: ['nginx::site']
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
---
|
||||
|
||||
- name: SHELL | Get Nginx version
|
||||
shell: nginx -v 2>&1 | sed -r 's#.*/##;' | cut -d ' ' -f 1
|
||||
ansible.builtin.shell: nginx -v 2>&1 | sed -r 's#.*/##;' | cut -d ' ' -f 1
|
||||
args:
|
||||
executable: /bin/sh
|
||||
register: nginx_version
|
||||
changed_when: false
|
||||
check_mode: no
|
||||
check_mode: false
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
- name: SHELL | Get module list
|
||||
shell: |
|
||||
ansible.builtin.shell: |
|
||||
nginx -V 2>&1 |
|
||||
tr -- - '\n' |
|
||||
grep -A 1 with |
|
||||
@@ -22,16 +22,16 @@
|
||||
executable: /bin/sh
|
||||
register: shell_modules
|
||||
changed_when: false
|
||||
check_mode: no
|
||||
check_mode: false
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
- name: SET_FACT | Save modules
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
nginx_modules: "{{ shell_modules.stdout_lines }}"
|
||||
|
||||
- name: FILE | Create folders
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
dest: "{{ item.dir }}"
|
||||
owner: "{{ item.owner }}"
|
||||
mode: "{{ item.mode }}"
|
||||
@@ -39,6 +39,9 @@
|
||||
loop: "{{ nginx_dirs }}"
|
||||
|
||||
- name: FILE | Create ansible facts dir
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: /etc/ansible/facts.d
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
|
||||
- name: FAIL | Check filenames
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: "Forbidden keyword default on site {{ item | nginx_site_name }}"
|
||||
when: item.filename is defined and item.filename == 'default'
|
||||
loop: "{{ nginx_sites }}"
|
||||
@@ -9,7 +9,7 @@
|
||||
label: "{{ item | nginx_site_name }}"
|
||||
|
||||
- name: FAIL | Check HTTPS redir and proto
|
||||
fail:
|
||||
ansible.builtin.fail:
|
||||
msg: "You can't have HTTP proto and HTTPS redirection at the same time"
|
||||
when:
|
||||
((item.proto is defined and 'http' in item.proto) or (item.proto is not defined)) and
|
||||
@@ -19,12 +19,15 @@
|
||||
label: "{{ item | nginx_site_name }}"
|
||||
|
||||
- name: FILE | Create root directory
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ nginx_root }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: FILE | Create root public folders (foreach nginx_sites)
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ nginx_root }}/{{ item | nginx_site_filename }}/public"
|
||||
state: directory
|
||||
owner: "{{ item.owner | default(nginx_user) }}"
|
||||
@@ -40,17 +43,30 @@
|
||||
label: "{{ item | nginx_site_name }}"
|
||||
|
||||
- name: TEMPLATE | Create sites
|
||||
template:
|
||||
ansible.builtin.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 }}"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
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') and item.custom_template is not defined
|
||||
loop: "{{ nginx_sites }}"
|
||||
loop_control:
|
||||
label: "{{ item | nginx_site_name }}"
|
||||
|
||||
- name: TEMPLATE | Create sites with preconfigured template
|
||||
template:
|
||||
src: "{{ item.custom_template }}"
|
||||
dest: "{{ nginx_etc_dir }}/sites-available/{{ item | nginx_site_filename }}"
|
||||
notify: ['reload nginx', 'restart nginx freebsd']
|
||||
when: (item.state is not defined or item.state != 'absent') and item.custom_template is defined
|
||||
loop: "{{ nginx_sites }}"
|
||||
loop_control:
|
||||
label: "{{ item | nginx_site_name }}"
|
||||
|
||||
- name: FILE | Delete sites
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ nginx_etc_dir }}/{{ item.1 }}/{{ item.0 | nginx_site_filename }}"
|
||||
state: absent
|
||||
loop: "{{ nginx_sites | product(dirs) | list }}"
|
||||
@@ -62,7 +78,7 @@
|
||||
label: "{{ nginx_etc_dir }}/{{ item.1 }}/{{ item.0 | nginx_site_filename }}"
|
||||
|
||||
- name: FILE | Enable sites
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
src: "{{ nginx_etc_dir }}/sites-available/{{ item | nginx_site_filename }}"
|
||||
dest: "{{ nginx_etc_dir }}/sites-enabled/{{ item | nginx_site_filename }}"
|
||||
state: link
|
||||
@@ -74,7 +90,7 @@
|
||||
label: "{{ item | nginx_site_name }}"
|
||||
|
||||
- name: FILE | Disable sites
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ nginx_etc_dir }}/sites-enabled/{{ item | nginx_site_filename }}"
|
||||
state: absent
|
||||
loop: "{{ nginx_sites }}"
|
||||
@@ -84,14 +100,14 @@
|
||||
label: "{{ item | nginx_site_name }}"
|
||||
|
||||
- name: FILE | Delete default site when explicitely defined
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ nginx_etc_dir }}/sites-enabled/default"
|
||||
state: absent
|
||||
notify: ['reload nginx', 'restart nginx freebsd']
|
||||
when: nginx_default_site is not none
|
||||
|
||||
- name: FILE | Auto set default site
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
src: "{{ nginx_etc_dir }}/sites-available/default"
|
||||
dest: "{{ nginx_etc_dir }}/sites-enabled/default"
|
||||
state: link
|
||||
@@ -99,7 +115,7 @@
|
||||
when: nginx_default_site is none
|
||||
|
||||
- name: TEMPLATE | Deploy facts
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: etc/ansible/facts.d/nginx.fact.j2
|
||||
dest: /etc/ansible/facts.d/nginx.fact
|
||||
mode: 0644
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
---
|
||||
|
||||
- name: SET_FACT | Assign default...
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
acme_create: []
|
||||
|
||||
- name: STAT | Check if certificates are already installed
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ item | nginx_cert_path(nginx_ssl_dir) }}"
|
||||
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:
|
||||
ansible.builtin.set_fact:
|
||||
acme_create: "{{ acme_create | default([]) + [ (item.item) ] }}"
|
||||
loop: "{{ acme_installed_certs.results }}"
|
||||
when: item.skipped is not defined and (not item.stat.exists or item.stat.size == 0)
|
||||
@@ -20,79 +20,82 @@
|
||||
- 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"
|
||||
loop: "{{ acme_create }}"
|
||||
register: fake_site
|
||||
- name: TEMPLATE | Create fake site
|
||||
ansible.builtin.template:
|
||||
src: "etc/nginx/conf.d/FAKESITE.conf.j2"
|
||||
dest: "{{ nginx_etc_dir }}/conf.d/FAKESITE_{{ item | nginx_site_name }}.conf"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
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
|
||||
loop: "{{ acme_create }}"
|
||||
when: fake_site.changed
|
||||
- name: FILE | Delete current site if needed
|
||||
ansible.builtin.file:
|
||||
path: "{{ nginx_etc_dir }}/sites-enabled/{{ item | nginx_site_name }}"
|
||||
state: absent
|
||||
loop: "{{ acme_create }}"
|
||||
when: fake_site.changed
|
||||
|
||||
- name: SERVICE | Restart nginx
|
||||
service:
|
||||
name: nginx
|
||||
state: restarted
|
||||
when: fake_site.changed and ansible_virtualization_type != 'docker'
|
||||
- name: SERVICE | Restart nginx
|
||||
ansible.builtin.service:
|
||||
name: nginx
|
||||
state: restarted
|
||||
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: COMMAND | Restart nginx
|
||||
ansible.builtin.command: service nginx restart
|
||||
args:
|
||||
warn: false
|
||||
when: fake_site.changed and ansible_virtualization_type == 'docker'
|
||||
|
||||
- name: COMMAND | Get certificates
|
||||
command: |
|
||||
{{ nginx_acmesh_bin }}
|
||||
--home {{ nginx_acmesh_dir }}
|
||||
--issue{% for s in nginx_sites | nginx_search_by_ssl_name(item.name) | nginx_all_site_names %} -d {{ s }}{% endfor %}
|
||||
--nginx
|
||||
{% if nginx_acmesh_test %}--test --log{% endif %}
|
||||
args:
|
||||
creates: "{{ nginx_acmesh_dir }}/{{ item | nginx_site_name }}/fullchain.cer"
|
||||
loop: "{{ acme_create }}"
|
||||
register: acme_get
|
||||
failed_when: acme_get.rc != 0 and acme_get.rc != 2
|
||||
no_log: not nginx_debug_role
|
||||
- name: COMMAND | Get certificates
|
||||
ansible.builtin.command: |
|
||||
{{ nginx_acmesh_bin }}
|
||||
--home {{ nginx_acmesh_dir }}
|
||||
--issue{% for s in nginx_sites | nginx_search_by_ssl_name(item.name) | nginx_all_site_names %} -d {{ s }}{% endfor %}
|
||||
--nginx
|
||||
{% if nginx_acmesh_test %}--test --log{% endif %}
|
||||
args:
|
||||
creates: "{{ nginx_acmesh_dir }}/{{ item | nginx_site_name }}/fullchain.cer"
|
||||
loop: "{{ acme_create }}"
|
||||
register: acme_get
|
||||
failed_when: acme_get.rc != 0 and acme_get.rc != 2
|
||||
no_log: "{{ not nginx_debug_role }}"
|
||||
|
||||
- name: FILE | Create SSL dir per site
|
||||
file:
|
||||
path: "{{ nginx_ssl_dir }}/{{ item | nginx_site_name }}"
|
||||
loop: "{{ acme_create }}"
|
||||
- name: FILE | Create SSL dir per site
|
||||
ansible.builtin.file:
|
||||
path: "{{ nginx_ssl_dir }}/{{ item | nginx_site_name }}"
|
||||
loop: "{{ acme_create }}"
|
||||
|
||||
- name: COMMAND | Install certificates
|
||||
command: |
|
||||
{{ nginx_acmesh_bin }}
|
||||
--home {{ nginx_acmesh_dir }}
|
||||
--install-cert -d {{ nginx_sites | nginx_search_by_ssl_name(item | nginx_site_name) | nginx_site_name }}
|
||||
--fullchain-file {{ item | nginx_cert_path(nginx_ssl_dir) }}
|
||||
--key-file {{ item | nginx_key_path(nginx_ssl_dir) }}
|
||||
--reloadcmd "service nginx reload"
|
||||
args:
|
||||
creates: "{{ item | nginx_cert_path(nginx_ssl_dir) }}"
|
||||
loop: "{{ nginx_ssl_pairs }}"
|
||||
when: item.acme is defined and item.acme
|
||||
notify: restart nginx
|
||||
- name: COMMAND | Install certificates
|
||||
ansible.builtin.command: |
|
||||
{{ nginx_acmesh_bin }}
|
||||
--home {{ nginx_acmesh_dir }}
|
||||
--install-cert -d {{ nginx_sites | nginx_search_by_ssl_name(item | nginx_site_name) | nginx_site_name }}
|
||||
--fullchain-file {{ item | nginx_cert_path(nginx_ssl_dir) }}
|
||||
--key-file {{ item | nginx_key_path(nginx_ssl_dir) }}
|
||||
--reloadcmd "service nginx reload"
|
||||
args:
|
||||
creates: "{{ item | nginx_cert_path(nginx_ssl_dir) }}"
|
||||
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!"
|
||||
- name: FAIL | Explicit
|
||||
ansible.builtin.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
|
||||
loop: "{{ acme_create }}"
|
||||
notify: restart nginx
|
||||
- name: FILE | Delete fake sites
|
||||
ansible.builtin.file:
|
||||
path: "{{ nginx_etc_dir }}/conf.d/FAKESITE_{{ item | nginx_site_name }}.conf"
|
||||
state: absent
|
||||
loop: "{{ acme_create }}"
|
||||
notify: restart nginx
|
||||
|
||||
- name: META | Flush handlers
|
||||
meta: flush_handlers
|
||||
- name: META | Flush handlers
|
||||
ansible.builtin.meta: flush_handlers
|
||||
|
||||
@@ -3,61 +3,71 @@
|
||||
- block:
|
||||
|
||||
- name: STAT | Get info about DH file
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ nginx_dh_path }}"
|
||||
get_checksum: no
|
||||
get_checksum: false
|
||||
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) }'
|
||||
ansible.builtin.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 }}
|
||||
ansible.builtin.command: openssl dhparam -out {{ nginx_dh_path }} {{ nginx_dh_length }}
|
||||
when: not stat_dh_file.stat.exists or (dh_info.stdout | int != nginx_dh_length | int)
|
||||
notify: restart nginx
|
||||
|
||||
when: nginx_dh is not string
|
||||
|
||||
- name: COPY | Deploy DH file from vars
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
content: "{{ nginx_dh }}"
|
||||
dest: "{{ nginx_dh_path }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0640
|
||||
when: nginx_dh is string
|
||||
notify: restart nginx
|
||||
|
||||
- name: FILE | Create SSL directories
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ item | nginx_ssl_dir(nginx_ssl_dir) }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0750
|
||||
loop: "{{ nginx_ssl_pairs }}"
|
||||
when: item.dest_key is not defined or item.dest_cert is not defined
|
||||
no_log: not nginx_debug_role
|
||||
no_log: "{{ not nginx_debug_role }}"
|
||||
|
||||
- name: COPY | Deploy SSL keys
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
content: "{{ item.key }}"
|
||||
dest: "{{ item | nginx_key_path(nginx_ssl_dir) }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0640
|
||||
loop: "{{ nginx_ssl_pairs }}"
|
||||
when: item.key is defined
|
||||
notify: restart nginx
|
||||
no_log: not nginx_debug_role
|
||||
no_log: "{{ not nginx_debug_role }}"
|
||||
|
||||
- name: COPY | Deploy SSL certs
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
content: "{{ item.cert }}"
|
||||
dest: "{{ item | nginx_cert_path(nginx_ssl_dir) }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
loop: "{{ nginx_ssl_pairs }}"
|
||||
when: item.cert is defined
|
||||
notify: restart nginx
|
||||
no_log: not nginx_debug_role
|
||||
no_log: "{{ not nginx_debug_role }}"
|
||||
|
||||
- name: COMMAND | Create self-signed certificates
|
||||
command: |
|
||||
ansible.builtin.command: |
|
||||
openssl req
|
||||
-new -newkey rsa:2048 -sha256 -days 3650 -nodes -x509
|
||||
-subj '/CN={{ item | nginx_site_name }}'
|
||||
@@ -69,4 +79,4 @@
|
||||
loop: "{{ nginx_ssl_pairs }}"
|
||||
when: item.self_signed is defined
|
||||
notify: restart nginx
|
||||
no_log: not nginx_debug_role
|
||||
no_log: "{{ not nginx_debug_role }}"
|
||||
|
||||
@@ -1,21 +1,27 @@
|
||||
---
|
||||
|
||||
- name: TEMPLATE | Deploy PHP upstream to Nginx
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "etc/nginx/conf.d/php.conf.j2"
|
||||
dest: "{{ nginx_etc_dir }}/conf.d/php.conf"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
notify: reload nginx
|
||||
|
||||
- name: TEMPLATE | Deploy other upstreams
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "etc/nginx/conf.d/_upstream.conf.j2"
|
||||
dest: "{{ nginx_etc_dir }}/conf.d/upstream-{{ item.name }}.conf"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
loop: "{{ nginx_upstreams }}"
|
||||
when: item.state is not defined or item.state == 'present'
|
||||
notify: reload nginx
|
||||
|
||||
- name: FILE | Delete other upstreams
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ nginx_etc_dir }}/conf.d/upstream-{{ item.name }}.conf"
|
||||
state: absent
|
||||
loop: "{{ nginx_upstreams }}"
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
{% extends "_base.j2" %}
|
||||
|
||||
{% block root %}
|
||||
root /usr/share/backuppc/cgi-bin;
|
||||
{% endblock %}
|
||||
|
||||
{% block template_try_files %}
|
||||
{% endblock %}
|
||||
|
||||
{% block template_index %}
|
||||
index index.cgi;
|
||||
{% endblock %}
|
||||
|
||||
{% block template_local_content %}
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
|
||||
location /backuppc/image {
|
||||
alias /usr/share/backuppc/image;
|
||||
expires 60d;
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block template_upstream_location %}
|
||||
location ~ \.cgi$ {
|
||||
gzip off;
|
||||
include fastcgi.conf;
|
||||
fastcgi_pass unix:/var/run/fcgiwrap.socket;
|
||||
fastcgi_index BackupPC_Admin;
|
||||
fastcgi_param SCRIPT_FILENAME /usr/share/backuppc/cgi-bin$fastcgi_script_name;
|
||||
}
|
||||
{% endblock %}
|
||||
@@ -1,19 +1 @@
|
||||
---
|
||||
|
||||
- name: APT | Install webapps and related tools
|
||||
apt:
|
||||
pkg: "{{ packages }}"
|
||||
state: present
|
||||
install_recommends: no
|
||||
vars:
|
||||
packages:
|
||||
- backuppc
|
||||
- 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
|
||||
|
||||
@@ -1,23 +1 @@
|
||||
---
|
||||
|
||||
#- name: APT | Install web apps
|
||||
# pkgng:
|
||||
# name: "backuppc"
|
||||
# state: present
|
||||
#
|
||||
#- name: COMMAND | Activate backuppc config
|
||||
# command: >
|
||||
# cp /usr/local/etc/backuppc/config.pl.sample /usr/local/etc/backuppc/config.pl
|
||||
# creates=/usr/local/etc/backuppc/config.pl
|
||||
#
|
||||
#- name: FILE | Fix backuppc permissions
|
||||
# file:
|
||||
# path: /usr/local/etc/backuppc/config.pl
|
||||
# owner: backuppc
|
||||
# group: backuppc
|
||||
#
|
||||
#
|
||||
# We don't manage BackupPC on FreeBSD... too dirty. :/
|
||||
#
|
||||
#- name: SERVICE | Ensure backuppc is started
|
||||
# service: name=backuppc state=started enabled=yes
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
- name: APT | Install needed packages
|
||||
apt:
|
||||
pkg: "{{ packages }}"
|
||||
update_cache: yes
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
state: present
|
||||
vars:
|
||||
@@ -17,7 +17,6 @@
|
||||
- cron
|
||||
- curl
|
||||
- daemonize
|
||||
- fcgiwrap
|
||||
- jq
|
||||
- nghttp2
|
||||
- strace
|
||||
@@ -27,7 +26,7 @@
|
||||
- name: APT | Install PHP
|
||||
apt:
|
||||
pkg: "{{ pkgs }}"
|
||||
update_cache: yes
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
state: present
|
||||
vars:
|
||||
@@ -40,11 +39,6 @@
|
||||
changed_when: false
|
||||
register: cur_php_version
|
||||
|
||||
- name: SERVICE | Force start fcgiwrap
|
||||
service:
|
||||
name: "fcgiwrap"
|
||||
state: started
|
||||
|
||||
# Bypasses Ansible+Docker issue. With service module... php is not really started!
|
||||
- name: COMMAND | Force start PHP
|
||||
command: "service php{{ cur_php_version.stdout }}-fpm start"
|
||||
@@ -61,7 +55,7 @@
|
||||
unarchive:
|
||||
src: "/tmp/ngrok.zip"
|
||||
dest: "/tmp"
|
||||
remote_src: yes
|
||||
remote_src: true
|
||||
|
||||
- name: SET_FACT | ngrok_path
|
||||
set_fact:
|
||||
@@ -70,7 +64,7 @@
|
||||
- name: USER | Create PHP User foo
|
||||
user:
|
||||
name: foo
|
||||
system: yes
|
||||
system: true
|
||||
|
||||
- name: INCLUDE_ROLE | HanXHX.php
|
||||
include_role:
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
sockets:
|
||||
- host: '127.0.0.1'
|
||||
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
|
||||
@@ -27,29 +25,23 @@
|
||||
state: present
|
||||
vars:
|
||||
packages:
|
||||
- bash
|
||||
- curl
|
||||
- daemonize
|
||||
- fcgiwrap
|
||||
# - GeoIP
|
||||
- jq
|
||||
- nghttp2
|
||||
- php74
|
||||
- vim
|
||||
|
||||
#- name: COMMAND | Get geoip database
|
||||
# command: geoipupdate.sh
|
||||
# args:
|
||||
# creates: /usr/local/share/GeoIP/GeoIP.dat
|
||||
|
||||
- name: SERVICE | Force start services
|
||||
service:
|
||||
name: "{{ item }}"
|
||||
state: started
|
||||
enabled: yes
|
||||
enabled: true
|
||||
register: sf
|
||||
loop:
|
||||
- php-fpm
|
||||
- fcgiwrap
|
||||
|
||||
- name: STAT | Check ports
|
||||
stat:
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
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'
|
||||
shell: set -o pipefail && curl 'http://127.0.0.1:4040/api/tunnels/command_line' 2> /dev/null | jq -r '.public_url' | cut -d '/' -f 3
|
||||
args:
|
||||
executable: /bin/bash
|
||||
warn: false
|
||||
register: ngrok
|
||||
changed_when: false
|
||||
@@ -23,7 +24,7 @@
|
||||
lineinfile:
|
||||
line: "set mouse="
|
||||
dest: "{{ item }}/.vimrc"
|
||||
create: yes
|
||||
create: true
|
||||
loop:
|
||||
- /root
|
||||
- /home/vagrant
|
||||
|
||||
16
tests/templates/custom_template.conf.j2
Normal file
16
tests/templates/custom_template.conf.j2
Normal file
@@ -0,0 +1,16 @@
|
||||
# {{ ansible_managed }} - custom template
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen 8888 http2;
|
||||
listen 9999 http2 proxy_protocol;
|
||||
server_name {{ item.name }};
|
||||
|
||||
index index.html index.htm;
|
||||
|
||||
root {{ item.root }};
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
}
|
||||
260
tests/test.yml
260
tests/test.yml
@@ -4,28 +4,37 @@
|
||||
pre_tasks:
|
||||
|
||||
- name: INCLUDE_TASKS | Pre_tasks related to OS version
|
||||
include_tasks: "includes/pre_{{ ansible_distribution }}.yml"
|
||||
ansible.builtin.include_tasks: "includes/pre_{{ ansible_distribution }}.yml"
|
||||
|
||||
- name: IMPORT_TASKS | Pre_tasks common
|
||||
import_tasks: "includes/pre_common.yml"
|
||||
ansible.builtin.import_tasks: "includes/pre_common.yml"
|
||||
|
||||
- name: FILE | Create an internal SSL dir
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ int_ansible_ssl_dir }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: COPY | Deploy test certificate
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
src: "file/test.crt"
|
||||
dest: "{{ int_ansible_ssl_dir }}/test.crt"
|
||||
mode: 0640
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: COPY | Deploy test key
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
src: "file/test.key"
|
||||
dest: "{{ int_ansible_ssl_dir }}/test.key"
|
||||
mode: 0640
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: COPY | Add all hosts in /etc/hosts
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
content: |
|
||||
127.0.0.1 localhost
|
||||
{% for s in nginx_sites %}
|
||||
@@ -39,13 +48,16 @@
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
dest: "/etc/hosts"
|
||||
unsafe_writes: yes
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
unsafe_writes: true
|
||||
|
||||
vars:
|
||||
# Internal vars
|
||||
# Internal vars
|
||||
int_ansible_ssl_dir: '/etc/ansible-ssl'
|
||||
# Role vars
|
||||
nginx_worker_processes: 1 # Ansible+FreeBSD can't detect CPU number
|
||||
# Role vars
|
||||
nginx_worker_processes: 1 # Ansible+FreeBSD can't detect CPU number
|
||||
nginx_apt_package: 'nginx-extras'
|
||||
nginx_module_packages: ['libnginx-mod-http-headers-more-filter']
|
||||
nginx_upstreams:
|
||||
@@ -85,7 +97,7 @@
|
||||
force: false
|
||||
- name:
|
||||
- 'test-ssl-predeployed.local'
|
||||
- 'test-multiple-name.local' # Hack: tests for acme with multiple name, without using acme
|
||||
- 'test-multiple-name.local' # Hack: tests for acme with multiple name, without using acme
|
||||
dest_key: "{{ int_ansible_ssl_dir }}/test.key"
|
||||
dest_cert: "{{ int_ansible_ssl_dir }}/test.crt"
|
||||
- name: 'test-ssl.local'
|
||||
@@ -154,7 +166,7 @@
|
||||
- 'test-alias.local'
|
||||
- 'test2-alias.local'
|
||||
template: '_base'
|
||||
filename : 'first-test'
|
||||
filename: 'first-test'
|
||||
override_try_files: '$uri/ $uri =404'
|
||||
headers:
|
||||
'X-Frame-Options': 'deny always'
|
||||
@@ -229,9 +241,6 @@
|
||||
state: 'absent'
|
||||
- name: 'redirect-to.local'
|
||||
redirect_to: 'http://test.local'
|
||||
- name: 'backuppc.local'
|
||||
template: '_backuppc'
|
||||
htpasswd: 'hello'
|
||||
- name: 'test-ssl.local'
|
||||
proto: ['http', 'https']
|
||||
template: '_base'
|
||||
@@ -280,34 +289,51 @@
|
||||
ssl_name: '{{ ngrok.stdout }}'
|
||||
headers:
|
||||
'X-acme': '1'
|
||||
- name: 'test-custom-template.local'
|
||||
custom_template: 'templates/custom_template.conf.j2'
|
||||
root: '/tmp/custom-template'
|
||||
|
||||
nginx_php: "{{ [{'upstream_name': 'manual', 'sockets': [{'host': '127.0.0.1', 'port': '9636' }] }] }}"
|
||||
nginx_dh_length: 1024
|
||||
roles:
|
||||
- ../../
|
||||
post_tasks:
|
||||
# --------------------------------
|
||||
# Apps
|
||||
# --------------------------------
|
||||
# --------------------------------
|
||||
# Apps
|
||||
# --------------------------------
|
||||
- name: INCLUDE_TASKS | Post_tasks related to OS version
|
||||
include_tasks: "includes/post_{{ ansible_distribution }}.yml"
|
||||
ansible.builtin.include_tasks: "includes/post_{{ ansible_distribution }}.yml"
|
||||
|
||||
# --------------------------------
|
||||
# Deploy index files
|
||||
# --------------------------------
|
||||
# --------------------------------
|
||||
# Deploy index files
|
||||
# --------------------------------
|
||||
- name: -- Add PHP file --
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ nginx_root }}/{{ item }}/public/index.php"
|
||||
content: "<?php phpinfo();"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
loop:
|
||||
- 'test-php.local'
|
||||
- 'test-php-index.local'
|
||||
- 'test-php-index2.local'
|
||||
|
||||
- name: -- Add Directories --
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
loop:
|
||||
- "{{ nginx_root }}/test-htpasswd.local/public/hello"
|
||||
- "/tmp/custom-template"
|
||||
|
||||
- name: -- Add HTML file --
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ item }}/index.html"
|
||||
content: "Index HTML test OK\n"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
loop:
|
||||
- '{{ nginx_root }}/first-test/public'
|
||||
- '/var/tmp'
|
||||
@@ -319,26 +345,33 @@
|
||||
- '{{ nginx_root }}/{{ ngrok.stdout }}/public'
|
||||
|
||||
- name: -- Create directory --
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: "{{ nginx_root }}/test-htpasswd.local/public/hello"
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: -- Add HTML file hello --
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ nginx_root }}/test-htpasswd.local/public/hello/index.html"
|
||||
content: "hello\n"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
# --------------------------------
|
||||
# Test custom facts
|
||||
# --------------------------------
|
||||
# --------------------------------
|
||||
# Test custom facts
|
||||
# --------------------------------
|
||||
- name: -- CHECK FACTS --
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that: "'{{ ansible_local.nginx.fact_nginx_sites[0].name[0] }}' == 'test.local'"
|
||||
# --------------------------------
|
||||
# Simple sites tests
|
||||
# --------------------------------
|
||||
|
||||
# --------------------------------
|
||||
# Simple sites tests
|
||||
# --------------------------------
|
||||
- name: -- VERIFY SITES --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
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
|
||||
@@ -347,12 +380,12 @@
|
||||
changed_when: false
|
||||
|
||||
- name: -- VERIFY FORBIDDEN --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "http://test-php-index.local/phpinfo.php"
|
||||
status_code: 403
|
||||
|
||||
- name: -- VERIFY REDIRECT SITES --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "http://{{ item.redirect_from[0] }}/"
|
||||
status_code: 301
|
||||
follow_redirects: none
|
||||
@@ -361,22 +394,22 @@
|
||||
changed_when: false
|
||||
|
||||
- name: -- VERIFY REDIRECT HTTPS SITES --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "https://{{ item.redirect_from[0] }}:{{ item.listen_ssl[0] | default(443) }}/"
|
||||
status_code: 301
|
||||
follow_redirects: none
|
||||
validate_certs: no
|
||||
validate_certs: false
|
||||
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
|
||||
|
||||
# --------------------------------
|
||||
# PHP
|
||||
# --------------------------------
|
||||
# --------------------------------
|
||||
# PHP
|
||||
# --------------------------------
|
||||
- name: -- VERIFY PHP SITES --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "http://{{ item.name }}/"
|
||||
return_content: yes
|
||||
return_content: true
|
||||
register: p
|
||||
loop: "{{ nginx_sites }}"
|
||||
when: >
|
||||
@@ -385,72 +418,58 @@
|
||||
failed_when: p.content.find('PHP Version') == -1
|
||||
|
||||
- name: -- VERIFY INDEX2 --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "http://test-php-index2.local/lorem.php?ipsum=sit&dolor=amet"
|
||||
return_content: yes
|
||||
return_content: true
|
||||
register: p2
|
||||
failed_when: p2.content.find('PHP Version') == -1
|
||||
|
||||
# --------------------------------
|
||||
# Basic Auth
|
||||
# --------------------------------
|
||||
# --------------------------------
|
||||
# Basic Auth
|
||||
# --------------------------------
|
||||
- name: -- VERIFY AUTH BASIC NONE --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "http://test-htpasswd.local/hello/"
|
||||
status_code: 401
|
||||
|
||||
- name: -- VERIFY AUTH BASIC FAIL --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "http://test-htpasswd.local/hello/"
|
||||
status_code: 401
|
||||
user: "fail"
|
||||
password: "fail"
|
||||
force_basic_auth: yes
|
||||
force_basic_auth: true
|
||||
|
||||
- name: -- VERIFY AUTH BASIC OK --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "http://test-htpasswd.local/hello/"
|
||||
user: "hanx"
|
||||
password: "qwerty"
|
||||
force_basic_auth: yes
|
||||
force_basic_auth: true
|
||||
|
||||
- name: -- VERIFY AUTH BASIC FAIL GLOBAL --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "http://test-htpasswd-all.local/"
|
||||
status_code: 401
|
||||
user: "fail"
|
||||
password: "fail"
|
||||
force_basic_auth: yes
|
||||
force_basic_auth: true
|
||||
|
||||
- name: -- VERIFY AUTH BASIC OK GLOBAL --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "http://test-htpasswd-all.local/"
|
||||
user: "hanx"
|
||||
password: "qwerty"
|
||||
force_basic_auth: yes
|
||||
force_basic_auth: true
|
||||
|
||||
# --------------------------------
|
||||
# BackupPC
|
||||
# --------------------------------
|
||||
- name: -- VERIFY BACKUPPC --
|
||||
uri:
|
||||
url: "http://backuppc.local/"
|
||||
user: "hanx"
|
||||
password: "qwerty"
|
||||
force_basic_auth: yes
|
||||
return_content: yes
|
||||
register: authbpc
|
||||
when: ansible_distribution != 'FreeBSD'
|
||||
failed_when: authbpc.content.find('BackupPC Server Status') == -1
|
||||
|
||||
# --------------------------------
|
||||
# SSL
|
||||
# --------------------------------
|
||||
# --------------------------------
|
||||
# SSL
|
||||
# --------------------------------
|
||||
- name: -- VERIFY SSL --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "https://{{ item }}/"
|
||||
return_content: yes
|
||||
validate_certs: no
|
||||
return_content: true
|
||||
validate_certs: false
|
||||
register: sslok
|
||||
failed_when: sslok.content.find('Index HTML test OK') == -1
|
||||
loop:
|
||||
@@ -460,11 +479,11 @@
|
||||
- '{{ ngrok.stdout }}'
|
||||
|
||||
- name: -- VERIFY SSL REDIRECT --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: "http://{{ item.name }}/"
|
||||
validate_certs: no
|
||||
validate_certs: false
|
||||
status_code: 301
|
||||
return_content: yes
|
||||
return_content: true
|
||||
follow_redirects: none
|
||||
register: sslredirok
|
||||
failed_when: '"https://%s%s" % (item.name, ":" + item.port if item.port is defined else "") not in sslredirok.location'
|
||||
@@ -475,89 +494,80 @@
|
||||
- name: 'test-ssl-redirect-many2.local'
|
||||
port: '8443'
|
||||
|
||||
# --------------------------------
|
||||
# Default sites
|
||||
# --------------------------------
|
||||
# --------------------------------
|
||||
# Default sites
|
||||
# --------------------------------
|
||||
- name: -- VERIFY DEFAULT SITE --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: 'http://127.0.0.1/'
|
||||
return_content: yes
|
||||
return_content: true
|
||||
register: vdefault
|
||||
failed_when: >
|
||||
vdefault.content.find('Index HTML test OK') == -1 or
|
||||
vdefault.x_ansible_default is not defined
|
||||
|
||||
- name: -- VERIFY DEFAULT SITE + STUB STATUS--
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: 'http://127.0.0.1/status'
|
||||
return_content: yes
|
||||
return_content: true
|
||||
register: vdefault_status
|
||||
failed_when: >
|
||||
vdefault_status.content.find('Active connections') == -1 or
|
||||
vdefault_status.x_ansible_default is not defined
|
||||
|
||||
- name: -- VERIFY DEFAULT SSL SITE --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: 'https://127.0.0.1/'
|
||||
return_content: yes
|
||||
validate_certs: no
|
||||
return_content: true
|
||||
validate_certs: false
|
||||
register: vdefault
|
||||
failed_when: >
|
||||
vdefault.content.find('Index HTML test OK') == -1 or
|
||||
vdefault.x_ansible_default is not defined
|
||||
|
||||
- name: -- VERIFY NOT DEFAULT SITE --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: 'http://test-php.local/'
|
||||
return_content: yes
|
||||
return_content: true
|
||||
register: vphp
|
||||
failed_when: vphp.x_ansible_default is defined
|
||||
|
||||
- name: -- VERIFY NOT DEFAULT SSL SITE --
|
||||
uri:
|
||||
ansible.builtin.uri:
|
||||
url: 'https://test-ssl.local/'
|
||||
return_content: yes
|
||||
validate_certs: no
|
||||
return_content: true
|
||||
validate_certs: false
|
||||
register: notdefaultssl
|
||||
failed_when: notdefaultssl.x_ansible_default is defined
|
||||
|
||||
|
||||
# --------------------------------
|
||||
# Check Proxy protocol
|
||||
# --------------------------------
|
||||
|
||||
# Note: Debian Stretch doesn't any version of curl with "--haproxy-protocol" argument
|
||||
|
||||
# --------------------------------
|
||||
# Check Proxy protocol
|
||||
# Note: Debian Stretch doesn't any version of curl with "--haproxy-protocol" argument
|
||||
# --------------------------------
|
||||
- block:
|
||||
|
||||
- name: SHELL | Check HTTP proxy protocol
|
||||
shell: curl -I --haproxy-protocol http://test-ssl-proxy-protocol.local:20080 | grep -qi 'X-Proxy-Protocol'
|
||||
args:
|
||||
executable: /bin/sh
|
||||
warn: no
|
||||
changed_when: false
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
- name: SHELL | Check HTTP proxy protocol
|
||||
ansible.builtin.shell: set -o pipefail && curl -I --haproxy-protocol http://test-ssl-proxy-protocol.local:20080 | grep -qi 'X-Proxy-Protocol'
|
||||
args:
|
||||
executable: /bin/bash
|
||||
warn: false
|
||||
changed_when: false
|
||||
|
||||
- name: SHELL | Check HTTPS proxy protocol
|
||||
shell: curl -I --haproxy-protocol -k https://test-ssl-proxy-protocol.local:20443 | grep -qi 'X-Proxy-Protocol'
|
||||
args:
|
||||
executable: /bin/sh
|
||||
warn: no
|
||||
changed_when: false
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
- name: SHELL | Check HTTPS proxy protocol
|
||||
ansible.builtin.shell: set -o pipefail && curl -I --haproxy-protocol -k https://test-ssl-proxy-protocol.local:20443 | grep -qi 'X-Proxy-Protocol'
|
||||
args:
|
||||
executable: /bin/bash
|
||||
warn: false
|
||||
changed_when: false
|
||||
|
||||
when: not (ansible_distribution == 'Debian' and ansible_distribution_major_version is version('9', 'eq'))
|
||||
|
||||
# --------------------------------
|
||||
# Check HTTP2
|
||||
# --------------------------------
|
||||
# --------------------------------
|
||||
# Check HTTP2
|
||||
# --------------------------------
|
||||
- name: SHELL | Check HTTP2
|
||||
shell: nghttp -nv https://localhost 2> /dev/null | grep -q h2
|
||||
ansible.builtin.shell: set -o pipefail && nghttp -nv https://localhost 2> /dev/null | grep -q h2
|
||||
args:
|
||||
executable: /bin/sh
|
||||
executable: /bin/bash
|
||||
changed_when: false
|
||||
when: nginx_auto_config_httpv2 and 'http_v2' in nginx_modules
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
---
|
||||
|
||||
nginx_events_use: 'epoll'
|
||||
nginx_pid: '/run/nginx.pid'
|
||||
nginx_etc_dir: '/etc/nginx'
|
||||
|
||||
# Specific sites
|
||||
nginx_fcgiwrap_sock: '/var/run/fcgiwrap.socket'
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
---
|
||||
|
||||
nginx_events_use: 'kqueue'
|
||||
nginx_pid: '/var/run/nginx.pid'
|
||||
nginx_etc_dir: '/usr/local/etc/nginx'
|
||||
|
||||
# Specific sites
|
||||
nginx_fcgiwrap_sock: '/var/run/fcgiwrap/fcgiwrap.sock'
|
||||
|
||||
nginx_acmesh_bin: '/usr/local/sbin/acme.sh'
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
---
|
||||
|
||||
nginx_upstream_server_params:
|
||||
- key: 'weight'
|
||||
default: 1
|
||||
@@ -40,7 +42,6 @@ nginx_dirs:
|
||||
owner: "root"
|
||||
|
||||
nginx_templates_no_dir:
|
||||
- '_backuppc'
|
||||
- '_proxy'
|
||||
|
||||
nginx_servers_default_headers:
|
||||
|
||||
Reference in New Issue
Block a user