Skip to content

Commit

Permalink
Merge pull request #31 from tPl0ch/feature-amazon-linux-support
Browse files Browse the repository at this point in the history
Now also supports Amazon Linux (RedHat)
tPl0ch committed Feb 14, 2014
2 parents a968266 + f44b7e5 commit 7bb1fb4
Showing 4 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
@@ -115,7 +115,7 @@
}

if $suhosin_enabled {
case $::osfamily {
case $family {

'Redhat','Centos': {

13 changes: 10 additions & 3 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -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}")
}
}
}
5 changes: 3 additions & 2 deletions spec/classes/composer_params_spec.rb
Original file line number Diff line number Diff line change
@@ -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 }
20 changes: 18 additions & 2 deletions spec/classes/composer_spec.rb
Original file line number Diff line number Diff line change
@@ -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',

0 comments on commit 7bb1fb4

Please sign in to comment.