Skip to content

Commit 7c728d8

Browse files
Helen CampbellDavidS
Helen Campbell
authored andcommitted
Replacing anchor functionality with contain
1 parent 388b2e8 commit 7c728d8

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

manifests/init.pp

+8-5
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@
6565
# Anchor this as per #8040 - this ensures that classes won't float off and
6666
# mess everything up. You can read about this at:
6767
# http://docs.puppetlabs.com/puppet/2.7/reference/lang_containment.html#known-issues
68-
anchor { 'ntp::begin': } ->
69-
class { '::ntp::install': } ->
70-
class { '::ntp::config': } ~>
71-
class { '::ntp::service': } ->
72-
anchor { 'ntp::end': }
68+
69+
contain ntp::install
70+
contain ntp::config
71+
contain ntp::service
72+
73+
Class['::ntp::install'] ->
74+
Class['::ntp::config'] ~>
75+
Class['::ntp::service']
7376
}

spec/classes/contains_spec.rb

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# To check the correct dependancies are set up for NTP.
2+
3+
require 'spec_helper'
4+
describe 'ntp' do
5+
let(:facts) {{ :is_virtual => 'false' }}
6+
let :pre_condition do
7+
'file { "foo.rb":
8+
ensure => present,
9+
path => "/etc/tmp",
10+
notify => Service["ntp"] }' end
11+
on_supported_os.select { |_, f| f[:os]['family'] != 'Solaris' }.each do |os, f|
12+
context "on #{os}" do
13+
let(:facts) do
14+
f.merge(super())
15+
end
16+
17+
it { is_expected.to compile.with_all_deps }
18+
describe "Testing the dependancies between the classes" do
19+
it { should contain_class('ntp::install') }
20+
it { should contain_class('ntp::config') }
21+
it { should contain_class('ntp::service') }
22+
it { is_expected.to contain_class('ntp::install').that_comes_before('Class[ntp::config]') }
23+
it { is_expected.to contain_class('ntp::service').that_subscribes_to('Class[ntp::config]') }
24+
it { is_expected.to contain_file('foo.rb').that_notifies('Service[ntp]') }
25+
end
26+
end
27+
end
28+
end

0 commit comments

Comments
 (0)