Puppet Class: generic
- Defined in:
- manifests/init.pp
Overview
Class: generic
This module is applied to ALL nodes
Requires:
class $operatingsystem
class backup
class certs
class dnsclient
class facter
class hosts
class logrotate
class logwatch
class postfix
class puppet
class rsync
class snmp
class ssh
class sudo
class syslog_ng::client
class utils
class vim
$lsbProvider be set in site manifest
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'manifests/init.pp', line 25
class generic {
include $operatingsystem
include backup
include certs
include dnsclient
include facter
include hosts
include logrotate
include logwatch
include postfix
include puppet
include rsync
include snmp
include ssh
include sudo
include syslog_ng::client
include utils
include vim
file {
# our hierarchical namespace as registered with LANANA
"/opt/$lsbProvider":
mode => 755,
ensure => directory;
# directory structure that we use everywhere
"/data":
mode => 755,
ensure => directory;
} # file
# Definition: mkuser
#
# mkuser creates a user/group that can be realized in the module that employs it
#
# Parameters:
# $uid - UID of user
# $gid - GID of user, defaults to UID
# $group - group name of user, defaults to username
# $shell - user's shell, defaults to "/bin/bash"
# $home - home directory, defaults to /home/<username>
# $ensure - present by default
# $managehome - true by default
# $dotssh - creates ~/.ssh by default
# $comment - comment field for passwdany additional groups the user should be associated with
# $groups - any additional groups the user should be associated with
# $password - defaults to "!!"
# $symlink - use a symlink for the home directory
# $mode - mode of home directory, defaults to 700
#
# Actions: creates a user/group
#
# Requires:
# $uid
#
# Sample Usage:
# # create apachehup user and realize it
# @mkuser { "apachehup":
# uid => "32001",
# gid => "32001",
# home => "/home/apachehup",
# managehome => "true",
# comment => "Apache Restart User",
# dotssh => "true",
# } # @mkuser
#
# realize Generic::Mkuser[apachehup]
#
define mkuser ($uid, $gid = undef, $group = undef, $shell = "/bin/bash", $home = undef, $ensure = "present", $managehome = true, $dotssh = "ensure", $comment = "created via puppet", $groups = undef, $password = "!!", $symlink = undef, $mode = undef) {
# if gid is unspecified, match with uid
if $gid {
$mygid = $gid
} else {
$mygid = $uid
}
# if home is unspecified, use /home/<username>
if $home {
$myhome = $home
} else {
$myhome = "/home/$name"
}
# if group is unspecified, use the username
if $group {
$mygroup = $group
} else {
$mygroup = $name
}
# create user
user { "$name":
uid => "$uid",
gid => "$mygid",
shell => "$shell",
groups => "$groups",
password => "$password",
managehome => "$managehome",
home => "$myhome",
ensure => "$ensure",
comment => "$comment",
require => Group["$name"],
} # user
group { "$name":
gid => "$mygid",
name => "$mygroup",
ensure => "$ensure",
} # group
# if link is passed a symlink will be used for ensure => , else we will make it a directory
if $symlink {
$myEnsure = $symlink
} else {
$myEnsure = "directory"
}
# if mode is unspecified, use 700
if $mode {
$myMode = $mode
} else {
$myMode = "700"
}
# create home dir
file { "$myhome":
ensure => $myEnsure,
mode => $myMode,
owner => $name,
group => $name,
require => User["$name"],
} # file
# create ~/.ssh
case $dotssh {
"ensure","true": {
file { "$myhome/.ssh":
ensure => directory,
mode => "700",
owner => $name,
group => $name,
require => User["$name"],
} # file
} # 'ensure' or 'true'
} # case
} # define mkuser
# Definition: mkgroup
#
# mkgroup creates a group that can be realized in the module that employs it
#
# Parameters:
# $gid - GID of user, defaults to UID
#
# Actions: creates a group
#
# Requires:
# $gid
#
# Sample Usage:
# # create systems group and realize it
# @mkgroup { "systems":
# gid => "30000",
# } # @mkgroup
#
# realize Generic::Mkgroup[systems]
#
define mkgroup ($gid) {
group { "$name":
ensure => present,
gid => "$gid",
name => "$name",
} # group
} # define mkgroup
# this is all listed here and realized within the module with 'realize Generic::Mkuser[username]'
# it is here and not in the modules, so that we have one place to list all the uid/gid's
# to avoid using the same numbers
#
# please keep sorted by UID
@mkuser {
#"gh":
# uid => "32000",
# gid => "32000",
# home => "/home/gh",
# comment => "garrett honeycutt";
"apachehup":
uid => "32001",
gid => "32001",
home => "/home/apachehup",
managehome => "true",
comment => "Apache Restart User",
dotssh => "true";
"memcached":
uid => "32002",
gid => "32002",
dotssh => "false";
"rt":
uid => "32003",
gid => "32003",
home => "/home/rt",
managehome => "false",
comment => "RT User",
dotssh => "false";
"puppetreposvn":
uid => "32005",
gid => "32005";
"puppetreposvn-master":
uid => "32006",
gid => "32006";
"dnsreposvn":
uid => "32007",
groups => [ "named" ];
"scrumworks":
uid => "33000",
gid => "33000",
home => "/home/scrumworks",
managehome => "false",
comment => "ScrumWorks daemon",
dotssh => "false";
} # @mkuser
# this is all listed here and realized within the module with 'realize Generic::Mkgroup[groupname]'
# it is here and not in the modules, so that we have one place to list all the uid/gid's
# to avoid using the same numbers
#
# please keep sorted by GID
@mkgroup {
"systems":
gid => "30000",
#"marketing":
# gid => "30001";
#"dev":
# gid => "30002";
#"finance":
# gid => "30003";
#"hr":
# gid => "30004";
#"cs":
# gid => "30005";
#"qa":
# gid => "30006";
#"bizdev":
# gid => "30007";
#full time employees
#"fte":
# gid => "30008";
#"employee":
# gid => "30009";
} # @mkgroup
# create the systems group everywhere
realize Mkgroup[systems]
}
|