darexsu.php

Ansible角色 PHP 7.x, 8.x

CI MoleculeAnsible角色

平台

测试 仓库: 发行版 仓库: 第三方
Debian 11 PHP 7.4 Sury
Debian 10 PHP 7.3 Sury
Ubuntu 20.04 PHP 7.4 ppa:andrej
Ubuntu 18.04 PHP 7.2 ppa:andrej
Oracle Linux 8 PHP 7.2-7.4 Remi
Rocky Linux 8 PHP 7.2-7.4 Remi

安装

ansible-galaxy install darexsu.php --force

合并行为

替换或合并字典(在ansible.cfg中使用"hash_behaviour=replace"):

# 替换             # 合并
---                   ---
  vars:                 vars:
    dict:                 merge:
      a: "值"            dict: 
      b: "值"              a: "值" 
                              b: "值"

# 合并是如何工作的?:
你的变量 [主机变量]  -->  默认变量 [当前角色] --> 默认变量 [包含角色]
  
  dict:          dict:              dict:
    a: "1" -->     a: "1"    -->      a: "1"
                   b: "2"    -->      b: "2"
                                      c: "3"
    
安装并配置: PHP(合并版本)
---
- hosts: all
  become: true

  vars:
    merge:
      # PHP
      php:
        enabled: true
        version: "7.4"
      # PHP -> 安装
      php_install:
        enabled: true
        modules: [common, fpm]
      # PHP -> 配置 -> php.ini
      php_ini:
        enabled: true
        file: "php.ini"
        src: "php_ini.j2"
        backup: false
        data:
          php:
            max_execution_time: "30"
            max_input_time: "60"
            memory_limit: "128M"
            upload_max_filesize: "2M"
      # PHP -> 配置 -> php.fpm
      php_fpm:
        www_conf:
          enabled: true
          file: "www.conf"
          state: "present"
          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"
            unix_socket:
              enabled: true
              file: "php{{ php.version }}-fpm.sock"
              user: "www-data"
              group: "www-data"

  tasks:
    - name: include role darexsu.php
      include_role:
        name: darexsu.php
安装: PHP, 仓库: 发行版(合并版本)
---
- hosts: all
  become: true

  vars:
    merge:
      # PHP
      php:
        enabled: true
        version: "7.4"
        repo: "distribution"
      # PHP -> 安装
      php_install:
        enabled: true
        modules: [common, fpm]

  tasks:
    - name: include role darexsu.php
      include_role: 
        name: darexsu.php
安装: PHP, 仓库: 第三方(合并版本)
---
- hosts: all
  become: true

  vars:
    merge:
      # PHP
      php:
        enabled: true
        version: "8.0"
        repo: "third_party"

      # PHP -> 安装
      php_install:
        enabled: true
        modules: [common, fpm]

  tasks:
    - name: include role darexsu.php
      include_role: 
        name: darexsu.php
安装: PHP模块(合并版本)
---
- hosts: all
  become: true

  vars:
    merge:
      # PHP
      php:
        enabled: true
        version: "7.4"
        repo: "third_party"
      # PHP -> 安装
      php_install:
        enabled: true
      # PHP -> 安装 -> 安装自定义模块
        modules: [common, fpm, gd]

  tasks:
    - name: include role darexsu.php
      include_role:
        name: darexsu.php
配置: php.ini(合并版本)
---
- hosts: all
  become: true

  vars:
    merge:
      # PHP
      php:
        enabled: true
        version: "7.4"
        repo: "third_party"
      # PHP -> 配置 -> php.ini
      php_ini:
        enabled: true
        data:
          php:
            engine: "开启"
            short_open_tag: "关闭"
            precision: "14"
            output_buffering: "4096"
            zlib_output_compression: "关闭"
            implicit_flush: "关闭"
       #    ...

  tasks:
    - name: include role darexsu.php
      include_role:
        name: darexsu.php
配置: php-fpm tcpip套接字(合并版本)
---
- hosts: all
  become: yes

  vars:
    merge:
      # PHP
      php:
        enabled: true
        version: "7.4"
        repo: "third_party"
      # PHP -> 配置 -> php-fpm池
      php_fpm:
        www_conf:
          enabled: true
          file: "www.conf"
          state: "present"
          src: "php_fpm.j2"
          backup: true          
          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"
      # PHP -> 配置 -> php-fpm池 -> 启用tcp/ip套接字   
            tcp_ip_socket:
              enabled: true
              listen: "127.0.0.1:9000"
      # PHP -> 配置 -> php-fpm池 -> 禁用unix套接字
            unix_socket:
              enabled: false
              file: "php{{ php.version }}-fpm.sock"
              user: "www-data"
              group: "www-data"  

  tasks:
    - name: include role darexsu.php
      include_role: 
        name: darexsu.php
