diff --git a/.travis.yml b/.travis.yml index d32f5f72996cea77d0ad2a2585fe8463fc0c3b94..feaf75430fabb63695d72cdfa1c29dd8441ee1c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,10 +10,8 @@ env: - VBOX_HWVIRTEX=off matrix: - TOXENV=openbsd60 - - TOXENV=trusty - - TOXENV=precise - - &jessie TOXENV=jessie - - TOXENV=wheezy + - TOXENV=xenial + - &stretch TOXENV=stretch cache: - pip @@ -37,6 +35,8 @@ notifications: matrix: fast_finish: True + allow_failures: + - env: *stretch include: - env: TOXENV: pre-commit diff --git a/README.rst b/README.rst index d9c12156efca1c71aa17563bb4adac1ab83ba048..c7509da0ef7255a61e9adcecd99459c421812248 100644 --- a/README.rst +++ b/README.rst @@ -1,11 +1,11 @@ -PHP-FPM -####### +PHP7-FPM +######## -.. image:: https://travis-ci.org/adarnimrod/php-fpm.svg?branch=master - :target: https://travis-ci.org/adarnimrod/php-fpm +.. image:: https://travis-ci.org/adarnimrod/php7-fpm.svg?branch=master + :target: https://travis-ci.org/adarnimrod/php7-fpm -Provision PHP FastCGI (FPM). Configuration of pools is done by placing templates -inside :code:`templates/php-fpm/pools/` either inside the role or relative to +Provision PHP7 FastCGI (FPM). Configuration of pools is done by placing templates +inside :code:`templates/php7-fpm/pools/` either inside the role or relative to the playbook. Requirements diff --git a/defaults/main.yml b/defaults/main.yml index f47dee4d32047269b1a53703e528a31e543fc23b..3713bad828c74d2bbc604d700acd151e5eb645a0 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,16 +1,16 @@ --- -# defaults file for php-fpm +# defaults file for php7-fpm -php_fpm_global_config: +php7_fpm_global_config: error_log: syslog - pid: '/var/run/{{ php_fpm_service[ansible_os_family] }}.pid' + pid: '/var/run/{{ php7_fpm_service[ansible_os_family] }}.pid' -php_fpm_www_pool_config: - user: '{{ php_fpm_user[ansible_os_family] }}' - group: '{{ php_fpm_user[ansible_os_family] }}' - listen: '{{ php_fpm_listen_socket[ansible_os_family] }}' - listen.owner: '{{ php_fpm_user[ansible_os_family] }}' - listen.group: '{{ php_fpm_user[ansible_os_family] }}' +php7_fpm_www_pool_config: + user: '{{ php7_fpm_user[ansible_os_family] }}' + group: '{{ php7_fpm_user[ansible_os_family] }}' + listen: '{{ php7_fpm_listen_socket[ansible_os_family] }}' + listen.owner: '{{ php7_fpm_user[ansible_os_family] }}' + listen.group: '{{ php7_fpm_user[ansible_os_family] }}' listen.mode: '0660' pm: dynamic pm.max_children: 5 @@ -20,4 +20,4 @@ php_fpm_www_pool_config: pm.status_path: /status.php ping.path: /ping.php chdir: / - chroot: '{{ php_fpm_chroot[ansible_os_family]|default("") }}' + chroot: '{{ php7_fpm_chroot[ansible_os_family]|default("") }}' diff --git a/handlers/main.yml b/handlers/main.yml index 1fd08930f7e6f97630c159625907346b5e674cc2..1691ff923d27872cd2697eac1ee4928f0b60e7ca 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,7 +1,7 @@ --- -# handlers file for php-fpm +# handlers file for php7-fpm -- name: Restart PHP-FPM +- name: Restart PHP7-FPM service: - name: '{{ php_fpm_service[ansible_os_family] }}' + name: '{{ php7_fpm_service[ansible_os_family] }}' state: restarted diff --git a/meta/main.yml b/meta/main.yml index 5e4fe3601646f4791b01888c65c66cb5fe4eb1f6..fa0032a0f187322568aa5e5556abfbc884c3038c 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,6 +1,6 @@ galaxy_info: author: Nimrod Adar - description: Provision PHP FastCGI (FPM) + description: Provision PHP7 FastCGI (FPM) company: Shore technologies license: MIT min_ansible_version: 2.3 @@ -10,13 +10,11 @@ galaxy_info: - 6.0 - name: Ubuntu versions: - - precise - - trusty + - xenial - name: Debian versions: - - jessie - - wheezy + - stretch galaxy_tags: [ php, fpm, fastcgi, http, web ] dependencies: -- src: adarnimrod.php5 - name: php5 +- src: adarnimrod.php7 + name: php7 diff --git a/molecule.yml b/molecule.yml index 65b51a86f0fdf4b7ce6c4a3cad0771205c803c84..430209d0a945d008063347eadfb9bcb799caa0c6 100644 --- a/molecule.yml +++ b/molecule.yml @@ -35,7 +35,7 @@ vagrant: - name: wheezy box: bmorg/debian-wheezy-i386 instances: - - name: php-fpm + - name: php7-fpm options: append_platform_to_hostname: yes raw_config_args: diff --git a/templates/php-fpm/pools/www.conf b/php7-fpm/pools/www.conf similarity index 100% rename from templates/php-fpm/pools/www.conf rename to php7-fpm/pools/www.conf diff --git a/tasks/main.yml b/tasks/main.yml index de2ec252a631aced5bff9b9d605aac97465d4fe3..8923b43661300eeedd698eef4f0e0e7e427298f2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,24 +1,23 @@ --- -# tasks file for php-fpm +# tasks file for php7-fpm - name: Assertions assert: that: - - ansible_os_family in php_fpm_service - - ansible_os_family in php_fpm_www_user - - ansible_os_family in php_fpm_conf - - ansible_os_family in php_fpm_listen_socket - - ansible_os_family in php_fpm_validate_config - - ansible_os_family in php_fpm_pools_dir - - ansible_os_family in php_fpm_user - - ansible_distribution_release in ['precise', 'wheezy', 'jessie', 'trusty'] or ansible_distribution_version in ['6.0'] - - php_fpm_global_config is iterable - - php_fpm_www_pool_config is iterable + - ansible_os_family in php7_fpm_service + - ansible_os_family in php7_fpm_conf + - ansible_os_family in php7_fpm_listen_socket + - ansible_os_family in php7_fpm_validate_config + - ansible_os_family in php7_fpm_pools_dir + - ansible_os_family in php7_fpm_user + - ansible_distribution_release in ['xenial', 'stretch'] or ansible_distribution_version in ['6.0'] + - php7_fpm_global_config is iterable + - php7_fpm_www_pool_config is iterable - name: APT install when: ansible_pkg_mgr == 'apt' apt: - name: php5-fpm + name: php7.0-fpm state: present update_cache: yes cache_valid_time: 3600 @@ -26,12 +25,12 @@ - name: pkg install when: ansible_pkg_mgr == 'openbsd_pkg' openbsd_pkg: - name: php-fastcgi%5.6 + name: php-fastcgi%7.0 state: present - name: Create pools directory file: - path: '{{ php_fpm_pools_dir[ansible_os_family] }}' + path: '{{ php7_fpm_pools_dir[ansible_os_family] }}' owner: root group: 0 mode: 0o0755 @@ -39,34 +38,34 @@ - name: Copy pool templates with_fileglob: - - '{{ role_path }}/templates/php-fpm/pools/*.conf' - - '{{ playbook_dir }}/templates/php-fpm/pools/*.conf' + - '{{ role_path }}/templates/php7-fpm/pools/*.conf' + - '{{ playbook_dir }}/templates/php7-fpm/pools/*.conf' template: src: '{{ item }}' - dest: '{{ php_fpm_pools_dir[ansible_os_family] }}/{{ item|basename }}' + dest: '{{ php7_fpm_pools_dir[ansible_os_family] }}/{{ item|basename }}' owner: root group: 0 mode: 0o0644 notify: - - Restart PHP-FPM + - Restart PHP7-FPM - name: Global config template: - dest: '{{ php_fpm_conf[ansible_os_family] }}' - src: php-fpm.conf + dest: '{{ php7_fpm_conf[ansible_os_family] }}' + src: php7-fpm.conf owner: root group: 0 mode: 0o0644 notify: - - Restart PHP-FPM + - Restart PHP7-FPM - name: Verify config - command: '{{ php_fpm_validate_config[ansible_os_family] }}' + command: '{{ php7_fpm_validate_config[ansible_os_family] }}' changed_when: False - name: Enable service service: - name: '{{ php_fpm_service[ansible_os_family] }}' + name: '{{ php7_fpm_service[ansible_os_family] }}' state: started enabled: yes @@ -74,4 +73,4 @@ - name: Wait for service to come up wait_for: - path: '{{ php_fpm_listen_socket[ansible_os_family] }}' + path: '{{ php7_fpm_listen_socket[ansible_os_family] }}' diff --git a/templates/php-fpm.conf b/templates/php-fpm.conf deleted file mode 100644 index af379970f0eeb75e63aef7d41be6d3498b2d6e9f..0000000000000000000000000000000000000000 --- a/templates/php-fpm.conf +++ /dev/null @@ -1,5 +0,0 @@ -[global] -{% for key, value in php_fpm_global_config.iteritems() %} -{{ key }} = {{ value }} -{% endfor %} -include = {{ php_fpm_pools_dir[ansible_os_family] }}/*.conf diff --git a/templates/php7-fpm.conf b/templates/php7-fpm.conf new file mode 100644 index 0000000000000000000000000000000000000000..921ddf77a9fdc3fbb4860a69146e14e51e08aa54 --- /dev/null +++ b/templates/php7-fpm.conf @@ -0,0 +1,5 @@ +[global] +{% for key, value in php7_fpm_global_config.iteritems() %} +{{ key }} = {{ value }} +{% endfor %} +include = {{ php7_fpm_pools_dir[ansible_os_family] }}/*.conf diff --git a/templates/php7-fpm/pools/www.conf b/templates/php7-fpm/pools/www.conf new file mode 100644 index 0000000000000000000000000000000000000000..a16e97fca011bca5925520d44380cf36523fa0c3 --- /dev/null +++ b/templates/php7-fpm/pools/www.conf @@ -0,0 +1,4 @@ +[www] +{% for key, value in php7_fpm_www_pool_config.iteritems() if not value == '' %} +{{ key }} = {{ value }} +{% endfor %} diff --git a/tests/playbook.yml b/tests/playbook.yml index 07c1abbc95ffb5c9608b7c184cdd93539d1c1e02..fa95fa4cc121f87395525e2c1d47aa8408aac9d1 100644 --- a/tests/playbook.yml +++ b/tests/playbook.yml @@ -1,5 +1,5 @@ --- -- hosts: php-fpm-openbsd* +- hosts: php7-fpm-openbsd* gather_facts: false roles: - openbsd-bootstrap @@ -8,7 +8,7 @@ users_use_sudo: True users_lock_root_ssh: False -- hosts: php-fpm-xenial, php-fpm-wheezy +- hosts: php7-fpm-xenial, php-fpm-wheezy gather_facts: false roles: - debian-bootstrap @@ -20,7 +20,7 @@ - hosts: all roles: - role: nginx - - role: php-fpm + - role: php7-fpm post_tasks: - name: Install cURL package: diff --git a/tests/templates/nginx/sites-enabled/php-fpm.conf b/tests/templates/nginx/sites-enabled/php7-fpm.conf similarity index 70% rename from tests/templates/nginx/sites-enabled/php-fpm.conf rename to tests/templates/nginx/sites-enabled/php7-fpm.conf index 8a770932e9a6fa3a1db0b49e1e788526beafb58f..d8af156b5202d9419391a71911e438c95e01a0b0 100644 --- a/tests/templates/nginx/sites-enabled/php-fpm.conf +++ b/tests/templates/nginx/sites-enabled/php7-fpm.conf @@ -5,7 +5,7 @@ server { root /var/www/html; location ~ [^/]\.php(/|$) { include fastcgi_params; - fastcgi_pass unix:{{ php_fpm_listen_socket_chrooted[ansible_os_family]|default(php_fpm_listen_socket[ansible_os_family]) }}; + fastcgi_pass unix:{{ php7_fpm_listen_socket_chrooted[ansible_os_family]|default(php7_fpm_listen_socket[ansible_os_family]) }}; {# {% if ansible_os_family == 'OpenBSD' %} #} fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; {# {% endif %} #} diff --git a/tests/test_php-fpm.py b/tests/test_php7-fpm.py similarity index 70% rename from tests/test_php-fpm.py rename to tests/test_php7-fpm.py index 284261bb1e5421552556d4e26ce5ca92ea6c0f02..25f2cad05c2f0fbe50159413fccb60b1414b9d8a 100644 --- a/tests/test_php-fpm.py +++ b/tests/test_php7-fpm.py @@ -4,16 +4,16 @@ import json testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all') -def test_php_fpm_service(Service, SystemInfo, File, Sudo): +def test_php7_fpm_service(Service, SystemInfo, File, Sudo): if SystemInfo.type == 'openbsd': - service = Service('php56_fpm') + service = Service('php70_fpm') socket = File('/var/www/run/php-fpm.sock') user = 'www' elif SystemInfo.type == 'linux' and SystemInfo.distribution in [ 'debian', 'ubuntu' ]: - service = Service('php5-fpm') - socket = File('/var/run/php5-fpm.sock') + service = Service('php7.0-fpm') + socket = File('/run/php/php7.0-fpm.sock') user = 'www-data' with Sudo(): assert socket.is_socket @@ -27,27 +27,27 @@ def test_php_fpm_service(Service, SystemInfo, File, Sudo): pass -def test_phpinfo(Command): - assert 'PHP Version 5' in Command( +def test_php7info(Command): + assert 'PHP Version 7.0' in Command( 'curl http://localhost/phpinfo.php').stdout -def test_php_fpm_config(Command, Sudo, SystemInfo): +def test_php7_fpm_config(Command, Sudo, SystemInfo): with Sudo(): if SystemInfo.type == 'openbsd': - assert Command('php-fpm-5.6 -t').rc == 0 + assert Command('php-fpm-7.0 -t').rc == 0 elif SystemInfo.type == 'linux' and SystemInfo.distribution in [ 'debian', 'ubuntu' ]: - assert Command('php5-fpm -t').rc == 0 + assert Command('php-fpm7.0 -t').rc == 0 -def test_php_fpm_status(Command): +def test_php7_fpm_status(Command): status = json.loads( Command('curl http://localhost/status.php?json').stdout) assert status['pool'] == 'www' assert status['process manager'] == 'dynamic' -def test_php_fpm_ping(Command): +def test_php7_fpm_ping(Command): assert 'pong' in Command('curl http://localhost/ping.php').stdout diff --git a/tox.ini b/tox.ini index 09d79c0d9c01f698cb463205bc878777af955951..8585b01244ec76a15b34aa190877cc7e937334c7 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] skip_install = True skipsdist = True -envlist = openbsd60,trusty,precise,jessie,wheezy +envlist = openbsd60,xenial,stretch [testenv] envdir = {toxinidir}/.tox/molecule diff --git a/vars/main.yml b/vars/main.yml index c2e7e45b5dc1a5513cad250c56676d3ab7c82228..af1167db563419ae5067c73445aeaa1a0fe532de 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,36 +1,32 @@ --- -# vars file for php-fpm +# vars file for php7-fpm -php_fpm_service: - OpenBSD: php56_fpm - Debian: php5-fpm +php7_fpm_service: + OpenBSD: php70_fpm + Debian: php7.0-fpm -php_fpm_conf: +php7_fpm_conf: OpenBSD: /etc/php-fpm.conf - Debian: /etc/php5/fpm/php-fpm.conf + Debian: /etc/php/7.0/fpm/php-fpm.conf -php_fpm_www_user: - OpenBSD: www - Debian: www-data - -php_fpm_listen_socket: +php7_fpm_listen_socket: OpenBSD: /var/www/run/php-fpm.sock - Debian: /var/run/php5-fpm.sock + Debian: /run/php/php7.0-fpm.sock -php_fpm_listen_socket_chrooted: +php7_fpm_listen_socket_chrooted: OpenBSD: run/php-fpm.sock -php_fpm_validate_config: - OpenBSD: php-fpm-5.6 -t - Debian: php5-fpm -t +php7_fpm_validate_config: + OpenBSD: php-fpm-7.0 -t + Debian: php-fpm7.0 -t -php_fpm_pools_dir: +php7_fpm_pools_dir: OpenBSD: /etc/php-fpm.pools - Debian: /etc/php5/fpm/pool.d + Debian: /etc/php/7.0/fpm/pool.d -php_fpm_user: +php7_fpm_user: OpenBSD: www Debian: www-data -php_fpm_chroot: +php7_fpm_chroot: OpenBSD: /var/www