From fcd668dee75364ca701880a175da33617198ffc3 Mon Sep 17 00:00:00 2001 From: Thom Toogood Date: Tue, 14 Jun 2016 08:00:20 +1000 Subject: [PATCH] Allow easy switching of PHP versions. (#226) --- .../ansible/config/beetbox.config.yml | 11 ++++- .../roles/beetbox-common/meta/main.yml | 2 +- .../ansible/roles/beetbox-init/tasks/main.yml | 1 - .../roles/beetbox-php-ppa/tasks/main.yml | 46 +++++++++++++++---- 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/provisioning/ansible/config/beetbox.config.yml b/provisioning/ansible/config/beetbox.config.yml index 8eac7cc..465ce3f 100644 --- a/provisioning/ansible/config/beetbox.config.yml +++ b/provisioning/ansible/config/beetbox.config.yml @@ -256,6 +256,7 @@ php_display_startup_errors: "On" php_enable_php_fpm: 1 php_realpath_cache_size: "1024K" php_sendmail_path: "/usr/sbin/ssmtp -t" +php_enable_apc: no php_opcache_enabled_in_ini: true php_opcache_memory_consumption: "192" php_opcache_max_accelerated_files: 4096 @@ -272,7 +273,7 @@ php_extension_conf_paths: php_fpm_daemon: "php{{ php_version }}-fpm" php_fpm_conf_path: "/etc/php/{{ php_version }}/fpm" php_mysql_package: "php{{ php_version }}-mysql" -php_memcached_package: "php{{ php_version }}-memcached" +php_memcached_package: "php-memcache" php55_packages: - php5.5 - php5.5-curl @@ -285,12 +286,18 @@ php55_packages: - libapache2-mod-php5.5 php56_packages: - php5.6 + - php5.6-cli + - php5.6-common - php5.6-curl - php5.6-dev - php5.6-fpm - php5.6-gd - php5.6-intl + - php5.6-json - php5.6-mbstring + - php5.6-mysql + - php5.6-opcache + - php5.6-readline - php5.6-xml - libapache2-mod-php5.6 php70_packages: @@ -355,4 +362,4 @@ mailhog_daemonize_bin_path: /usr/sbin/daemonize # Other config. known_hosts_path: ~/.ssh/known_hosts -workspace: "{{ beet_home }}/workspace" +workspace: "{{ beet_home }}/workspace/{{ php_version }}" diff --git a/provisioning/ansible/roles/beetbox-common/meta/main.yml b/provisioning/ansible/roles/beetbox-common/meta/main.yml index 394ff48..cb69d20 100644 --- a/provisioning/ansible/roles/beetbox-common/meta/main.yml +++ b/provisioning/ansible/roles/beetbox-common/meta/main.yml @@ -16,7 +16,7 @@ dependencies: # Conditionally-installed roles. - { role: ANXS.postgresql, when: "{{ installed_extras_postgresql }}" } - { role: geerlingguy.memcached, when: "{{ installed_extras_memcached }}" } - - { role: geerlingguy.php-memcached, when: "{{ installed_extras_memcached }} and ({{ php_version }} != '7.0')" } + - { role: geerlingguy.php-memcached, when: "{{ installed_extras_memcached }}" } - { role: geerlingguy.php-xdebug, when: "{{ installed_extras_xdebug }}" } - { role: geerlingguy.php-xhprof, when: "{{ installed_extras_xhprof }}" } - { role: geerlingguy.blackfire, when: "{{ installed_extras_blackfire }}" } diff --git a/provisioning/ansible/roles/beetbox-init/tasks/main.yml b/provisioning/ansible/roles/beetbox-init/tasks/main.yml index 1b52af6..4f78e57 100644 --- a/provisioning/ansible/roles/beetbox-init/tasks/main.yml +++ b/provisioning/ansible/roles/beetbox-init/tasks/main.yml @@ -38,7 +38,6 @@ path: "{{ workspace }}" state: directory mode: 0775 - become: no when: workspace is defined - name: Set SSH home directory. diff --git a/provisioning/ansible/roles/beetbox-php-ppa/tasks/main.yml b/provisioning/ansible/roles/beetbox-php-ppa/tasks/main.yml index d74b2fd..972310c 100644 --- a/provisioning/ansible/roles/beetbox-php-ppa/tasks/main.yml +++ b/provisioning/ansible/roles/beetbox-php-ppa/tasks/main.yml @@ -1,22 +1,38 @@ --- -- set_fact: - php_ppa: ppa:ondrej/php - when: php_version == '5.5' or php_version == '5.6' or php_version == '7.0' - - name: Add repository for PHP. apt_repository: - repo: "{{ php_ppa }}" + repo: "ppa:ondrej/php" update_cache: yes - name: Purge PHP version packages. apt: name: "{{ item }}" state: absent - when: "'php{{ php_version }}' != item" + purge: yes + force: yes + when: "'{{ php_version }}' not in item" + with_items: + - "{{ php55_packages }} + {{ php56_packages }} + {{ php70_packages }}" + register: php_purge + +- name: Purge depreciated memcached package. + apt: + name: "{{ item }}" + state: absent + purge: yes + force: yes + when: php_purge.changed + with_items: + - "php-memcached" + +- name: Purge PHP modules directory. + file: + path: "{{ item }}" + state: absent + when: php_purge.changed with_items: - - php5.5 - - php5.6 - - php7.0 + - "/usr/lib/php5/modules" + - "/usr/lib/php/modules" - name: Set PHP 5.5 packages. set_fact: @@ -33,6 +49,8 @@ php_packages: "{{ php70_packages }}" when: php_version == '7.0' +# PHP 7 Support + - name: Set default PHP7 mysql package. set_fact: php_mysql_package: php7.0-mysql @@ -47,3 +65,13 @@ set_fact: php_fpm_pool_conf_path: "/etc/php/7.0/fpm/pool.d/www.conf" when: (php_version == '7.0') and (php_fpm_pool_conf_path is not defined) + +- name: Set xhprof_download_url for PHP7. + set_fact: + xhprof_download_url: https://github.com/RustJason/xhprof/archive/php7.zip + when: php_version == '7.0' + +- name: Set xhprof_download_folder_name for PHP7. + set_fact: + xhprof_download_folder_name: xhprof-php7 + when: php_version == '7.0'