配置: php-fpm unix套接字(合并版本)
---
- hosts: all
  become: yes

  vars:
    merge:
      # PHP
      php:
        enabled: true
        version: "7.4"
        repo: "third_party"
      # PHP -> 配置 -> php-fpm池
      php_fpm:
        www_conf:
          enabled: true
          file: "www.conf"
          state: "present"
          src: "php_fpm.j2"
          backup: true         
          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"
      # PHP -> 配置 -> php-fpm池 -> 禁用tcp/ip套接字       
            tcp_ip_socket:
              enabled: false
              listen: "127.0.0.1:9000"
      # PHP -> 配置 -> php-fpm池 -> 启用unix套接字
            unix_socket:
              enabled: true
              file: "php{{ php.version }}-fpm.sock"
              user: "www-data"
              group: "www-data"  

  tasks:
    - name: include role darexsu.php
      include_role: 
        name: darexsu.php
配置: 添加多个配置(合并版本)
---
- hosts: all
  become: yes

  vars:
    merge:
      # PHP
      php:
        enabled: true
        version: "7.4"
        repo: "third_party"
      # PHP -> 配置 -> php-fpm池
      php_fpm:
      # PHP -> 配置 -> php.fpm池 -> 删除www.conf  
        www_conf:
          enabled: true
          state: "absent"
      # PHP -> 配置 -> php.fpm池 -> 添加new.conf
        first_conf:
          enabled: true
          file: "first.conf"
          state: "present"
          src: "php_fpm.j2"
          backup: true         
          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 }}-first-fpm.sock"
              user: "www-data"
              group: "www-data"
      # PHP -> 配置 -> php.fpm池 -> 添加second.conf
        second_conf:
          enabled: true
          file: "second.conf"
          state: "present"
          src: "php_fpm.j2"
          backup: true         
          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 }}-second-fpm.sock"
              user: "www-data"
              group: "www-data"  

  tasks:
    - name: include role darexsu.php
      include_role: 
        name: darexsu.php
安装并配置: PHP(完整版本)
---
- hosts: all
  become: true

  vars:
    # 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.ini
    php_ini:
      enabled: true
      file: "php.ini"
      src: "php_ini.j2"
      backup: false
      data:
        php:
          engine: "开启"
          short_open_tag: "关闭"
          precision: "14"
          output_buffering: "4096"
          zlib_output_compression: "关闭"
          implicit_flush: "关闭"
          unserialize_callback_func: ""
          serialize_precision: "-1"
          disable_functions: ""
          disable_classes: ""
          zend_enable_gc: ""
          zend_exception_ignore_args: "开启"
          zend_exception_string_param_max_len: "0"
          expose_php: "开启"
          max_execution_time: "30"
          max_input_time: "60"
          memory_limit: "128M"
          error_reporting: "E_ALL & ~E_DEPRECATED & ~E_STRICT"
          display_errors: "关闭"
          display_startup_errors: "关闭"
          log_errors: "开启"
          log_errors_max_len: "1024"
          ignore_repeated_errors: "关闭"
          ignore_repeated_source: "关闭"
          report_memleaks: "开启"
          variables_order: "GPCS"
          request_order: "GP"
          register_argc_argv: "关闭"
          auto_globals_jit: "开启"
          post_max_size: "8M"
          auto_prepend_file: ""
          auto_append_file: ""
          default_mimetype: "text/html"
          default_charset: "UTF-8"
          doc_root: ""
          user_dir: ""
          enable_dl: "关闭"
          file_uploads: "开启"
          upload_max_filesize: "2M"
          max_file_uploads: "20"
          allow_url_fopen: "开启"
          allow_url_include: "关闭"
          default_socket_timeout: "60"
    # 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: include role darexsu.php
      include_role: 
        name: darexsu.php
安装: PHP, 仓库: 发行版(完整版本)
---
- hosts: all
  become: true

  vars:
    # PHP
    php:
      enabled: true
      version: "7.4"
      repo: "distribution"
      service:
        enabled: true
        state: "started"
    # PHP -> 安装
    php_install:
      enabled: true
      modules: [common, fpm]

  tasks:
    - name: include role darexsu.php
      include_role: 
        name: darexsu.php
安装: PHP, 仓库: 第三方(完整版本)
---
- hosts: all
  become: true

  vars:
    # PHP
    php:
      enabled: true
      version: "8.0"
      repo: "third_party"
      service:
        enabled: true
        state: "started"
    # PHP -> 安装
    php_install:
      enabled: true
      modules: [common, fpm]

  tasks:
    - name: include role darexsu.php
      include_role: 
        name: darexsu.php
安装: PHP模块(完整版本)
---
- hosts: all
  become: true

  vars:
    # PHP
    php:
      enabled: true
      version: "7.4"
      repo: "third_party"
      service:
        enabled: true
        state: "started"
    # PHP -> 安装
    php_install:
      enabled: true
    # PHP -> 安装 -> 安装自定义模块
      modules: [common, fpm, gd]

  tasks:
    - name: include role darexsu.php
      include_role: 
        name: darexsu.php 
