Git Product home page Git Product logo

ansible-role-php-fpm-1's Introduction

php-fpm

License Build Status Build Status Updates Python 3 Ansible Role GitHub tag

Install php-fpm package.

Requirements

This role requires Ansible 2.4 or higher, and platform requirements are listed in the metadata file.

Testing

This role use Molecule to run tests.

Locally, you can run tests on Docker (default driver) or Vagrant. Travis run tests using Docker driver only.

Currently, tests are done on:

  • Ubuntu Xenial
  • Ubuntu Bionic

and use:

  • Ansible 2.4.x
  • Ansible 2.5.x
  • Ansible 2.6.x
  • Ansible 2.7.x

Running tests

Automatically with Travis

Tests runs automatically on Travis on push, release, pr, ... using docker testing containers

Using Docker driver

$ tox

Role Variables

Default role variables

# Packages management
php_fpm_apt_update_cache: True
php_fpm_apt_cache_valid_time: 3600
php_fpm_packages: "{{ _php_fpm_packages }}"

# Binaries
php_fpm_binary_name: "{{ _php_fpm_binary_name }}"

# Service management
php_fpm_disable_default_service: False
php_fpm_init_file_set_user: False
php_fpm_init_file_process_user: "{{ php_fpm_instance.fpm_pools[0].user }}"
php_fpm_init_file_timeout: 30

# Paths
php_fpm_binary_check_config_file_path: "{{ _php_fpm_binary_check_config_file_path }}"
php_fpm_binary_file_path: "{{ _php_fpm_binary_file_path }}"
php_fpm_config_base_path: "{{ _php_fpm_config_base_path }}"
php_fpm_init_base_path: '/etc/init.d'
php_fpm_init_file_path: "{{ _php_fpm_init_file_path }}"
php_fpm_log_base_path: "{{ _php_fpm_log_base_path }}"
php_fpm_run_base_path: "{{ _php_fpm_run_base_path }}"
php_fpm_systemd_base_path: "{{ _php_fpm_systemd_base_path | default('') }}"

# Files
php_fpm_error_log_file_path: "{{ _php_fpm_error_log_file_path }}"
php_fpm_pid_file_path: "{{ _php_fpm_pid_file_path }}"

# Permissions
php_fpm_config_owner: 'root'
php_fpm_config_group: 'root'
php_fpm_config_directories_mode: '0700'
php_fpm_config_files_mode: '0644'
php_fpm_init_files_mode: '0755'

# Instance management
php_fpm_instance:
  name: 'fpm'
  service_name: "{{ _php_fpm_service_name }}"
  fpm_config:
    - section: 'global'
      option: 'pid'
      value: "{{ php_fpm_pid_file_path }}"
    - section: 'global'
      option: 'error_log'
      value: "{{ php_fpm_error_log_file_path }}"
    - section: 'global'
      option: 'include'
      value: "{{ php_fpm_config_base_path }}/fpm/pool.d/*.conf"
  fpm_pools:
    - name: 'www'
      user: 'www-data'
      group: 'www-data'
      listen: "/var/run/{{ _php_fpm_service_name }}.sock"
      listen.owner: 'www-data'
      listen.group: 'www-data'
      chdir: '/'
  php_config: []
  php_modules: []

# php.ini configuration file configuration
php_fpm_shared_php_enabled: True
php_fpm_shared_php_force_unlink: False
php_fpm_shared_php_master_file: "{{ php_fpm_config_base_path }}/fpm/php.ini"
php_fpm_shared_php_master_confd: "{{ php_fpm_config_base_path }}/fpm/conf.d"

# Pools default settings
php_fpm_pool_defaults:
  pm: dynamic
  pm.max_children: 5
  pm.start_servers: 2
  pm.min_spare_servers: 1
  pm.max_spare_servers: 3
  pm.status_path: /status

# Logrotate configuration
php_fpm_manage_logrotate_config: True
php_fpm_logrotate_config:
  filename: "/etc/logrotate.d/{{ php_fpm_instance.service_name }}"
  log_pattern: "{{ php_fpm_error_log_file_path }}"
  options:
    - 'rotate 54'
    - 'weekly'
    - 'missingok'
    - 'notifempty'
    - 'compress'
    - 'delaycompress'
    - 'postrotate'
    - "[ -r '{{ php_fpm_pid_file_path }}' ] && kill -USR1 $(cat '{{ php_fpm_pid_file_path }}') > /dev/null"
    - 'endscript'

How ...

Force init.d service stop to only managed processes run by a user

  • Set 'php_fpm_init_file_set_user' key to True (default: False)
  • Set 'php_fpm_init_file_process_user' key with username

Disable default service and only use custom instances

  • Set 'php_fpm_disable_default_service' key to True

Use a common PHP configuration between instances

  • Set 'php_fpm_shared_php_enabled' to True (default)
  • Use a dedicated role (ex: infOpen.php) to manage php configuration.

When use this setting, conf.d folder and php.ini file will be symlinks from:

  • php_fpm_shared_php_master_file target
  • php_fpm_shared_php_master_confd target

Define custom settings for php.ini or php-fpm.conf files

You can define custom settings for php.ini or php-fpm.conf using:

  • php.ini: 'php_config' key of php_fpm_instance
  • php-fpm.conf: 'fpm_config' key of php_fpm instance

Note: PHP configuration will be managed only if 'php_fpm_shared_php_enabled' is set to False

- section: 'global'
  option: 'my_option'
  value: 'my_value'
  state: 'present'

Define pools configuration

Each instance can manage multiple pools, usng this format. Pool settings will be merged with 'php_fpm_pool_defaults' dict

- name: 'foobar'
  user: 'www-data'
  group: 'www-data'
  listen: '/var/run/php5-fpm-foobar.sock'
  listen.owner: 'www-data'
  listen.group: 'www-data'

Define php modules

Note: PHP modules will be managed only if 'php_fpm_shared_php_enabled' is set to False

- 'json'

Dependencies

None

Example Playbook

- hosts: servers
  roles:
     - { role: Temelio.php-fpm }

License

MIT

Author Information

L Machetel (for Temelio company) Fork from: Alexandre Chaussier (for Infopen company)

ansible-role-php-fpm-1's People

Contributors

achaussier avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.