lemp

Ansible роль LEMP

CI MoleculeAnsible Role

Платформы

Платформы Тестирование
Debian 11 :heavy_check_mark:
Debian 10 :heavy_check_mark:
Ubuntu 20.04 :heavy_check_mark:
Ubuntu 18.04 :heavy_check_mark:
Oracle Linux 8 :heavy_check_mark:
Rocky Linux 8 :heavy_check_mark:

Установка

ansible-galaxy install darexsu.lemp --force

Требования

роли: Nginx, MariaDB, MySQL, PHP, FirewallD (будет установлен автоматически)

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

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

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

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

  vars:
    merge:
      # LEMP
      lemp:
        enabled: true
        domen: "example.site"
        project_dir: "/usr/share/nginx/html/"

      # Nginx
      nginx:
        enabled: true
      # Nginx -> установка
      nginx_install:
        enabled: true
      # Nginx -> конфигурация -> nginx.conf
      nginx_conf:
        enabled: true
      # Nginx -> конфигурация -> {virtualhost}.conf
      nginx_virtualhost:
        default_conf:
          enabled: true

      # MariaDB
      mariadb:
        enabled: true
      mariadb_install:
        enabled: true

      # PHP
      php:
        enabled: true
        version: "7.4"
      # PHP -> установка
      php_install:
        enabled: true
        modules: [common, fpm]
      # PHP -> конфигурация -> php.fpm
      php_fpm:
        www_conf:
          enabled: true

      # FirewallD
      firewalld:
        enabled: true
      # FirewallD -> правила
      firewalld_rules:
        service_http:
          enabled: true
        service_https:
          enabled: true


  tasks:
    - name: роль darexsu lemp
      include_role:
        name: darexsu.lemp
Установка и настройка: LEMP с MySQL (версия слияния)
---
- hosts: all
  become: true

  vars:
    merge:
      # LEMP
      lemp:
        enabled: true
        domen: "example.site"
        project_dir: "/usr/share/nginx/html/"

      # Nginx
      nginx:
        enabled: true
      # Nginx -> установка
      nginx_install:
        enabled: true
      # Nginx -> конфигурация -> nginx.conf
      nginx_conf:
        enabled: true
      # Nginx -> конфигурация -> {virtualhost}.conf
      nginx_virtualhost:
        default_conf:
          enabled: true

      # MySQL
      mysql:
        enabled: true
      # MySQL -> установка
      mysql_install:
        enabled: true

      # PHP
      php:
        enabled: true
        version: "7.4"
      # PHP -> установка
      php_install:
        enabled: true
        modules: [common, fpm]
      # PHP -> конфигурация -> php.fpm
      php_fpm:
        www_conf:
          enabled: true

      # FirewallD
      firewalld:
        enabled: true
      # FirewallD -> правила
      firewalld_rules:
        service_http:
          enabled: true
        service_https:
          enabled: true

  tasks:
    - name: роль darexsu lemp
      include_role:
        name: darexsu.lemp
Установка: LEMP с MariaDB (версия слияния)
---
- hosts: all
  become: true

  vars:
    merge:
      # LEMP
      lemp:
        enabled: true

      # Nginx
      nginx:
        enabled: true
      # Nginx -> установка
      nginx_install:
        enabled: true

      # MariaDB
      mariadb:
        enabled: true
      # MariaDB -> установка
      mariadb_install:
        enabled: true

      # PHP
      php:
        enabled: true
        version: "7.4"
      # PHP -> установка
      php_install:
        enabled: true
        modules: [common, fpm]

  tasks:
    - name: роль darexsu lemp
      include_role:
        name: darexsu.lemp
Установка: LEMP с MySQL (версия слияния)
---
- hosts: all
  become: true

  vars:
    merge:
      # LEMP
      lemp:
        enabled: true

      # Nginx
      nginx:
        enabled: true
      # Nginx -> установка
      nginx_install:
        enabled: true

      # MySQL
      mysql:
        enabled: true
      # MySQL -> установка
      mysql_install:
        enabled: true

      # PHP
      php:
        enabled: true
        version: "7.4"
      # PHP -> установка
      php_install:
        enabled: true
        modules: [common, fpm]

  tasks:
    - name: роль darexsu lemp
      include_role:
        name: darexsu.lemp
