Role name in Ansible Galaxy: williamyeh.nginx
This Ansible role has the following features for Nginx:
- Install specific version.
- Handlers for restart/reload/stop events;
- Bare bone configuration (real configuration should be left to user's template files; see Usage section below).
None.
User-installable configuration files (by Ansible's template system):
# main conf template to be installed to "/etc/nginx/nginx.conf";
# relative to `playbook_dir`
nginx_conf_main
# other conf templates to be installed to "/etc/nginx/conf.d";
# dict fields:
# - key: memo for this conf
# - value:
# - src: template file relative to `playbook_dir`
# - dest: target file relative to `/etc/nginx/conf.d/`
nginx_conf_others
User-configurable defaults:
# Nginx version; e.g., "1.8.1"
# Will install the default (usually the latest stable) version, if not specified.
nginx_version
# start the service at the end of the role?
# default: True
nginx_start
# uid of worker process;
# default: "nginx".
nginx_user
# for worker_rlimit_nofile in nginx.conf
nginx_ulimit: 51200
# for worker_connections in nginx.conf
nginx_worker_connections: 1024
# install health-check endpoint "http://HOST:PORT/nginx_status"?
nginx_status: False
# use `service` command to start/restart nginx daemon?
nginx_use_service: True
-
restart nginx
-
reload nginx
-
stop nginx
Add role name williamyeh.nginx
to your playbook file.
Set vars in your playbook file.
Simple example:
---
# file: simple-playbook.yml
- hosts: all
roles:
- williamyeh.nginx
vars:
nginx_version: 1.8.1
More practical example:
---
# file: complex-playbook.yml
- hosts: all
roles:
- williamyeh.nginx
vars:
nginx_version: 1.8.1
nginx_conf_main: "templates/nginx.conf.j2"
nginx_conf_others:
conf_template_for_app_1:
src: "templates/app-1.conf.j2"
dest: app-1.conf
conf_template_for_app_2:
src: "templates/app-2.conf.j2"
dest: app-2.conf
None.
MIT License. See the LICENSE file for details.
Rewritten from my pre-Galaxy version: server-config-template.
During refactoring, some roles on Ansible Galaxy also inspired me: