nginx

Ansible роль Nginx

CI MoleculeAnsible Role

Платформы

Тестирование репо: дистрибутив репо: nginx
Debian 11 Nginx 1.18 nginx.org
Debian 10 Nginx 1.14 nginx.org
Ubuntu 20.04 Nginx 1.18-1.20 nginx.org
Ubuntu 18.04 Nginx 1.18-1.20 nginx.org
Oracle Linux 8 Nginx 1.14-1.20 nginx.org
Rocky Linux 8 Nginx 1.14-1.20 nginx.org

Установка

ansible-galaxy install darexsu.nginx --force

Поведение слияния

Замена или Слияние словарей (с "hash_behaviour=replace" в ansible.cfg):

# Замена             # Слияние
---                   ---
  vars:                 vars:
    dict:                 merge:
      a: "value"            dict: 
      b: "value"              a: "value" 
                              b: "value"

# Как работает слияние?
Ваши vars [host_vars]  -->  стандартные vars [текущая роль] --> стандартные vars [включить роль]
  
  dict:          dict:              dict:
    a: "1" -->     a: "1"    -->      a: "1"
                   b: "2"    -->      b: "2"
                                      c: "3"
    
Установка и настройка: Nginx (версия слияния)
---
- hosts: all
  become: true

  vars:
    merge:
      # Nginx
      nginx:
        enabled: true
        repo: "nginx"
      # Nginx -> установка
      nginx_install:
        enabled: true
      # Nginx -> конфигурация -> nginx.conf
      nginx_conf:
        enabled: true
        data:
          user: "www-data"
          worker_processes: "auto"
          error_log: "/var/log/nginx/error.log notice"
          pidfile: "/var/run/nginx.pid"
          worker_connections: "1024"
      #   ...
      # Nginx -> конфигурация -> {virtualhost}.conf
      nginx_virtualhost:
        default_conf:
          enabled: true
          file: "default.conf"
          state: "present"
          src: "nginx_virtualhost.j2"
          backup: false
          data:
            listen_port: "80"
            listen_ipv6: false
            server_name: "localhost"
            root: "/usr/share/nginx/html"
            index: "index.html index.htm index.php"
            error_page: ""
            access_log: false
            error_log: false
            tcp_ip_socket:
              enabled: false
              listen: "127.0.0.1:9000"
            unix_socket:
              enabled: true
              file: "php-fpm.sock"

  tasks:
    - name: включить роль darexsu.nginx
      include_role:
        name: darexsu.nginx
    
Установка: Nginx, репозиторий: дистрибутив (версия слияния)
---
- hosts: all
  become: true

  vars:
    merge:
      # Nginx
      nginx:
        enabled: true
        repo: "distribution"
      # Nginx -> установка
      nginx_install:
        enabled: true
  
  tasks:
    - name: включить роль darexsu.nginx
      include_role: 
        name: darexsu.nginx
Установка: Nginx, репозиторий: nginx (версия слияния)
---
- hosts: all
  become: true

  vars:
    merge:
      # Nginx
      nginx:
        enabled: true
        repo: "nginx"
      # Nginx -> установка
      nginx_install:
        enabled: true
  
  tasks:
    - name: включить роль darexsu.nginx
      include_role: 
        name: darexsu.nginx
    
Настройка: nginx.conf (версия слияния)
---
- hosts: all
  become: true

  vars:
    merge:
      # Nginx
      nginx:
        enabled: true
        repo: "nginx"
      # Nginx -> конфигурация -> nginx.conf
      nginx_conf:
        enabled: true
        file: "nginx.conf"
        src: "nginx_conf.j2"
        backup: false
        data:
          user: "www-data"
          worker_processes: "auto"
          error_log: "/var/log/nginx/error.log notice"
          pidfile: "/var/run/nginx.pid"
          worker_connections: "1024"
          multi_accept: "off"
          mime_file_path: "/etc/nginx/mime.types"
          access_log: "/var/log/nginx/access.log"
          sendfile: "off"
          tcp_nopush: "off"
          tcp_nodelay: "on"
          keepalive_timeout: "75s"
          keepalive_requests: "1000"
  
  tasks:
    - name: включить роль darexsu.nginx
      include_role: 
        name: darexsu.nginx
    
Настройка: virtualhost.conf tcpip-сокет (версия слияния)
---
- hosts: all
  become: true

  vars:
    merge:
      # Nginx
      nginx:
        enabled: true
      # Nginx -> конфигурация -> {virtualhost}.conf
      nginx_virtualhost:
        default_conf:
          enabled: true
          file: "default.conf"
          state: "present"
          src: "nginx_virtualhost.j2"
          backup: false
          data:
            listen_port: "80"
            listen_ipv6: false
            server_name: "localhost"
            root: "/usr/share/nginx/html"
            index: "index.html index.htm index.php"
            error_page: ""
            access_log: false
            error_log: false
            tcp_ip_socket:
              enabled: true
              listen: "127.0.0.1:9000"
            unix_socket:
              enabled: false
              file: "php-fpm.sock"
  
  tasks:
    - name: включить роль darexsu.nginx
      include_role: 
        name: darexsu.nginx
    
