diff --git a/manifests/init.pp b/manifests/init.pp index 8f2a51ad4..1468860f4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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: @@ -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'], } @@ -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'], } diff --git a/manifests/service.pp b/manifests/service.pp index 2ffc8e6f9..6d78a00a3 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -21,8 +21,9 @@ } service { "nginx": ensure => running, - enable => true, + enable => true, hasstatus => true, hasrestart => true, + subscribe => Exec['rebuild-nginx-vhosts'], } } diff --git a/tests/init.pp b/tests/init.pp index 47b61b0ff..41cc19dec 100644 --- a/tests/init.pp +++ b/tests/init.pp @@ -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': } +}