Created
May 23, 2012 02:17
-
-
Save three18ti/2772865 to your computer and use it in GitHub Desktop.
puppet-configserver-firewall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Facter.add("configserver_firewall") do | |
has_weight 100 | |
setcode do | |
if File.exist? "/etc/init.d/csf" | |
"true" | |
else | |
"false" | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@puppet:~# grep configserver /var/lib/puppet/yaml/node/sidious.yaml | |
configserver_firewall: "false" | |
root@puppet:~# ssh sidious puppet agent --test | |
stdin: is not a tty | |
info: Retrieving plugin | |
info: Loading facts in /var/lib/puppet/lib/facter/cpanel.rb | |
info: Loading facts in /var/lib/puppet/lib/facter/configserver_firewall.rb | |
info: Caching catalog for sidious | |
info: Applying configuration version '1337739347' | |
notice: /Stage[main]/Cpanel/Exec[disable_selinux]/returns: executed successfully | |
notice: /Stage[main]/Configserver-firewall/Exec[enter-class-configserver-firewall]/returns: false fact: false | |
notice: /Stage[main]/Configserver-firewall/Exec[enter-class-configserver-firewall]/returns: executed successfully | |
notice: Finished catalog run in 0.23 seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class configserver-firewall { | |
exec { 'enter-class-configserver-firewall': | |
command => "echo $configserver_firewall fact: ${configserver_firewall}", | |
path => '/bin', | |
logoutput => true, | |
} | |
if ! $configserver_firewall { | |
exec { 'enter-if-block': | |
command => "echo Didn't get here ${configserver_firewall}", | |
path => '/bin', | |
logoutput => true, | |
} | |
exec { 'download_csf': | |
command => 'wget http://www.configserver.com/free/csf.tgz -O /root/csf.tgz', | |
path => '/usr/bin', | |
creates => '/root/csf.tgs', | |
logoutput => true, | |
} | |
exec { 'unzip_csf': | |
command => 'tar vxzf /root/csf.tgz', | |
path => '/bin/', | |
creates => '/root/csf/', | |
require => Exec['download_csf'], | |
logoutput => true, | |
} | |
exec { 'install_csf': | |
command => 'sh /root/csf/install.sh', | |
cwd => '/root/csf/', | |
path => '/bin/', | |
require => Exec['unzip_csf'], | |
creates => '/etc/init.d/csf', | |
logoutput => true, | |
} | |
exec { 'cleanup_install_files': | |
command => 'rm -rf /root/csf/ /root/csf.tgz', | |
path => '/bin/', | |
require => Exec['install_csf'], | |
logoutput => true, | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The above code doesn't work for me, some logical mistakes as well as syntax issue. The modified code is give below.
class configserver_firewall {$configserver_firewall fact: $ {configserver_firewall}",
exec { 'enter-class-configserver_firewall':
command => "echo
path => '/bin',
logoutput => true,
}
if $configserver_firewall == 'false' {
}
include configserver_firewall