diff --git a/manifests/init.pp b/manifests/init.pp index d99792e..5b3a431 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -115,7 +115,7 @@ } if $suhosin_enabled { - case $::osfamily { + case $family { 'Redhat','Centos': { diff --git a/manifests/params.pp b/manifests/params.pp index 34387a0..54f752a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -14,7 +14,14 @@ class composer::params { $composer_home = $::composer_home - case $::osfamily { + # Support Amazon Linux which is supported by RedHat family + if $::osfamily == 'Linux' and $::operatingsystem == 'Amazon' { + $family = 'RedHat' + } else { + $family = $::osfamily + } + + case $family { 'Debian': { $target_dir = '/usr/local/bin' $composer_file = 'composer' @@ -27,7 +34,7 @@ $php_bin = 'php' $suhosin_enabled = true } - 'RedHat': { + 'RedHat', 'Centos': { $target_dir = '/usr/local/bin' $composer_file = 'composer' $download_method = 'curl' @@ -40,7 +47,7 @@ $suhosin_enabled = true } default: { - fail("Unsupported platform: ${::osfamily}") + fail("Unsupported platform: ${family}") } } } diff --git a/spec/classes/composer_params_spec.rb b/spec/classes/composer_params_spec.rb index d3d12a9..914de71 100644 --- a/spec/classes/composer_params_spec.rb +++ b/spec/classes/composer_params_spec.rb @@ -1,10 +1,11 @@ require 'spec_helper' describe 'composer::params' do - ['RedHat', 'Debian'].each do |osfamily| + ['RedHat', 'Debian', 'Linux'].each do |osfamily| context "on #{osfamily} operating system family" do let(:facts) { { - :osfamily => osfamily, + :osfamily => osfamily, + :operatingsystem => 'Amazon', } } it { should compile } diff --git a/spec/classes/composer_spec.rb b/spec/classes/composer_spec.rb index d512ea2..a34e335 100644 --- a/spec/classes/composer_spec.rb +++ b/spec/classes/composer_spec.rb @@ -1,12 +1,16 @@ require 'spec_helper' describe 'composer' do - ['RedHat', 'Debian'].each do |osfamily| + ['RedHat', 'Debian', 'Linux'].each do |osfamily| case osfamily when 'RedHat' php_package = 'php-cli' php_context = '/files/etc/php.ini/PHP' suhosin_context = '/files/etc/suhosin.ini/suhosin' + when 'Linux' + php_package = 'php-cli' + php_context = '/files/etc/php.ini/PHP' + suhosin_context = '/files/etc/suhosin.ini/suhosin' when 'Debian' php_package = 'php5-cli' php_context = '/files/etc/php5/cli/php.ini/PHP' @@ -19,7 +23,8 @@ context "on #{osfamily} operating system family" do let(:facts) { { - :osfamily => osfamily, + :osfamily => osfamily, + :operatingsystem => 'Amazon' } } it { should contain_class('composer::params') } @@ -65,6 +70,17 @@ } end + context "on invalid operating system family" do + let(:facts) { { + :osfamily => 'Invalid', + :operatingsystem => 'Amazon' + } } + + it 'should not compile' do + expect { should compile }.to raise_error(/Unsupported platform: Invalid/) + end + end + context 'with custom parameters' do let(:params) { { :target_dir => '/you_sir/lowcal/been',