Install anc configure Nginx package.
This role requires Ansible 2.4 or higher, and platform requirements are listed in the metadata file.
This role use Molecule to run tests.
Local and Travis tests run tests on Docker by default. See molecule documentation to use other backend.
Currently, tests are done on:
- Debian Stretch
- Ubuntu Trusty
- Ubuntu Xenial
- Ubuntu Bionic
and use:
- Ansible 2.4.x
- Ansible 2.5.x
- Ansible 2.6.x
- Ansible 2.7.x
$ tox
# General
#------------------------------------------------------------------------------
# Packages and repositories management
nginx_packages: "{{ _nginx_packages }}"
nginx_repository_cache_valid_time: "{{ _nginx_repository_cache_valid_time }}"
nginx_repositories_keys: "{{ _nginx_repositories_keys }}"
nginx_repositories: "{{ _nginx_repositories }}"
# Services management
nginx_service_name: "{{ _nginx_service_name }}"
nginx_service_state: 'started'
nginx_service_enabled: True
# Nginx configuration properties
nginx_config_permissions:
files:
owner: 'root'
group: 'root'
mode: '0644'
folders:
owner: 'root'
group: 'root'
mode: '0750'
nginx_config_paths:
files:
main: '/etc/nginx/nginx.conf'
default:
- '/etc/nginx/conf.d/default.conf'
- '/etc/nginx/conf.d/example_ssl.conf'
folders:
sites_available: '/etc/nginx/sites-available'
sites_enabled: '/etc/nginx/sites-enabled'
# Servers configuration management
#------------------------------------------------------------------------------
# Remove default servers configuration files
nginx_delete_default_config_files: True
# General
nginx_user: 'nginx'
# Nginx main configuration
nginx_conf:
root:
options: |
user {{ nginx_user }};
worker_processes 1;
error_log /var/log/nginx/error.log info;
pid /run/nginx.pid;
events:
options: |
worker_connections 1024;
http:
default_server:
enabled: True
content: |
return 404;
options: |
log_format main '$remote_addr - $remote_user [$time_local] "$request"
$status $body_bytes_sent "$http_referer" "$http_user_agent"
"$http_x_forwarded_for"';
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
nginx_servers: []
nginx_upstreams: []
nginx_log_path: '/var/log/nginx'
default_nginx_logrotate_config_modify: True
nginx_logrotate_config:
- dest: '/etc/logrotate.d/nginx'
nginx_logrotate_rotate: '54'
Today, management of configuration options is smaller and incomplete, but will grow later.
Example:
nginx_servers:
- name: "{{ ansible_fqdn }}"
is_enabled: False
options: |
listen: 80;
root /var/www/foo;
server_name localhost;
locations:
- target: '/foo'
options: |
try_files $uri =404;
root /var/www/foo;
- target: '/bar'
options: |
try_files $uri =404;
root /var/www/bar;
Today, management of configuration options is smaller and incomplete, but will grow later.
Example:
nginx_upstreams:
- name: 'foo'
is_enabled: False
options: |
server 127.0.0.1:8080;
Example:
nginx_maps:
- name: 'foo'
is_enabled: False
target: '$uri $new_uri'
options: |
/foo /bar;
None
- hosts: servers
roles:
- { role: Temelio.nginx }
MIT
A Chaussier, L Machetel (for Temelio company)