Skip to content

Commit

Permalink
Merge pull request voxpupuli#613 from wyardley/change_class_scope
Browse files Browse the repository at this point in the history
Switch to 'contain' vs. anchor pattern, and use Class['foo'] vs Class['::foo']
  • Loading branch information
alexjfisher authored Sep 7, 2017
2 parents 1d69d6a + 87bcfe3 commit 16ea855
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 27 deletions.
40 changes: 15 additions & 25 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -151,70 +151,60 @@
}
}

include '::rabbitmq::install'
include '::rabbitmq::config'
include '::rabbitmq::service'
include '::rabbitmq::management'
contain '::rabbitmq::install'
contain '::rabbitmq::config'
contain '::rabbitmq::service'
contain '::rabbitmq::management'

if $admin_enable and $service_manage {
include '::rabbitmq::install::rabbitmqadmin'

rabbitmq_plugin { 'rabbitmq_management':
ensure => present,
require => Class['rabbitmq::install'],
notify => Class['rabbitmq::service'],
provider => 'rabbitmqplugins',
}

Class['::rabbitmq::service'] -> Class['::rabbitmq::install::rabbitmqadmin']
Class['::rabbitmq::install::rabbitmqadmin'] -> Rabbitmq_exchange<| |>
Class['rabbitmq::service'] -> Class['rabbitmq::install::rabbitmqadmin']
Class['rabbitmq::install::rabbitmqadmin'] -> Rabbitmq_exchange<| |>
}

if $stomp_ensure {
rabbitmq_plugin { 'rabbitmq_stomp':
ensure => present,
require => Class['rabbitmq::install'],
notify => Class['rabbitmq::service'],
ensure => present,
notify => Class['rabbitmq::service'],
}
}

if ($ldap_auth) {
rabbitmq_plugin { 'rabbitmq_auth_backend_ldap':
ensure => present,
require => Class['rabbitmq::install'],
notify => Class['rabbitmq::service'],
ensure => present,
notify => Class['rabbitmq::service'],
}
}

if ($config_shovel) {
rabbitmq_plugin { 'rabbitmq_shovel':
ensure => present,
require => Class['rabbitmq::install'],
notify => Class['rabbitmq::service'],
provider => 'rabbitmqplugins',
}

if ($admin_enable) {
rabbitmq_plugin { 'rabbitmq_shovel_management':
ensure => present,
require => Class['rabbitmq::install'],
notify => Class['rabbitmq::service'],
provider => 'rabbitmqplugins',
}
}
}

# Anchor this as per #8040 - this ensures that classes won't float off and
# mess everything up. You can read about this at:
# http://docs.puppetlabs.com/puppet/2.7/reference/lang_containment.html#known-issues
anchor { 'rabbitmq::begin': }
anchor { 'rabbitmq::end': }

Anchor['rabbitmq::begin'] -> Class['::rabbitmq::install']
-> Class['::rabbitmq::config'] ~> Class['::rabbitmq::service']
-> Class['::rabbitmq::management'] -> Anchor['rabbitmq::end']
Class['rabbitmq::install']
-> Class['rabbitmq::config']
~> Class['rabbitmq::service']
-> Class['rabbitmq::management']

# Make sure the various providers have their requirements in place.
Class['::rabbitmq::install'] -> Rabbitmq_plugin<| |>
Class['rabbitmq::install'] -> Rabbitmq_plugin<| |>

}
2 changes: 0 additions & 2 deletions spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@
it 'we enable the admin interface by default' do
is_expected.to contain_class('rabbitmq::install::rabbitmqadmin')
is_expected.to contain_rabbitmq_plugin('rabbitmq_management').with(
'require' => 'Class[Rabbitmq::Install]',
'notify' => 'Class[Rabbitmq::Service]'
)
is_expected.to contain_archive('rabbitmqadmin').with_source('http://1.1.1.1:15672/cli/rabbitmqadmin')
Expand All @@ -209,7 +208,6 @@
it 'we enable the admin interface by default' do
is_expected.to contain_class('rabbitmq::install::rabbitmqadmin')
is_expected.to contain_rabbitmq_plugin('rabbitmq_management').with(
'require' => 'Class[Rabbitmq::Install]',
'notify' => 'Class[Rabbitmq::Service]'
)
is_expected.to contain_archive('rabbitmqadmin').with_source('http://127.0.0.1:15672/cli/rabbitmqadmin')
Expand Down

0 comments on commit 16ea855

Please sign in to comment.