Skip to content

Instantly share code, notes, and snippets.

@three18ti
Created May 22, 2012 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save three18ti/2766140 to your computer and use it in GitHub Desktop.
Save three18ti/2766140 to your computer and use it in GitHub Desktop.
# File: cpanel/manifests/init.pp
# Class: cpanel
#
# This module manages cPanel
#
# Parameters:
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
# [Remember: No empty lines between comments and class definition]
class cpanel {
# execute this first
# file { 'config':
# path => '/etc/selinux/config',
# ensure => file,
# content => template("cpanel/selinux.config.erb"),
# }
if ! $cpanel_server {
package {
"mail-server":
ensure => absent,
"ftp-server":
ensure => absent,
"kde-desktop":
ensure => absent,
"legacy-x":
ensure => absent,
"web-server":
ensure => absent,
"web-servlet":
ensure => absent,
"system-management-wbem":
ensure => absent,
"x11":
ensure => absent,
}
exec { 'setenforce 0': }
# disable firewall
exec { "disable_firewall":
command => "chkconfig iptables off && service iptables stop",
path => "/sbin/",
}
# Download cPanel install script
exec { "download_cpanel":
command => "wget http://httpupdate.cpanel.net/latest -O /root/install_cpanel.sh",
path => "/usr/bin/",
}
exec { "install_cpanel":
command => "sh /root/install_cpanel.sh",
path => "/bin/",
}
}
}
# File: cpanel/facter/cpanel.rb
facter.add("cpanel_server") do
has_weight 100
setcode do
if File.exist? "/etc/init.d/cpanel"
"true"
else
"false"
end
end
end
root@puppet:/etc/puppet/modules# ssh sidious puppet agent --test
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at '{'; expected '}' at /etc/puppet/modules/cpanel/manifests/init.pp:23 on node sidious
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run
# cpanel/templates/selinux.config.erb
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#
#!! Managed By Puppet Class[CPanel:] !!#
#!! !!#
#!! Do not modify this file settings! !!#
#!! Your setting will be overwritten! !!#
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
# File: cpanel/manifests/yum_removegroup.pp
define yumgroup($ensure = "present", $optional = false) {
case $ensure {
present,installed: {
$pkg_types_arg = $optional ? {
true => "--setopt=group_package_types=optional,default,mandatory",
default => ""
}
exec { "Installing $name yum group":
command => "yum -y groupremove $pkg_types_arg $name",
unless => "yum groupinfo -v $name |sed '1,/^ Mandatory/d;/^ Default/,$d'",
timeout => 600,
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment