diff --git a/tasks/main.yml b/tasks/main.yml index 36750a665a6f8b9cb5cb23fcb55d4d594dbd704f..4f400b4b546562e47f4283b71951c0ec4cdf59f6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -57,3 +57,20 @@ user: root name: Composer self-update job: /usr/local/bin/composer self-update 2>&1 | logger + +- name: Check for PEAR installation + changed_when: False + ignore_errors: True + command: which pear + register: php7_which_pear + +- include: pear.yml + when: php7_which_pear|failed + +- name: Configure include_path + when: ansible_pkg_mgr == 'openbsd_pkg' + ini_file: + dest: /etc/php-7.0.ini + section: PHP + option: include_path + value: '".:/pear/lib:/var/www/pear/lib:/usr/local/share/php-7.0"' diff --git a/tasks/pear.yml b/tasks/pear.yml new file mode 100644 index 0000000000000000000000000000000000000000..b34af7c51e57d28ca0df3b260b824dc7337aa6c6 --- /dev/null +++ b/tasks/pear.yml @@ -0,0 +1,10 @@ +--- +- name: Download PEAR installer + get_url: + url: https://pear.php.net/install-pear-nozlib.phar + dest: /root/install-pear-nozlib.phar + +- name: Install PEAR + command: php /root/install-pear-nozlib.phar + args: + creates: /usr/local/bin/pear diff --git a/tests/files/check_pear.php b/tests/files/check_pear.php new file mode 100644 index 0000000000000000000000000000000000000000..81ee51e8fc84c310e9f4a864bdd913e14c88e369 --- /dev/null +++ b/tests/files/check_pear.php @@ -0,0 +1,4 @@ +<?php +require_once 'System.php'; +var_dump(class_exists('System', false)); +?> diff --git a/tests/playbook.yml b/tests/playbook.yml index fa483a9cbdce9f35ef3e6dfa311882bad89a05a6..0901607812d70bc52c83b5040f8e1124ee7f8c2b 100644 --- a/tests/playbook.yml +++ b/tests/playbook.yml @@ -20,3 +20,8 @@ - hosts: all roles: - role: php7 + post_tasks: + - name: Copy check_pear script + copy: + src: check_pear.php + dest: /root/check_pear.php diff --git a/tests/test_php7.py b/tests/test_php7.py index 388b8818bafd1ef234c440c57d223565d0106008..9affa26cdd7442911501613849106f2b662bd2e0 100644 --- a/tests/test_php7.py +++ b/tests/test_php7.py @@ -11,8 +11,15 @@ def test_composer(Command): assert Command('composer --version').stdout.startswith('Composer version') -def test_pear(Command): +def test_pear(Command, Sudo): assert Command('pear version').stdout.startswith('PEAR Version') + with Sudo(): + assert Command( + 'php /root/check_pear.php').stdout.strip() == 'bool(true)' + + +def test_pecl(Command): + assert Command('pecl version').stdout.startswith('PEAR Version') def test_php_ini(Command):