Skip to content

Commit

Permalink
Fix CentOS 5 support using webtatic repository to install PHP 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
zuazo committed Sep 23, 2015
1 parent 22d7d2c commit afeb353
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Requirements
* postfix
* postgresql
* ssl_certificate
* yum-webtatic

## Required Applications

Expand Down
1 change: 1 addition & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
depends 'postfix', '~> 3.0'
depends 'postgresql', '~> 3.4'
depends 'ssl_certificate', '~> 1.1'
depends 'yum-webtatic', '~> 0.4.0'

recipe 'owncloud::default', 'Installs and configures ownCloud'

Expand Down
15 changes: 11 additions & 4 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
php_pkgs << 'php5-mysql' if dbtype == 'mysql'
php_pkgs << 'php5-pgsql' if dbtype == 'pgsql'
when 'rhel'
if node['platform'] != 'amazon' && node['platform_version'].to_f < 6
php_pkgs = %w(php53-gd php53-mbstring php53-xml php53-intl samba-client)
php_pkgs << 'php53-mysql' if dbtype == 'mysql'
php_pkgs << 'php53-pgsql' if dbtype == 'pgsql'
if node['platform'] != 'amazon' && node['platform_version'].to_f < 7
php_pkgs = %w(php54w-gd php54w-mbstring php54w-xml php54w-intl samba-client)
php_pkgs << 'php54w-mysql' if dbtype == 'mysql'
php_pkgs << 'php54w-pgsql' if dbtype == 'pgsql'
if dbtype == 'sqlite'
fail(
"SQLite database type not supported on #{node['platform']}"\
Expand Down Expand Up @@ -128,6 +128,13 @@
end
end

if node['platform_family'] == 'rhel' && node['platform_version'].to_i < 7
include_recipe 'yum-webtatic'
node.default['php']['packages'] =
%w(php54w php54w-devel php54w-cli php54w-pear)
node.default['php']['mysql']['package'] = 'php54w-mysql'
end

include_recipe 'php'

php_pkgs.each do |pkg|
Expand Down
87 changes: 84 additions & 3 deletions test/unit/recipes/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@
.with_key('E5267A6C')
.with_deb_src(true)
end

it 'does not include yum-webtatic recipe' do
expect(chef_run).to_not include_recipe('yum-webtatic')
end

it 'does not change PHP 5.4 packages in attributes' do
chef_run
expect(node['php']['packages'])
.to_not eq(%w(php54w php54w-devel php54w-cli php54w-pear))
expect(node['php']['mysql']['package']).to_not eq('php54w-mysql')
end
end # context on Ubuntu 12.04

context 'on Ubuntu 14.04' do
Expand All @@ -136,8 +147,70 @@
it 'does not add ondrej-php5-oldstable apt repository' do
expect(chef_run).to_not add_apt_repository('ondrej-php5-oldstable')
end

it 'does not include yum-webtatic recipe' do
expect(chef_run).to_not include_recipe('yum-webtatic')
end

it 'does not change PHP 5.4 packages in attributes' do
chef_run
expect(node['php']['packages'])
.to_not eq(%w(php54w php54w-devel php54w-cli php54w-pear))
expect(node['php']['mysql']['package']).to_not eq('php54w-mysql')
end
end # context on Ubuntu 14.04

context 'on CentOS 5' do
let(:chef_runner) do
ChefSpec::SoloRunner.new(platform: 'centos', version: '5.10')
end

it 'includes yum-webtatic recipe' do
expect(chef_run).to include_recipe('yum-webtatic')
end

it 'changes PHP 5.4 packages in attributes' do
chef_run
expect(node['php']['packages'])
.to eq(%w(php54w php54w-devel php54w-cli php54w-pear))
expect(node['php']['mysql']['package']).to eq('php54w-mysql')
end
end # context on CentOS 5

context 'on CentOS 6' do
let(:chef_runner) do
ChefSpec::SoloRunner.new(platform: 'centos', version: '6.0')
end

it 'includes yum-webtatic recipe' do
expect(chef_run).to include_recipe('yum-webtatic')
end

it 'changes PHP 5.4 packages in attributes' do
chef_run
expect(node['php']['packages'])
.to eq(%w(php54w php54w-devel php54w-cli php54w-pear))
expect(node['php']['mysql']['package']).to eq('php54w-mysql')
end
end # context on CentOS 6

context 'on CentOS 7' do
let(:chef_runner) do
ChefSpec::SoloRunner.new(platform: 'centos', version: '7.0')
end

it 'does not include yum-webtatic recipe' do
expect(chef_run).to_not include_recipe('yum-webtatic')
end

it 'does not change PHP 5.4 packages in attributes' do
chef_run
expect(node['php']['packages'])
.to_not eq(%w(php54w php54w-devel php54w-cli php54w-pear))
expect(node['php']['mysql']['package']).to_not eq('php54w-mysql')
end
end # context on CentOS 7

it 'includes php recipe' do
expect(chef_run).to include_recipe('php')
end
Expand All @@ -150,12 +223,20 @@
'pgsql' => %w(php5-pgsql)
},
'centos@5.10' => {
'core' => %w(php53-gd php53-mbstring php53-xml php53-intl samba-client),
'core' =>
%w(php54w-gd php54w-mbstring php54w-xml php54w-intl samba-client),
'sqlite' => %w(), # Raises an exception
'mysql' => %w(php53-mysql),
'pgsql' => %w(php53-pgsql)
'mysql' => %w(php54w-mysql),
'pgsql' => %w(php54w-pgsql)
},
'centos@6.0' => {
'core' =>
%w(php54w-gd php54w-mbstring php54w-xml php54w-intl samba-client),
'sqlite' => %w(),
'mysql' => %w(php54w-mysql),
'pgsql' => %w(php54w-pgsql)
},
'centos@7.0' => {
'core' => %w(php-gd php-mbstring php-xml php-intl samba-client),
'sqlite' => %w(php-pdo),
'mysql' => %w(php-mysql),
Expand Down

0 comments on commit afeb353

Please sign in to comment.