Skip to content

Commit

Permalink
Merge pull request #56 from palantirnet/add-pecl-yaml
Browse files Browse the repository at this point in the history
Add the yaml PHP extension from pecl
  • Loading branch information
becw authored Jan 6, 2017
2 parents 6170c78 + b4a9918 commit dd00726
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 22 deletions.
5 changes: 5 additions & 0 deletions drupalbox/CHANGELOG-0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Added

- Added the PECL YAML PHP extension to match [Acquia Cloud release 1.96](https://docs.acquia.com/release-note/acquia-cloud-196), which [caused some problems](https://docs.acquia.com/article/pecl-yaml-serialization-errors)

### Fixed

- Downgraded Solr from 4.9.1 to 4.5.1 in order to match Acquia Search
- Fixed serverspec tests for PHP extensions

## [0.2.3] - 2016-11-17

### Fixed
Expand Down
68 changes: 47 additions & 21 deletions drupalbox/tests/php_spec.rb
Original file line number Diff line number Diff line change
@@ -1,48 +1,74 @@
require_relative 'spec_helper'

describe package('php5-cli'), :if => os[:release] == '14.06' do
# Different PHP cli packages should be installed depending on the Ubuntu version.
describe package('php5.6-cli'), :if => os[:release] == '14.04' do
it { should be_installed }
end

describe package("php7.0-cli"), :if => os[:release] == '16.04' do
it { should be_installed }
end

# These PHP extensions should be installed and enabled for either PHP 5 or PHP 7.
%w{
cli
curl
gd
intl
json
mbstring
mcrypt
mysql
sqlite
memcached
xdebug
sqlite3
xml
}.each do |pkg|
describe package("php5-#{pkg}"), :if => os[:release] == '14.06' do
# The PHP extension's package should be installed from apt.
describe package("php5.6-#{pkg}"), :if => os[:release] == '14.04' do
it { should be_installed }
end

describe package("php7.0-#{pkg}"), :if => os[:release] == '16.06' do
describe package("php7.0-#{pkg}"), :if => os[:release] == '16.04' do
it { should be_installed }
end

# cli and sqlite are not valid extension names
# xdebug is checked differently, below
unless %w{cli sqlite xdebug}.include?(pkg)
context php_extension(pkg) do
it { should be_loaded }
end
# The PHP extension should be enabled.
context php_extension(pkg) do
it { should be_loaded }
end
end

if os[:release] == '14.06'
# xdebug is enabled for apache2
describe file('/etc/php5/apache2/conf.d/220-xdebug.ini') do
it { should be_symlink }
if os[:release] == '14.04'
# These packages are installed from apt, but have a different naming pattern
# than the other PHP 5.6 extensions above.
%w{
memcached
xdebug
}.each do |pkg|
# The PHP extension's package should be installed from apt.
describe package("php-#{pkg}") do
it { should be_installed }
end
end

# xdebug is disabled for cli
describe file('/etc/php5/cli/conf.d/xdebug.ini') do
it { should_not exist }
end
# xdebug is enabled for apache2
describe file('/etc/php/5.6/apache2/conf.d/20-xdebug.ini') do
it { should be_symlink }
end

# xdebug is disabled for cli
describe file('/etc/php/5.6/cli/conf.d/20-xdebug.ini') do
it { should_not exist }
end

# The memcached PHP extension is loaded.
context php_extension('memcached') do
it { should be_loaded }
end

# The yaml extension is installed from pecl, not apt, so here we just check
# that it's enabled.
context php_extension('yaml') do
it { should be_loaded }
end
end

describe 'PHP config parameters' do
Expand Down
4 changes: 3 additions & 1 deletion provisioning/roles/php5/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
- include: xdebug.yml
when: php5_xdebug_enabled == True

- include: pecl.yml

- name: Restart Apache
become: yes
service:
name: apache2
state: restarted
tags: php5
tags: php5
25 changes: 25 additions & 0 deletions provisioning/roles/php5/tasks/pecl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: Update PECL channel
become: yes
command: pecl channel-update pecl.php.net

# Ansible has a "pear" module that can manage pecl packages, but it can't
# handle interactive prompts, which this module uses.
- name: Install YAML extension from PECL
become: yes
shell: yes '' | pecl install yaml
args:
creates: /usr/lib/php/*/yaml.so
tags: php5

- name: Add YAML extension config
become: yes
template:
src: yaml.ini.j2
dest: /etc/php/5.6/mods-available/yaml.ini
tags: php5

- name: Enable YAML extension
become: true
shell: "/usr/sbin/phpenmod yaml"
tags: php5
1 change: 1 addition & 0 deletions provisioning/roles/php5/templates/yaml.ini.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension=yaml.so

0 comments on commit dd00726

Please sign in to comment.