Skip to content

Commit

Permalink
Now also supports Amazon Linux (RedHat)
Browse files Browse the repository at this point in the history
A new variable `$family` has bee introduced that will be set to
`RedHat` when `$::osfamily` is `'Linux'` and `$::operatingsystem`
is `'Amazon'`.

Fixes #25
  • Loading branch information
Thomas Ploch committed Feb 14, 2014
1 parent a968266 commit f44b7e5
Show file tree
Hide file tree
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
Expand Up @@ -115,7 +115,7 @@
}

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

'Redhat','Centos': {

Expand Down
13 changes: 10 additions & 3 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -27,7 +34,7 @@
$php_bin = 'php'
$suhosin_enabled = true
}
'RedHat': {
'RedHat', 'Centos': {
$target_dir = '/usr/local/bin'
$composer_file = 'composer'
$download_method = 'curl'
Expand All @@ -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 }
Expand Down
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'
Expand All @@ -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') }
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit f44b7e5

Please sign in to comment.