配置: php.ini(完整版本)
---
- hosts: all
  become: true

  vars:
    # PHP
    php:
      enabled: true
      version: "7.4"
      repo: "third_party"
      service:
        enabled: true
        state: "started"
    # PHP -> 配置 -> php.ini
    php_ini:
      enabled: true
      file: "php.ini"
      src: "php_ini.j2"
      backup: false
      data:
        php:
          engine: "开启"
          short_open_tag: "关闭"
          precision: "14"
          output_buffering: "4096"
          zlib_output_compression: "关闭"
          implicit_flush: "关闭"
          unserialize_callback_func: ""
          serialize_precision: "-1"
          disable_functions: ""
          disable_classes: ""
          zend_enable_gc: ""
          zend_exception_ignore_args: "开启"
          zend_exception_string_param_max_len: "0"
          expose_php: "开启"
          max_execution_time: "30"
          max_input_time: "60"
          memory_limit: "128M"
          error_reporting: "E_ALL & ~E_DEPRECATED & ~E_STRICT"
          display_errors: "关闭"
          display_startup_errors: "关闭"
          log_errors: "开启"
          log_errors_max_len: "1024"
          ignore_repeated_errors: "关闭"
          ignore_repeated_source: "关闭"
          report_memleaks: "开启"
          variables_order: "GPCS"
          request_order: "GP"
          register_argc_argv: "关闭"
          auto_globals_jit: "开启"
          post_max_size: "8M"
          auto_prepend_file: ""
          auto_append_file: ""
          default_mimetype: "text/html"
          default_charset: "UTF-8"
          doc_root: ""
          user_dir: ""
          enable_dl: "关闭"
          file_uploads: "开启"
          upload_max_filesize: "2M"
          max_file_uploads: "20"
          allow_url_fopen: "开启"
          allow_url_include: "关闭"
          default_socket_timeout: "60"

  tasks:
    - name: include role darexsu.php
      include_role: 
        name: darexsu.php
配置: php-fpm tcpip套接字(完整版本)
---
- hosts: all
  become: yes

  vars:
    # PHP
    php:
      enabled: true
      version: "7.4"
      repo: "third_party"
    # PHP -> 配置 -> php-fpm池
    php_fpm:
      www_conf:
        enabled: true
        file: "www.conf"
        state: "present"
        src: "php_fpm.j2"
        backup: true          
        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"
    # PHP -> 配置 -> php-fpm池 -> 启用tcp/ip套接字   
          tcp_ip_socket:
            enabled: true
            listen: "127.0.0.1:9000"
    # PHP -> 配置 -> php-fpm池 -> 禁用unix套接字
          unix_socket:
            enabled: false
            file: "php{{ php.version }}-fpm.sock"
            user: "www-data"
            group: "www-data"  

  tasks:
    - name: include role darexsu.php
      include_role: 
        name: darexsu.php
配置: php-fpm unix套接字(完整版本)
---
- hosts: all
  become: yes

  vars:
    # PHP
    php:
      enabled: true
      version: "7.4"
      repo: "third_party"
    # PHP -> 配置 -> php-fpm池
    php_fpm:
      www_conf:
        enabled: true
        file: "www.conf"
        state: "present"
        src: "php_fpm.j2"
        backup: true         
        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"
    # PHP -> 配置 -> php-fpm池 -> 禁用tcp/ip套接字       
          tcp_ip_socket:
            enabled: false
            listen: "127.0.0.1:9000"
    # PHP -> 配置 -> php-fpm池 -> 启用unix套接字
          unix_socket:
            enabled: true
            file: "php{{ php.version }}-fpm.sock"
            user: "www-data"
            group: "www-data"  

  tasks:
    - name: include role darexsu.php
      include_role: 
        name: darexsu.php
配置: 添加多个配置(完整版本)
---
- hosts: all
  become: yes

  vars:
    # PHP
    php:
      enabled: true
      version: "7.4"
      repo: "third_party"
    # PHP -> 配置 -> php-fpm池
    php_fpm:
    # PHP -> 配置 -> php.fpm池 -> 删除www.conf  
      www_conf:
        enabled: true
        state: "absent"
    # PHP -> 配置 -> php.fpm池 -> 添加new.conf
      first_conf:
        enabled: true
        file: "first.conf"
        state: "present"
        src: "php_fpm.j2"
        backup: true         
        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 }}-first-fpm.sock"
            user: "www-data"
            group: "www-data"
    # PHP -> 配置 -> php.fpm池 -> 添加second.conf
      second_conf:
        enabled: true
        file: "second.conf"
        state: "present"
        src: "php_fpm.j2"
        backup: true         
        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 }}-second-fpm.sock"
            user: "www-data"
            group: "www-data"  

  tasks:
    - name: include role darexsu.php
      include_role: 
        name: darexsu.php
关于项目

install and configure php 7.x, php 8.x.

安装
ansible-galaxy install darexsu.php
许可证
mit
下载
2.9k
拥有者