1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
test_name 'Augeas puppet configuration' do
tag 'risk:medium',
'audit:medium',
'audit:acceptance',
'audit:refactor' # move to types test dir
skip_test 'requires augeas which is included in AIO' if @options[:type] != 'aio'
confine :except, platform: 'windows'
confine(:to, {}, hosts.reject { |host| host[:roles].include?('master') })
teardown do
agents.each do |agent|
on agent, "cat /tmp/puppet.conf.bak > #{agent.puppet['confdir']}/puppet.conf && rm /tmp/puppet.conf.bak"
end
end
agents.each do |agent|
step 'Backup the puppet config' do
on agent, "mv #{agent.puppet['confdir']}/puppet.conf /tmp/puppet.conf.bak"
end
step 'Create a new puppet config that has a master and agent section' do
puppet_conf = <<-CONF
[main]
CONF
on agent, "echo \"#{puppet_conf}\" >> #{agent.puppet['confdir']}/puppet.conf"
end
step 'Modify the puppet.conf file' do
manifest = <<-EOF
augeas { 'puppet agent noop mode':
context => "/files#{agent.puppet['confdir']}/puppet.conf/agent",
incl => "/etc/puppetlabs/puppet/puppet.conf",
lens => 'Puppet.lns',
changes => 'set noop true',
}
EOF
on agent, puppet_apply('--verbose'), stdin: manifest
on agent, "grep 'noop=true' #{agent.puppet['confdir']}/puppet.conf"
end
end
end
|