ginsys.nginx
nginx
Ten rol jest fork od https://github.com/bennojoy/nginx. Implementuje inną "API" do definiowania parametrów.
Ten rol instaluję i konfiguruje serwer webowy nginx. Użytkownik może określić wszelkie parametry konfiguracyjne HTTP, które chciałby zastosować na swojej stronie. Można dodać dowolną liczbę stron z dowolnymi konfiguracjami.
Wymagania
Ten rol wymaga Ansible w wersji 1.4 lub wyższej, a wymagania dotyczące platformy są wymienione w pliku metadanych.
Zmienne Roli
Zmienne, które mogą być przekazane do tej roli oraz ich krótki opis:
# Maksymalna liczba klientów
nginx_max_clients: 512
# Zbiór parametrów http. Zauważ, że wszelkie
# poprawne parametry http dla nginx mogą być dodane tutaj.
# (zobacz dokumentację nginx w celu uzyskania szczegółów.)
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"
# Lista zbiorów definiujących serwery dla nginx,
# analogicznie do parametrów http. Jakiekolwiek poprawne parametry serwera
# można tutaj zdefiniować.
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"
Przykłady
Zainstaluj nginx z wybranymi dyrektywami HTTP, ale bez skonfigurowanych stron:
- hosts: all
roles:
- {role: nginx, nginx_http_params: { sendfile: "on", access_log: "/var/log/nginx/access.log"}, nginx_sites: none }
- hosts: all
roles:
Zainstaluj nginx z innymi dyrektywami HTTP niż w poprzednim przykładzie, ale bez skonfigurowanych stron.
- hosts: all
roles:
- {role: nginx, nginx_http_params: { tcp_nodelay: "on", error_log: "/var/log/nginx/error.log"}, nginx_sites: none }
- hosts: all
roles:
Uwaga: Proszę upewnić się, że przekazane dyrektywy HTTP są poprawne, ponieważ ten rol nie sprawdzi ich poprawności. Zobacz dokumentację nginx w celu uzyskania szczegółów.
Zainstaluj nginx i dodaj stronę do konfiguracji.
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"
- server:
file_name: bar
listen: 8080
location:
- role: nginx,
nginx_http_params:
sendfile: "on"
access_log: "/var/log/nginx/access.log"
nginx_sites:
Uwaga: Każda dodana strona jest reprezentowana przez listę zbiorów, a wygenerowane
konfiguracje są umieszczane w /etc/nginx/sites-available/
i mają odpowiadające
linki symboliczne w /etc/nginx/sites-enabled/
.
Nazwa pliku konkretnej konfiguracji strony jest określona w zbiorze kluczem "file_name", wszelkie poprawne dyrektywy serwera mogą być dodane do zbioru. Dla dyrektywy lokalizacji dodaj klucz "location" z unikalnym numerem, wartość dla lokalizacji to zbiór; upewnij się, że są to poprawne dyrektywy lokalizacji.
Zainstaluj Nginx i dodaj 2 strony (inna metoda)
- 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"
- server:
file_name: foo
listen: 8080
server_name: localhost
root: "/tmp/site1"
location:
- role: nginx
nginx_http_params:
sendfile: "on"
access_log: "/var/log/nginx/access.log"
nginx_sites:
- hosts: all
roles:
Zależności
Brak
Licencja
BSD
Informacje o autorze
Oryginalny autor roli: Benno Joy Autor fork Ginsys: Serge van Ginderachter serge@vanginderachter.be
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
ansible-galaxy install ginsys.nginx