Last active
March 2, 2016 18:50
-
-
Save robperc/981699ecec9414428370 to your computer and use it in GitHub Desktop.
Apache Puppet Module using Puppet's best practice standards and architecture.
This file contains hidden or 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
Apache Puppet Module using Puppet's best practice standards and architecture. |
This file contains hidden or 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 apache::config inherits apache { | |
file { $index: | |
ensure => file, | |
owner => 0, | |
group => 0, | |
mode => '0644', | |
source => $config_template, | |
} | |
} |
This file contains hidden or 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
<html> | |
<head> | |
<title>Hello, World</title> | |
</head> | |
<body> | |
<h1>Hello, World</h1> | |
</body> | |
</html> |
This file contains hidden or 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 apache ( | |
$package_ensure = $apache::params::package_ensure, | |
$package_name = $apache::params::package_name, | |
$index = $apache::params::index, | |
$index_template = $apache::params::index_template, | |
$service_ensure = $apache::params::service_ensure, | |
$service_enable = $apache::params::service_enable, | |
$service_manage = $apache::params::service_manage, | |
$service_name = $apache::params::service_name | |
) inherits apache::params { | |
contain apache::install | |
contain apache::config | |
contain apache::service | |
anchor { 'apache_begin': } | |
anchor { 'apache_end': } | |
Anchor['apache_begin'] -> | |
Class['apache::install'] ~> | |
Class['apache::config'] ~> | |
Class['apache::service'] -> | |
Anchor['apache_end'] | |
} |
This file contains hidden or 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 apache::install inherits apache { | |
package {'apache': | |
ensure => $package_ensure, | |
name => $package_name, | |
} | |
} |
This file contains hidden or 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 apache::params { | |
case $::osfamily { | |
'Debian': { | |
$package_name = "apache2" | |
$service_name = "apache2" | |
} | |
'RedHat': { | |
$package_name = "httpd" | |
$service_name = "httpd" | |
} | |
} | |
$index = '/var/www/html/index.html' | |
$index_template = 'puppet:///modules/apache/index.html' | |
$package_ensure = present | |
$service_ensure = running | |
$service_enable = true | |
$service_manage = true | |
} |
This file contains hidden or 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 apache::service inherits apache { | |
if ! ($service_ensure in [ 'running', 'stopped' ]) { | |
fail('service_ensure parameter must be running or stopped') | |
} | |
if $service_manage == true { | |
service { 'apache': | |
ensure => $service_ensure, | |
enable => $service_enable, | |
name => $service_name, | |
hasstatus => true, | |
hasrestart => true, | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment