Created
March 13, 2012 22:27
-
-
Save bcarpio/2032220 to your computer and use it in GitHub Desktop.
Puppet Class Relationship Using New Relationship Syntax
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
manifests/site.pp: | |
import "classes/*.pp" | |
import "nodes/*.pp" | |
manifests/classes/base.pp | |
class base { | |
$role = regsubst($ec2_userdata, '.*role=(.*).*', '\1') | |
notify {"the role is: ${role}": } | |
Class['baseapps']<-Class['admin_users'] | |
case $operatingsystem { | |
"Fedora", "CentOS", "RedHat": { $osver = $lsbdistrelease } | |
} | |
case $operatingsystem { | |
"Fedora", "CentOS", "RedHat": { | |
include baseapps, admin_users | |
} | |
} | |
include "roles::${role}" | |
modules/baseapps/manifests/init.pp | |
class baseapps { | |
Class['baseapps::install']->Class['baseapps::config']->Class['baseapps::service'] | |
include baseapps::install, baseapps::config | |
} | |
modules/baseapps/manifests/install.pp | |
class baseapps::install { | |
include centos_repo | |
include ntp, postfix, ssh, sudo, puppet, yum_updatesd, pam | |
} | |
modules/baseapps/manifests/config.pp | |
class baseapps::config { | |
# configure the hosts file | |
include hosts | |
# configure the profile.d directory | |
include profile | |
} | |
modules/centos_repo/manifests/service.pp | |
class baseapps::service { | |
service { portmap: | |
name => "portmap", | |
enable => false, | |
ensure => stopped, | |
} | |
} | |
modules/centos_repo/manifests/init.pp | |
class centos_repo { | |
Class['baseapps::service']->Class['centos_repo::config'] | |
include centos_repo::config | |
} | |
modules/centos_repo/manifests/config.pp | |
class centos_repo::config { | |
file { "centos_repo": | |
name => "/etc/yum.repos.d/CentOS-Base.repo", | |
source => [ "puppet:///modules/centos_repo/${base::role}-CentOS-Base.repo", "puppet:///modules/centos_repo/CentOS-Base.repo" ], | |
mode => 644, | |
owner => root, | |
group => root, | |
} | |
file { "/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5": | |
source => "puppet:///modules/centos_repo/RPM-GPG-KEY-CentOS-5", | |
mode => 644, | |
owner => root, | |
group => root, | |
require => File["centos_repo"] | |
} | |
} | |
class roles::web { | |
Class['baseapps::service']->Class['roles::web'] | |
Class['centos_repo::config']->Class['utils::web'] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment