Skip to content

Commit

Permalink
Merge pull request voxpupuli#4 from jeffmccune/feedback/master/contai…
Browse files Browse the repository at this point in the history
…nment_with_anchors

Contain all classes within Class[nginx]
  • Loading branch information
jamtur01 committed Jan 5, 2012
2 parents a6f98a8 + c1166fd commit 14d6281
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
22 changes: 14 additions & 8 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
#
# Requires:
# puppetlabs-stdlib - https://github.com/puppetlabs/puppetlabs-stdlib
#
#
# Packaged NGINX
# - RHEL: EPEL or custom package
# - Debian/Ubuntu: Default Install or custom package
# - SuSE: Default Install or custom package
#
# stdlib
# - puppetlabs-stdlib module >= 0.1.6
# - plugin sync enabled to obtain the anchor type
#
# Sample Usage:
#
# The module works with sensible defaults:
Expand All @@ -25,15 +29,10 @@
# include nginx
# }
class nginx {

class { 'stdlib': }

anchor{ 'nginx::begin':
before => Class['nginx::package'],
notify => Class['nginx::service'],
}

class { 'nginx::package':
class { 'nginx::package':
notify => Class['nginx::service'],
}

Expand All @@ -44,6 +43,13 @@

class { 'nginx::service': }

# Allow the end user to establish relationships to the "main" class
# and preserve the relationship to the implementation classes through
# a transitive relationship to the composite class.
anchor{ 'nginx::begin':
before => Class['nginx::package'],
notify => Class['nginx::service'],
}
anchor { 'nginx::end':
require => Class['nginx::service'],
}
Expand Down
3 changes: 2 additions & 1 deletion manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
}
service { "nginx":
ensure => running,
enable => true,
enable => true,
hasstatus => true,
hasrestart => true,
subscribe => Exec['rebuild-nginx-vhosts'],
}
}
11 changes: 9 additions & 2 deletions tests/init.pp
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
include nginx

# The notify before should always come BEFORE all resources
# managed by the nginx class
# and the notify last should always come AFTER all resources
# managed by the nginx class.
node default {
notify { 'before': }
-> class { 'nginx': }
-> notify { 'last': }
}

0 comments on commit 14d6281

Please sign in to comment.