Skip to content

Commit

Permalink
The spec helper should only run on supported platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
hunner committed Jul 22, 2014
1 parent 8bcc83f commit 81511af
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,38 @@
include apt::backports
})
end
pp = <<-EOS
$netcat = $::osfamily ? {
'RedHat' => $::operatingsystemmajrelease ? {
'7' => 'nmap-ncat',
default => 'nc',
},
'Debian' => 'netcat-openbsd',
}
package { $netcat: ensure => present, }
package { 'screen': ensure => present, }
if $::osfamily == 'RedHat' {
class { 'epel': }
service { 'iptables': ensure => stopped, }
exec { 'setenforce Permissive':
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
onlyif => 'getenforce | grep Enforcing',
if ! UNSUPPORTED_PLATFORMS.include(fact('osfamily'))
pp = <<-EOS
$netcat = $::osfamily ? {
'RedHat' => $::operatingsystemmajrelease ? {
'7' => 'nmap-ncat',
default => 'nc',
},
'Debian' => 'netcat-openbsd',
}
if $::operatingsystemmajrelease == '7' {
# For `netstat` for serverspec
package { 'net-tools': ensure => present, }
package { $netcat: ensure => present, }
package { 'screen': ensure => present, }
if $::osfamily == 'RedHat' {
class { 'epel': }
service { 'iptables': ensure => stopped, }
exec { 'setenforce Permissive':
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
onlyif => 'getenforce | grep Enforcing',
}
if $::operatingsystemmajrelease == '7' {
# For `netstat` for serverspec
package { 'net-tools': ensure => present, }
}
}
}
EOS
apply_manifest(pp, :catch_failures => true)
EOS
apply_manifest(pp, :catch_failures => true)

['5556','5557'].each do |port|
shell(%{echo 'while :; do echo "HTTP/1.1 200 OK\r\n\r\nResponse on #{port}" | nc -l #{port} ; done' > /root/script-#{port}.sh})
shell(%{/usr/bin/screen -dmS script-#{port} sh /root/script-#{port}.sh})
sleep 1
shell(%{netstat -tnl|grep ':#{port}'})
['5556','5557'].each do |port|
shell(%{echo 'while :; do echo "HTTP/1.1 200 OK\r\n\r\nResponse on #{port}" | nc -l #{port} ; done' > /root/script-#{port}.sh})
shell(%{/usr/bin/screen -dmS script-#{port} sh /root/script-#{port}.sh})
sleep 1
shell(%{netstat -tnl|grep ':#{port}'})
end
end
end
end
Expand Down

0 comments on commit 81511af

Please sign in to comment.