Настройка: virtualhost.conf unix-сокет (версия слияния)
---
- hosts: all
  become: true

  vars:
    merge:
      # Nginx
      nginx:
        enabled: true
      # Nginx -> конфигурация -> {virtualhost}.conf
      nginx_virtualhost:
        default_conf:
          enabled: true
          file: "default.conf"
          state: "present"
          src: "nginx_virtualhost.j2"
          backup: false
          data:
            listen_port: "80"
            listen_ipv6: false
            server_name: "localhost"
            root: "/usr/share/nginx/html"
            index: "index.html index.htm index.php"
            error_page: ""
            access_log: false
            error_log: false
            tcp_ip_socket:
              enabled: true
              listen: "127.0.0.1:9000"
            unix_socket:
              enabled: false
              file: "php-fpm.sock"
  
  tasks:
    - name: включить роль darexsu.nginx
      include_role: 
        name: darexsu.nginx    
Настройка: добавление нескольких virtualhost.conf (версия слияния)
---
- hosts: all
  become: true

  vars:
    merge:
      # Nginx
      nginx:
        enabled: true
      # Nginx -> конфигурация -> default.conf
      nginx_virtualhost:
        default_conf:
          enabled: true
          file: "default.conf"
          state: "present"
          src: "nginx_virtualhost.j2"
          backup: false
          data:
            listen_port: "80"
            listen_ipv6: false
            server_name: "localhost"
            root: "/usr/share/nginx/html"
            index: "index.html index.htm index.php"
            error_page: ""
            access_log: false
            error_log: false
            tcp_ip_socket:
              enabled: true
              listen: "127.0.0.1:9000"
            unix_socket:
              enabled: false
              file: "php-fpm.sock"
      # Nginx -> конфигурация -> new.conf
        new_conf:
          enabled: true
          file: "new.conf"
          state: "present"
          src: "nginx_virtualhost.j2"
          backup: false
          data:
            listen_port: "80"
            listen_ipv6: false
            server_name: "localhost"
            root: "/usr/share/nginx/html"
            index: "index.html index.htm index.php"
            error_page: ""
            access_log: false
            error_log: false
            tcp_ip_socket:
              enabled: true
              listen: "127.0.0.1:9001"
            unix_socket:
              enabled: false
              file: "php-fpm.sock"
  
  tasks:
    - name: включить роль darexsu.nginx
      include_role: 
        name: darexsu.nginx    
Установка и настройка: Nginx (полная версия)
---
- hosts: all
  become: true

  vars:
    # Nginx
    nginx:
      enabled: true
      repo: "nginx"
      service:
        enabled: true
        state: "started"
    # Nginx -> установка
    nginx_install:
      enabled: true
    # Nginx -> конфигурация -> nginx.conf
    nginx_conf:
      enabled: true
      file: "nginx.conf"
      src: "nginx_conf.j2"
      backup: false
      data:
        user: "www-data"
        worker_processes: "auto"
        error_log: "/var/log/nginx/error.log notice"
        pidfile: "/var/run/nginx.pid"
        worker_connections: "1024"
        multi_accept: "off"
        mime_file_path: "/etc/nginx/mime.types"
        access_log: "/var/log/nginx/access.log"
        sendfile: "off"
        tcp_nopush: "off"
        tcp_nodelay: "on"
        keepalive_timeout: "75s"
        keepalive_requests: "1000"
    # Nginx -> конфигурация -> {virtualhost}.conf
    nginx_virtualhost:
      default_conf:
        enabled: true
        file: "default.conf"
        state: "present"
        src: "nginx_virtualhost.j2"
        backup: false
        data:
          listen_port: "80"
          listen_ipv6: false
          server_name: "localhost"
          root: "/usr/share/nginx/html"
          index: "index.html index.htm index.php"
          error_page: ""
          access_log: false
          error_log: false
          tcp_ip_socket:
            enabled: false
            listen: "127.0.0.1:9000"
          unix_socket:
            enabled: true
            file: "php-fpm.sock"

  tasks:
    - name: включить роль darexsu.nginx
      include_role:
        name: darexsu.nginx
    
Установка: Nginx, репозиторий: дистрибутив (полная версия)
---
- hosts: all
  become: true

  vars:
    # Nginx
    nginx:
      enabled: true
      repo: "distribution"
      service:
        enabled: true
        state: "started"
    # Nginx -> установка
    nginx_install:
      enabled: true
  
  tasks:
    - name: включить роль darexsu.nginx
      include_role: 
        name: darexsu.nginx
