From 592f139c2bcaddf780725286b302641c212615d2 Mon Sep 17 00:00:00 2001 From: "Aaron M. Wartner" Date: Thu, 2 Apr 2015 23:07:04 -0400 Subject: [PATCH 1/8] Install appropriate packages --- attributes/default.rb | 4 +++- spec/recipes/default_spec.rb | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 spec/recipes/default_spec.rb diff --git a/attributes/default.rb b/attributes/default.rb index 2c67f7d6b..dd6845c4c 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -68,9 +68,11 @@ ext_php_pgsql ext_php_soap ext_php_sockets ext_php_sqlite3 ext_php_tidy ext_php_xmlrpc } - default['php']['package_options'] = "" # Use this to customise your yum or apt command + default['php']['package_options'] = "" # Use this to customise your yum or apt command default['php']['pear'] = 'pear.bat' default['php']['pecl'] = 'pecl.bat' +when 'freebsd' + default['php']['packages'] = %w( php5 ) else default['php']['conf_dir'] = '/etc/php5/cli' default['php']['ext_conf_dir'] = '/etc/php5/conf.d' diff --git a/spec/recipes/default_spec.rb b/spec/recipes/default_spec.rb new file mode 100644 index 000000000..2e6a0fd1c --- /dev/null +++ b/spec/recipes/default_spec.rb @@ -0,0 +1,17 @@ +require_relative '../spec_helper' + +describe 'php::default' do + + context 'on freebsd' do + let(:chef_run) { + ChefSpec::SoloRunner.new(platform: 'freebsd', version: '10.0') + .converge(described_recipe) + } + + it 'installs php' do + expect(chef_run).to install_package('php5') + expect(chef_run).not_to install_package('php5-cgi') + end + end + +end From ab22fdb258fca0c7360a3a1dbb669e6dbba556db Mon Sep 17 00:00:00 2001 From: "Aaron M. Wartner" Date: Thu, 2 Apr 2015 23:25:37 -0400 Subject: [PATCH 2/8] Fix paths and users --- attributes/default.rb | 4 ++++ recipes/ini.rb | 6 +++++- spec/recipes/default_spec.rb | 13 +++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index dd6845c4c..fe08846a2 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -72,6 +72,10 @@ default['php']['pear'] = 'pear.bat' default['php']['pecl'] = 'pecl.bat' when 'freebsd' + default['php']['conf_dir'] = '/usr/local/etc' + default['php']['ext_conf_dir'] = '/usr/local/etc/php' + default['php']['fpm_user'] = 'www' + default['php']['fpm_group'] = 'www' default['php']['packages'] = %w( php5 ) else default['php']['conf_dir'] = '/etc/php5/cli' diff --git a/recipes/ini.rb b/recipes/ini.rb index b3d737aac..0e13f564c 100644 --- a/recipes/ini.rb +++ b/recipes/ini.rb @@ -23,7 +23,11 @@ cookbook node['php']['ini']['cookbook'] unless platform?('windows') owner 'root' - group 'root' + if platform?('freebsd') + group 'wheel' + else + group 'root' + end mode '0644' end variables(:directives => node['php']['directives']) diff --git a/spec/recipes/default_spec.rb b/spec/recipes/default_spec.rb index 2e6a0fd1c..979ab4685 100644 --- a/spec/recipes/default_spec.rb +++ b/spec/recipes/default_spec.rb @@ -12,6 +12,19 @@ expect(chef_run).to install_package('php5') expect(chef_run).not_to install_package('php5-cgi') end + + it 'creates /usr/local/etc/php.ini' do + expect(chef_run).to create_template('/usr/local/etc/php.ini').with( + source: 'php.ini.erb', + cookbook: 'php', + owner: 'root', + group: 'wheel', + mode: '0644', + variables: { + directives: {} + } + ) + end end end From d24e817fc6c766c5abb64f6b8159caec94901eb6 Mon Sep 17 00:00:00 2001 From: "Aaron M. Wartner" Date: Thu, 2 Apr 2015 23:37:42 -0400 Subject: [PATCH 3/8] Install pear --- Berksfile | 3 +-- attributes/default.rb | 2 +- spec/recipes/default_spec.rb | 5 +++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Berksfile b/Berksfile index 10fe2efd7..e7584a427 100644 --- a/Berksfile +++ b/Berksfile @@ -1,7 +1,6 @@ -site :opscode +source 'https://supermarket.chef.io' metadata group :integration do cookbook 'apt', '~> 2.0' end - diff --git a/attributes/default.rb b/attributes/default.rb index fe08846a2..d3d7f45a4 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -76,7 +76,7 @@ default['php']['ext_conf_dir'] = '/usr/local/etc/php' default['php']['fpm_user'] = 'www' default['php']['fpm_group'] = 'www' - default['php']['packages'] = %w( php5 ) + default['php']['packages'] = %w( php5 pear ) else default['php']['conf_dir'] = '/etc/php5/cli' default['php']['ext_conf_dir'] = '/etc/php5/conf.d' diff --git a/spec/recipes/default_spec.rb b/spec/recipes/default_spec.rb index 979ab4685..5bd526681 100644 --- a/spec/recipes/default_spec.rb +++ b/spec/recipes/default_spec.rb @@ -1,6 +1,7 @@ require_relative '../spec_helper' describe 'php::default' do + let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) } context 'on freebsd' do let(:chef_run) { @@ -13,6 +14,10 @@ expect(chef_run).not_to install_package('php5-cgi') end + it 'installs pear' do + expect(chef_run).to install_package('pear') + end + it 'creates /usr/local/etc/php.ini' do expect(chef_run).to create_template('/usr/local/etc/php.ini').with( source: 'php.ini.erb', From 839ac94da36aad5d4d7a62d8472f2a378eb87782 Mon Sep 17 00:00:00 2001 From: "Aaron M. Wartner" Date: Thu, 2 Apr 2015 23:56:48 -0400 Subject: [PATCH 4/8] Integration test --- .kitchen.yml | 1 + .../default/serverspec/php_spec.rb | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 test/integration/default/serverspec/php_spec.rb diff --git a/.kitchen.yml b/.kitchen.yml index aab610ac8..ff331084d 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -9,6 +9,7 @@ platforms: - name: centos-6.5 - name: fedora-19 - name: fedora-20 + - name: freebsd-10.1 suites: - name: default diff --git a/test/integration/default/serverspec/php_spec.rb b/test/integration/default/serverspec/php_spec.rb new file mode 100644 index 000000000..3d9bdb724 --- /dev/null +++ b/test/integration/default/serverspec/php_spec.rb @@ -0,0 +1,20 @@ +require 'serverspec' + +# Required by serverspec +set :backend, :exec + +describe 'PHP' do + + it 'has php' do + expect(command('php -v').exit_status).to eq(0) + end + + it 'has the pear.php.net channel' do + expect(command('pear list-channels').stdout).to include('pear.php.net') + end + + it 'has the pecl.php.net channel' do + expect(command('pear list-channels').stdout).to include('pecl.php.net') + end + +end From 7ee66b542472e1cb4a492842a118ca596fb1bba5 Mon Sep 17 00:00:00 2001 From: "Aaron M. Wartner" Date: Mon, 13 Apr 2015 20:13:02 -0400 Subject: [PATCH 5/8] Pear depends on php56. --- attributes/default.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index d3d7f45a4..d5852b5bb 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -76,7 +76,7 @@ default['php']['ext_conf_dir'] = '/usr/local/etc/php' default['php']['fpm_user'] = 'www' default['php']['fpm_group'] = 'www' - default['php']['packages'] = %w( php5 pear ) + default['php']['packages'] = %w( php56 pear ) else default['php']['conf_dir'] = '/etc/php5/cli' default['php']['ext_conf_dir'] = '/etc/php5/conf.d' From eaed3b3747439ebeddb6f52d14acd75534554606 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 9 Jun 2015 14:31:39 +0200 Subject: [PATCH 6/8] FreeBSD php-gd needs be php56-gd --- recipes/ini.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/recipes/ini.rb b/recipes/ini.rb index 0e13f564c..5a8ef6cd2 100644 --- a/recipes/ini.rb +++ b/recipes/ini.rb @@ -22,13 +22,9 @@ source node['php']['ini']['template'] cookbook node['php']['ini']['cookbook'] unless platform?('windows') - owner 'root' - if platform?('freebsd') - group 'wheel' - else - group 'root' - end - mode '0644' + owner 'root' + group node['root_group'] + mode '0644' end variables(:directives => node['php']['directives']) end From ec6fa61c4a0cdc595bd869404b75d0518eea987f Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 9 Jun 2015 14:49:47 +0200 Subject: [PATCH 7/8] Expect to install php56 --- spec/recipes/default_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/recipes/default_spec.rb b/spec/recipes/default_spec.rb index 5bd526681..c6414e38f 100644 --- a/spec/recipes/default_spec.rb +++ b/spec/recipes/default_spec.rb @@ -10,7 +10,7 @@ } it 'installs php' do - expect(chef_run).to install_package('php5') + expect(chef_run).to install_package('php56') expect(chef_run).not_to install_package('php5-cgi') end @@ -23,7 +23,6 @@ source: 'php.ini.erb', cookbook: 'php', owner: 'root', - group: 'wheel', mode: '0644', variables: { directives: {} From 3e8c782c2e6152462c39b50f71e94612b2ddd75c Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 9 Jun 2015 14:50:36 +0200 Subject: [PATCH 8/8] GD module needs be version 56 --- recipes/module_gd.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recipes/module_gd.rb b/recipes/module_gd.rb index 148232371..629a22225 100644 --- a/recipes/module_gd.rb +++ b/recipes/module_gd.rb @@ -24,6 +24,9 @@ el5_range => 'php53-gd', 'default' => 'php-gd' }, + 'freebsd' => { + 'default' => 'php56-gd' + }, 'default' => 'php5-gd' )