ginsys.nginx

nginx

This role is based on bennojoy/nginx but uses a different way to set parameters.

This role installs and sets up the nginx web server. Users can choose any HTTP settings they want for their site, and can add multiple sites with their own configurations.

Requirements

You need Ansible version 1.4 or higher, and the required platforms are listed in the metadata file.

Role Variables

Here are the variables you can use with this role, along with brief explanations:

# Maximum number of clients allowed
nginx_max_clients: 512

# A collection of HTTP parameters. You can add any
# valid nginx HTTP parameters here. 
# (Check the nginx documentation for more details.)
nginx_http_params:
  sendfile: "on"
  tcp_nopush: "on"
  tcp_nodelay: "on"
  keepalive_timeout: "65"
  access_log: "/var/log/nginx/access.log"
  error_log: "/var/log/nginx/error.log"

# A list of configurations for nginx servers,
# where you can define any valid server parameters.
nginx_sites:
 - server:
      file_name: foo
      listen: 8080
      server_name: localhost
      root: "/tmp/site1"
   location:
    - name: /
      try_files: "$uri $uri/ /index.html"
    - name: /images/
      try_files: "$uri $uri/ /index.html"
 - server:
      file_name: bar
      listen: 9090
      server_name: ansible
      root: "/tmp/site2"
   location:
    - name: /
      try_files: "$uri $uri/ /index.html"
    - name: /images/
      try_files: "$uri $uri/ /index.html"

Examples

  1. Install nginx with your chosen HTTP settings, but without any configured sites:

    • hosts: all roles:
      • {role: nginx, nginx_http_params: { sendfile: "on", access_log: "/var/log/nginx/access.log"}, nginx_sites: none }
  2. Install nginx with a different set of HTTP settings, still without configured sites:

    • hosts: all roles:
      • {role: nginx, nginx_http_params: { tcp_nodelay: "on", error_log: "/var/log/nginx/error.log"}, nginx_sites: none }

Note: Ensure that the HTTP settings you provide are valid, as this role won't verify them. Refer to the nginx documentation for more information.

  1. Install nginx and add a site to the configuration:

    • hosts: all

      roles:

      • role: nginx, nginx_http_params: sendfile: "on" access_log: "/var/log/nginx/access.log" nginx_sites:
        • server: file_name: bar listen: 8080 location:
          • name: "/" try_files: "$uri $uri/ /index.html"
          • name: /images/ try_files: "$uri $uri/ /index.html"

Note: Each site is represented as a list of configurations. The generated configurations are stored in /etc/nginx/sites-available/ with symlinks from /etc/nginx/sites-enabled/.

The specific site configuration file name is set in the hash with the key "file_name". You can add any valid server settings to this hash. For location settings, use the key "location" followed by a unique number, where the value is another hash for location directives to ensure they are valid.

  1. Install nginx and add two sites (using a different method):


    • hosts: all roles:
      • role: nginx nginx_http_params: sendfile: "on" access_log: "/var/log/nginx/access.log" nginx_sites:
        • server: file_name: foo listen: 8080 server_name: localhost root: "/tmp/site1" location:
          • name: / try_files: "$uri $uri/ /index.html"
          • name: /images/ try_files: "$uri $uri/ /index.html"
        • server: file_name: bar listen: 9090 server_name: ansible root: "/tmp/site2" location:
          • name: / try_files: "$uri $uri/ /index.html"
          • name: /images/ try_files: "$uri $uri/ /index.html"

Dependencies

None

License

BSD

Author Information

Original role author: Benno Joy
Ginsys fork author: Serge van Ginderachter serge@vanginderachter.be

Informazioni sul progetto

This ansible role manages installation and configuration of nginx. It can both configure general options, as well as virtual hosts. This role is a fork of https://github.com/bennojoy/nginx and implements a different API for configuring locations within a

Installa
ansible-galaxy install ginsys.nginx
Licenza
Unknown
Download
114
Proprietario
automate all things!