Установка: Nginx, репозиторий: nginx (полная версия)
---
- hosts: all
  become: true

  vars:
    # Nginx
    nginx:
      enabled: true
      repo: "nginx"
      service:
        enabled: true
        state: "started"
    # Nginx -> установка
    nginx_install:
      enabled: true
  
  tasks:
    - name: включить роль darexsu.nginx
      include_role: 
        name: darexsu.nginx
    
Настройка: nginx.conf (полная версия)
---
- hosts: all
  become: true

  vars:
    # Nginx
    nginx:
      enabled: true
      repo: "nginx"
      service:
        enabled: true
        state: "started"
    # Nginx -> конфигурация -> nginx.conf
    nginx_conf:
      enabled: true
      file: "nginx.conf"
      src: "nginx_conf.j2"
      backup: false
      data:
        user: "www-data"
        worker_processes: "auto"
        error_log: "/var/log/nginx/error.log notice"
        pidfile: "/var/run/nginx.pid"
        worker_connections: "1024"
        multi_accept: "off"
        mime_file_path: "/etc/nginx/mime.types"
        access_log: "/var/log/nginx/access.log"
        sendfile: "off"
        tcp_nopush: "off"
        tcp_nodelay: "on"
        keepalive_timeout: "75s"
        keepalive_requests: "1000"
  
  tasks:
    - name: включить роль darexsu.nginx
      include_role: 
        name: darexsu.nginx
    
Настройка: virtualhost.conf tcpip-сокет (полная версия)
---
- hosts: all
  become: true

  vars:
    # Nginx
    nginx:
      enabled: true
      repo: "nginx"
      service:
        enabled: true
        state: "started"
    # Nginx -> конфигурация -> {virtualhost}.conf
    nginx_virtualhost:
      default_conf:
        enabled: true
        file: "default.conf"
        state: "present"
        src: "nginx_virtualhost.j2"
        backup: false
        data:
          listen_port: "80"
          listen_ipv6: false
          server_name: "localhost"
          root: "/usr/share/nginx/html"
          index: "index.html index.htm index.php"
          error_page: ""
          access_log: false
          error_log: false
          tcp_ip_socket:
            enabled: true
            listen: "127.0.0.1:9000"
          unix_socket:
            enabled: false
            file: "php-fpm.sock"
  
  tasks:
    - name: включить роль darexsu.nginx
      include_role: 
        name: darexsu.nginx
    
Настройка: virtualhost.conf unix-сокет (полная версия)
---
- hosts: all
  become: true

  vars:
    # Nginx
    nginx:
      enabled: true
      repo: "nginx"
      service:
        enabled: true
        state: "started"
    # Nginx -> конфигурация -> {virtualhost}.conf
    nginx_virtualhost:
      default_conf:
        enabled: true
        file: "default.conf"
        state: "present"
        src: "nginx_virtualhost.j2"
        backup: false
        data:
          listen_port: "80"
          listen_ipv6: false
          server_name: "localhost"
          root: "/usr/share/nginx/html"
          index: "index.html index.htm index.php"
          error_page: ""
          access_log: false
          error_log: false
          tcp_ip_socket:
            enabled: true
            listen: "127.0.0.1:9000"
          unix_socket:
            enabled: false
            file: "php-fpm.sock"
  
  tasks:
    - name: включить роль darexsu.nginx
      include_role: 
        name: darexsu.nginx    
Настройка: добавление нескольких virtualhost.conf (полная версия)
---
- hosts: all
  become: true

  vars:
    # Nginx
    nginx:
      enabled: true
      repo: "nginx"
      service:
        enabled: true
        state: "started"
    # Nginx -> конфигурация -> default.conf
    nginx_virtualhost:
      default_conf:
        enabled: true
        file: "default.conf"
        state: "present"
        src: "nginx_virtualhost.j2"
        backup: false
        data:
          listen_port: "80"
          listen_ipv6: false
          server_name: "localhost"
          root: "/usr/share/nginx/html"
          index: "index.html index.htm index.php"
          error_page: ""
          access_log: false
          error_log: false
          tcp_ip_socket:
            enabled: true
            listen: "127.0.0.1:9000"
          unix_socket:
            enabled: false
            file: "php-fpm.sock"
    # Nginx -> конфигурация -> new.conf
      new_conf:
        enabled: true
        file: "new.conf"
        state: "present"
        src: "nginx_virtualhost.j2"
        backup: false
        data:
          listen_port: "80"
          listen_ipv6: false
          server_name: "localhost"
          root: "/usr/share/nginx/html"
          index: "index.html index.htm index.php"
          error_page: ""
          access_log: false
          error_log: false
          tcp_ip_socket:
            enabled: true
            listen: "127.0.0.1:9001"
          unix_socket:
            enabled: false
            file: "php-fpm.sock"
  
  tasks:
    - name: включить роль darexsu.nginx
      include_role: 
        name: darexsu.nginx    
О проекте

install and configure nginx from distro/third-party

Установить
ansible-galaxy install darexsu/ansible-role-nginx
Лицензия
mit
Загрузки
2375
Владелец