Установка и настройка: LEMP с MariaDB (полная версия)
---
- hosts: all
  become: true

  vars:
    # LEMP
    lemp:
      enabled: true
      domen: "example.site"
      project_dir: "/usr/share/nginx/html/"

    # 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: "{{ lemp.domen }}"
          root: "{{ lemp.project_dir }}"
          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{{ php.version }}-fpm.sock"

    # MariaDB
    mariadb:
      enabled: true
      repo: "mariadb"
      version: "10.5"
      service:
        state: "started"
        enabled: true
    # MariaDB -> установка
    mariadb_install:
      enabled: true

    # PHP
    php:
      enabled: true
      version: "7.4"
      repo: "third_party"
      service:
        enabled: true
        state: "started"
    # PHP -> установка
    php_install:
      enabled: true
      modules: [common, fpm]
    # PHP -> конфигурация -> php.fpm
    php_fpm:
      www_conf:
        enabled: true
        file: "www.conf"
        state: "present"
        src: "php_fpm.j2"
        backup: false
        data:
          webserver_user: "www-data"
          webserver_group: "www-data"
          pm: "dynamic"
          pm_max_children: "10"
          pm_start_servers: "5"
          pm_min_spare_servers: "5"
          pm_max_spare_servers: "5"
          pm_max_requests: "500"
          tcp_ip_socket:
            enabled: false
            listen: "127.0.0.1:9000"
          unix_socket:
            enabled: true
            file: "php{{ php.version }}-fpm.sock"
            user: "www-data"
            group: "www-data"

  tasks:
    - name: роль darexsu lemp
      include_role:
        name: darexsu.lemp
Установка и настройка: LEMP с MySQL (полная версия)
---
- hosts: all
  become: true

  vars:
    # LEMP
    lemp:
      enabled: true
      domen: "example.site"
      project_dir: "/usr/share/nginx/html/"

    # 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: "{{ lemp.domen }}"
          root: "{{ lemp.project_dir }}"
          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{{ php.version }}-fpm.sock"

    # MySQL
    mysql:
      enabled: true
      repo: "mysql"
      version: "8.0"
      service:
        state: "started"
        enabled: true
    # MySQL -> установка
    mysql_install:
      enabled: true

    # PHP
    php:
      enabled: true
      version: "7.4"
      repo: "third_party"
      service:
        enabled: true
        state: "started"
    # PHP -> установка
    php_install:
      enabled: true
      modules: [common, fpm]
    # PHP -> конфигурация -> php.fpm
    php_fpm:
      www_conf:
        enabled: true
        file: "www.conf"
        state: "present"
        src: "php_fpm.j2"
        backup: false
        data:
          webserver_user: "www-data"
          webserver_group: "www-data"
          pm: "dynamic"
          pm_max_children: "10"
          pm_start_servers: "5"
          pm_min_spare_servers: "5"
          pm_max_spare_servers: "5"
          pm_max_requests: "500"
          tcp_ip_socket:
            enabled: false
            listen: "127.0.0.1:9000"
          unix_socket:
            enabled: true
            file: "php{{ php.version }}-fpm.sock"
            user: "www-data"
            group: "www-data"

    # FirewallD
    firewalld:
      enabled: true
      service:
        enabled: true
        state: "started"

    # FirewallD -> правила
    firewalld_rules:
      service_http:
        enabled: true
        zone: "public"
        state: "enabled"
        service: "http"
        permanent: true
        immediate: true
      service_https:
        enabled: true
        zone: "public"
        state: "enabled"
        service: "https"
        permanent: true
        immediate: true

  tasks:
    - name: роль darexsu lemp
      include_role:
        name: darexsu.lemp
Установка: LEMP с MariaDB (полная версия)
---
- hosts: all
  become: true

  vars:
    # LEMP
    lemp:
      enabled: true
      domen: "example.site"
      project_dir: "/usr/share/nginx/html/"

    # Nginx
    nginx:
      enabled: true
      repo: "nginx"
      service:
        enabled: true
        state: "started"
    # Nginx -> установка
    nginx_install:
      enabled: true

    # MariaDB
    mariadb:
      enabled: true
      repo: "mariadb"
      version: "10.5"
      service:
        state: "started"
        enabled: true
    # MariaDB -> установка
    mariadb_install:
      enabled: true

    # PHP
    php:
      enabled: true
      version: "7.4"
      repo: "third_party"
      service:
        enabled: true
        state: "started"
    # PHP -> установка
    php_install:
      enabled: true
      modules: [common, fpm]

  tasks:
    - name: роль darexsu lemp
      include_role:
        name: darexsu.lemp
Установка: LEMP с MySQL (полная версия)
---
- hosts: all
  become: true

  vars:
    # LEMP
    lemp:
      enabled: true
      domen: "example.site"
      project_dir: "/usr/share/nginx/html/"

    # Nginx
    nginx:
      enabled: true
      repo: "nginx"
      service:
        enabled: true
        state: "started"
    # Nginx -> установка
    nginx_install:
      enabled: true

    # MySQL
    mysql:
      enabled: true
      repo: "mysql"
      version: "8.0"
      service:
        state: "started"
        enabled: true
    # MySQL -> установка
    mysql_install:
      enabled: true

    # PHP
    php:
      enabled: true
      version: "7.4"
      repo: "third_party"
      service:
        enabled: true
        state: "started"
    # PHP -> установка
    php_install:
      enabled: true
      modules: [common, fpm]

  tasks:
    - name: роль darexsu lemp
      include_role:
        name: darexsu.lemp
О проекте

install and configure LEMP stack

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