Shir0kamii.ansible_role_nginx

Ansible Role: Nginx

Build Status

Note: It's recommended to use the official NGINX Ansible role from NGINX, Inc.

This role helps install Nginx on various server types including RedHat/CentOS, Debian/Ubuntu, Archlinux, FreeBSD, and OpenBSD.

It installs and configures the latest Nginx version from the appropriate package manager for your OS (like yum for RedHat, apt for Debian, etc.). You might need to do some additional configuration by adding your own .conf file in /etc/nginx/conf.d/ to set up your website.

Requirements

None.

Role Variables

Here are the available variables you can use and their default values (see defaults/main.yml):

nginx_vhosts

A list for defining virtual hosts in Nginx. Each entry creates a separate configuration file named after server_name. If you don’t provide any, you need to create your own configuration file. Refer to the commented example in defaults/main.yml for available options.

Example vhost setup:

nginx_vhosts:
  - listen: "443 ssl http2"
    server_name: "example.com"
    root: "/var/www/example.com"
    index: "index.php index.html"
    state: "present"
    filename: "example.com.conf"
    extra_parameters: |
      location ~ \.php$ {
          fastcgi_pass unix:/var/run/php5-fpm.sock;
          ...
      }

nginx_remove_default_vhost

Set to false if you want to keep the default virtual host configuration provided by Nginx.

nginx_user

The user that Nginx will run under. Defaults to nginx for RedHat, www-data for Debian, and www for FreeBSD/OpenBSD.

nginx_worker_processes

This should match the number of CPU cores on your server. You can find this by running grep processor /proc/cpuinfo | wc -l.

nginx_error_log and nginx_access_log

Settings for the default error and access logs. Set them to off to disable logging.

nginx_client_max_body_size

This determines the maximum file size that can be uploaded. If set too low, you might see errors about sending too large a body.

nginx_proxy_cache_path

If you want to use Nginx as a reverse proxy, set this variable to configure a cache path.

nginx_extra_http_options

Use this to add extra lines to the main http block in the nginx.conf.

nginx_log_format

This configures how logs are formatted in Nginx.

nginx_default_release and nginx_ppa_use

These options allow you to choose specific repositories for installing Nginx on Debian/Ubuntu.

Overriding Templates

If you need more control over config files, you can override the default templates:

nginx_conf_template: "nginx.conf.j2"
nginx_vhost_template: "vhost.j2"

Example Playbook

Here's a simple playbook example that uses this role:

- hosts: server
  roles:
    - { role: geerlingguy.nginx }

License

MIT / BSD

Author Information

This role was created in 2014 by Jeff Geerling, author of Ansible for DevOps.

Informazioni sul progetto

Nginx installation for Linux, FreeBSD and OpenBSD.

Installa
ansible-galaxy install Shir0kamii.ansible_role_nginx
Licenza
mit
Download
76
Proprietario