beaker-puppet 1.29.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.github/workflows/release.yml +3 -3
  4. data/.github/workflows/test.yml +28 -7
  5. data/.github_changelog_generator +3 -0
  6. data/.rubocop.yml +5 -0
  7. data/.rubocop_todo.yml +887 -0
  8. data/CHANGELOG.md +50 -0
  9. data/CODEOWNERS +1 -0
  10. data/Gemfile +5 -20
  11. data/README.md +4 -13
  12. data/Rakefile +64 -169
  13. data/acceptance/config/acceptance-options.rb +3 -3
  14. data/acceptance/config/gem/acceptance-options.rb +8 -8
  15. data/acceptance/config/git/acceptance-options.rb +8 -8
  16. data/acceptance/config/pkg/acceptance-options.rb +7 -7
  17. data/acceptance/pre_suite/gem/install.rb +6 -6
  18. data/acceptance/pre_suite/git/install.rb +22 -22
  19. data/acceptance/pre_suite/pkg/install.rb +3 -3
  20. data/acceptance/tests/backwards_compatible.rb +6 -7
  21. data/acceptance/tests/clone_git_repo_on_test.rb +12 -13
  22. data/acceptance/tests/create_tmpdir_on_test.rb +13 -9
  23. data/acceptance/tests/install_smoke_test.rb +5 -4
  24. data/acceptance/tests/stub_host.rb +11 -10
  25. data/acceptance/tests/web_helpers_test.rb +11 -10
  26. data/beaker-puppet.gemspec +17 -24
  27. data/bin/beaker-puppet +2 -4
  28. data/lib/beaker-puppet/helpers/facter_helpers.rb +9 -7
  29. data/lib/beaker-puppet/helpers/host_helpers.rb +10 -7
  30. data/lib/beaker-puppet/helpers/puppet_helpers.rb +145 -229
  31. data/lib/beaker-puppet/helpers/rake_helpers.rb +1 -1
  32. data/lib/beaker-puppet/helpers/tk_helpers.rb +22 -28
  33. data/lib/beaker-puppet/install_utils/aio_defaults.rb +39 -43
  34. data/lib/beaker-puppet/install_utils/ezbake_utils.rb +34 -42
  35. data/lib/beaker-puppet/install_utils/foss_defaults.rb +134 -138
  36. data/lib/beaker-puppet/install_utils/foss_utils.rb +269 -480
  37. data/lib/beaker-puppet/install_utils/module_utils.rb +58 -70
  38. data/lib/beaker-puppet/install_utils/puppet5.rb +30 -35
  39. data/lib/beaker-puppet/install_utils/puppet_utils.rb +53 -80
  40. data/lib/beaker-puppet/install_utils/windows_utils.rb +34 -36
  41. data/lib/beaker-puppet/version.rb +1 -1
  42. data/lib/beaker-puppet/wrappers.rb +13 -14
  43. data/lib/beaker-puppet.rb +4 -5
  44. data/release-prep.sh +11 -0
  45. data/setup/aio/010_Install_Puppet_Agent.rb +22 -9
  46. data/setup/common/000-delete-puppet-when-none.rb +2 -4
  47. data/setup/common/003_solaris_cert_fix.rb +74 -70
  48. data/setup/common/005_redhat_subscription_fix.rb +3 -2
  49. data/setup/common/011_Install_Puppet_Server.rb +7 -9
  50. data/setup/common/012_Finalize_Installs.rb +5 -5
  51. data/setup/common/025_StopFirewall.rb +1 -1
  52. data/setup/common/030_StopSssd.rb +2 -2
  53. data/setup/common/040_ValidateSignCert.rb +9 -18
  54. data/setup/common/045_EnsureMasterStarted.rb +2 -2
  55. data/setup/gem/010_GemInstall.rb +6 -5
  56. data/setup/git/000_EnvSetup.rb +48 -48
  57. data/setup/git/010_TestSetup.rb +13 -12
  58. data/setup/git/020_PuppetUserAndGroup.rb +3 -2
  59. data/setup/git/060_InstallModules.rb +14 -14
  60. data/setup/git/070_InstallCACerts.rb +82 -82
  61. data/spec/beaker-puppet/helpers/facter_helpers_spec.rb +22 -24
  62. data/spec/beaker-puppet/helpers/host_helpers_spec.rb +10 -6
  63. data/spec/beaker-puppet/helpers/puppet_helpers_spec.rb +463 -724
  64. data/spec/beaker-puppet/helpers/tk_helpers_spec.rb +20 -24
  65. data/spec/beaker-puppet/install_utils/ezbake_utils_spec.rb +86 -90
  66. data/spec/beaker-puppet/install_utils/foss_utils_spec.rb +471 -863
  67. data/spec/beaker-puppet/install_utils/module_utils_spec.rb +125 -116
  68. data/spec/beaker-puppet/install_utils/puppet5_spec.rb +159 -165
  69. data/spec/beaker-puppet/install_utils/puppet_utils_spec.rb +89 -97
  70. data/spec/beaker-puppet/install_utils/windows_utils_spec.rb +101 -89
  71. data/spec/beaker-puppet/wrappers_spec.rb +10 -10
  72. data/spec/helpers.rb +85 -91
  73. data/tasks/ci.rake +188 -188
  74. metadata +38 -62
  75. data/setup/common/020_InstallCumulusModules.rb +0 -13
  76. data/setup/common/021_InstallAristaModuleMasters.rb +0 -12
  77. data/setup/common/022_InstallAristaModuleAgents.rb +0 -13
@@ -17,90 +17,111 @@ end
17
17
  describe ClassMixedWithDSLInstallUtils do
18
18
  let(:metadata) { @metadata ||= {} }
19
19
  let(:presets) { Beaker::Options::Presets.new }
20
- let(:opts) { presets.presets.merge(presets.env_vars).merge({ :type => 'foss' }) }
21
- let(:basic_hosts) { make_hosts( { :pe_ver => '3.0',
22
- :platform => 'linux',
23
- :roles => [ 'agent' ],
24
- :type => 'foss' }, 4 ) }
25
- let(:hosts) { basic_hosts[0][:roles] = ['master', 'database', 'dashboard']
26
- basic_hosts[1][:platform] = 'windows'
27
- basic_hosts[2][:platform] = 'osx-10.9-x86_64'
28
- basic_hosts[3][:platform] = 'eos'
29
- basic_hosts }
30
- let(:hosts_sorted) { [ hosts[1], hosts[0], hosts[2], hosts[3] ] }
31
- let(:winhost) { make_host( 'winhost', { :platform => Beaker::Platform.new('windows-2008r2-64'),
32
- :pe_ver => '3.0',
33
- :working_dir => '/tmp',
34
- :type => 'foss',
35
- :is_cygwin => true} ) }
36
- let(:winhost_non_cygwin) { make_host( 'winhost_non_cygwin', { :platform => 'windows',
37
- :pe_ver => '3.0',
38
- :working_dir => '/tmp',
39
- :type => 'foss',
40
- :is_cygwin => 'false' } ) }
41
-
42
- let(:machost) { make_host( 'machost', { :platform => 'osx-10.9-x86_64',
43
- :pe_ver => '3.0',
44
- :type => 'foss',
45
- :working_dir => '/tmp' } ) }
46
- let(:freebsdhost9) { make_host( 'freebsdhost9', { :platform => 'freebsd-9-x64',
47
- :pe_ver => '3.0',
48
- :working_dir => '/tmp' } ) }
49
- let(:freebsdhost10) { make_host( 'freebsdhost10', { :platform => 'freebsd-10-x64',
50
- :pe_ver => '3.0',
51
- :working_dir => '/tmp' } ) }
52
- let(:unixhost) { make_host( 'unixhost', { :platform => 'linux',
53
- :pe_ver => '3.0',
54
- :working_dir => '/tmp',
55
- :type => 'foss',
56
- :dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386' } ) }
57
- let(:eoshost) { make_host( 'eoshost', { :platform => 'eos',
58
- :pe_ver => '3.0',
59
- :working_dir => '/tmp',
60
- :type => 'foss',
61
- :dist => 'puppet-enterprise-3.7.1-rc0-78-gffc958f-eos-4-i386' } ) }
62
- let(:el6hostaio) { make_host( 'el6hostaio', { :platform => Beaker::Platform.new('el-6-i386'),
63
- :pe_ver => '3.0',
64
- :working_dir => '/tmp',
65
- :type => 'aio',
66
- :dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-centos-6-i386' } ) }
67
- let(:el6hostfoss) { make_host( 'el6hostfoss', { :platform => Beaker::Platform.new('el-6-i386'),
68
- :pe_ver => '3.0',
69
- :working_dir => '/tmp',
70
- :type => 'foss',
71
- :dist => 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-centos-6-i386' } ) }
72
-
73
- let(:win_temp) { 'C:\\Windows\\Temp' }
20
+ let(:opts) { presets.presets.merge(presets.env_vars).merge({ type: 'foss' }) }
21
+ let(:basic_hosts) do
22
+ make_hosts({ pe_ver: '3.0',
23
+ platform: 'linux',
24
+ roles: ['agent'],
25
+ type: 'foss', }, 4)
26
+ end
27
+ let(:hosts) do
28
+ basic_hosts[0][:roles] = %w[master database dashboard]
29
+ basic_hosts[1][:platform] = 'windows'
30
+ basic_hosts[2][:platform] = 'osx-10.9-x86_64'
31
+ basic_hosts[3][:platform] = 'eos'
32
+ basic_hosts
33
+ end
34
+ let(:hosts_sorted) { [hosts[1], hosts[0], hosts[2], hosts[3]] }
35
+ let(:winhost) do
36
+ make_host('winhost', { platform: Beaker::Platform.new('windows-2008r2-64'),
37
+ pe_ver: '3.0',
38
+ working_dir: '/tmp',
39
+ type: 'foss',
40
+ is_cygwin: true, })
41
+ end
42
+ let(:winhost_non_cygwin) do
43
+ make_host('winhost_non_cygwin', { platform: 'windows',
44
+ pe_ver: '3.0',
45
+ working_dir: '/tmp',
46
+ type: 'foss',
47
+ is_cygwin: 'false', })
48
+ end
49
+
50
+ let(:machost) do
51
+ make_host('machost', { platform: 'osx-10.9-x86_64',
52
+ pe_ver: '3.0',
53
+ type: 'foss',
54
+ working_dir: '/tmp', })
55
+ end
56
+ let(:freebsdhost12) do
57
+ make_host('freebsdhost12', { platform: 'freebsd-12-amd64',
58
+ pe_ver: '3.0',
59
+ working_dir: '/tmp', })
60
+ end
61
+ let(:freebsdhost13) do
62
+ make_host('freebsdhost13', { platform: 'freebsd-13-amd64',
63
+ pe_ver: '3.0',
64
+ working_dir: '/tmp', })
65
+ end
66
+ let(:unixhost) do
67
+ make_host('unixhost', { platform: 'linux',
68
+ pe_ver: '3.0',
69
+ working_dir: '/tmp',
70
+ type: 'foss',
71
+ dist: 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-debian-7-i386', })
72
+ end
73
+ let(:eoshost) do
74
+ make_host('eoshost', { platform: 'eos',
75
+ pe_ver: '3.0',
76
+ working_dir: '/tmp',
77
+ type: 'foss',
78
+ dist: 'puppet-enterprise-3.7.1-rc0-78-gffc958f-eos-4-i386', })
79
+ end
80
+ let(:el6hostaio) do
81
+ make_host('el6hostaio', { platform: Beaker::Platform.new('el-6-i386'),
82
+ pe_ver: '3.0',
83
+ working_dir: '/tmp',
84
+ type: 'aio',
85
+ dist: 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-centos-6-i386', })
86
+ end
87
+ let(:el6hostfoss) do
88
+ make_host('el6hostfoss', { platform: Beaker::Platform.new('el-6-i386'),
89
+ pe_ver: '3.0',
90
+ working_dir: '/tmp',
91
+ type: 'foss',
92
+ dist: 'puppet-enterprise-3.1.0-rc0-230-g36c9e5c-centos-6-i386', })
93
+ end
94
+
95
+ let(:win_temp) { 'C:\\Windows\\Temp' }
74
96
 
75
97
  context '#sanitize_opts' do
76
- let(:opts) {
98
+ let(:opts) do
77
99
  {
78
- :win_download_url => nil,
79
- :dev_builds_url => '',
80
- :release_yum_repo_url => 'https://apt.customserver.net/apt'
100
+ win_download_url: nil,
101
+ dev_builds_url: '',
102
+ release_yum_repo_url: 'https://apt.customserver.net/apt',
81
103
  }
82
- }
104
+ end
83
105
 
84
106
  it 'honors any custom values' do
85
- expect( subject.sanitize_opts(opts)).to include({release_yum_repo_url: 'https://apt.customserver.net/apt'})
107
+ expect(subject.sanitize_opts(opts)).to include({ release_yum_repo_url: 'https://apt.customserver.net/apt' })
86
108
  end
87
109
 
88
110
  it 'overwrites any nil values with pre-defined defaults' do
89
111
  default_win_url = described_class::FOSS_DEFAULT_DOWNLOAD_URLS[:win_download_url]
90
- expect( subject.sanitize_opts(opts)).to include({win_download_url: default_win_url})
112
+ expect(subject.sanitize_opts(opts)).to include({ win_download_url: default_win_url })
91
113
  end
92
114
 
93
115
  it 'keeps empty strings' do
94
- expect( subject.sanitize_opts(opts)).to include({dev_builds_url: ''})
116
+ expect(subject.sanitize_opts(opts)).to include({ dev_builds_url: '' })
95
117
  end
96
118
 
97
119
  it 'adds any undefined defaults' do
98
120
  default_mac_url = described_class::FOSS_DEFAULT_DOWNLOAD_URLS[:mac_download_url]
99
- expect( subject.sanitize_opts(opts)).to include({mac_download_url: default_mac_url})
121
+ expect(subject.sanitize_opts(opts)).to include({ mac_download_url: default_mac_url })
100
122
  end
101
123
  end
102
124
 
103
-
104
125
  context '#configure_foss_defaults_on' do
105
126
  it 'uses aio paths for hosts with role aio' do
106
127
  hosts.each do |host|
@@ -112,7 +133,7 @@ describe ClassMixedWithDSLInstallUtils do
112
133
  expect(subject).to receive(:add_aio_defaults_on).exactly(hosts.length).times
113
134
  expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
114
135
 
115
- subject.configure_foss_defaults_on( hosts )
136
+ subject.configure_foss_defaults_on(hosts)
116
137
  end
117
138
 
118
139
  it 'uses no paths for hosts with no type' do
@@ -123,7 +144,7 @@ describe ClassMixedWithDSLInstallUtils do
123
144
  expect(subject).to receive(:add_foss_defaults_on).never
124
145
  expect(subject).to receive(:add_puppet_paths_on).never
125
146
 
126
- subject.configure_foss_defaults_on( hosts )
147
+ subject.configure_foss_defaults_on(hosts)
127
148
  end
128
149
 
129
150
  it 'uses aio paths for hosts with aio type (backwards compatability)' do
@@ -136,7 +157,7 @@ describe ClassMixedWithDSLInstallUtils do
136
157
  expect(subject).to receive(:add_foss_defaults_on).never
137
158
  expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
138
159
 
139
- subject.configure_foss_defaults_on( hosts )
160
+ subject.configure_foss_defaults_on(hosts)
140
161
  end
141
162
 
142
163
  it 'uses aio paths for hosts of version >= 4.0' do
@@ -149,7 +170,7 @@ describe ClassMixedWithDSLInstallUtils do
149
170
  expect(subject).to receive(:add_foss_defaults_on).exactly(hosts.length).times
150
171
  expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
151
172
 
152
- subject.configure_foss_defaults_on( hosts )
173
+ subject.configure_foss_defaults_on(hosts)
153
174
  end
154
175
 
155
176
  it 'uses foss paths for hosts of version < 4.0' do
@@ -161,7 +182,7 @@ describe ClassMixedWithDSLInstallUtils do
161
182
  expect(subject).to receive(:add_aio_defaults_on).never
162
183
  expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
163
184
 
164
- subject.configure_foss_defaults_on( hosts )
185
+ subject.configure_foss_defaults_on(hosts)
165
186
  end
166
187
 
167
188
  it 'uses foss paths for foss-like type foss-package' do
@@ -174,17 +195,16 @@ describe ClassMixedWithDSLInstallUtils do
174
195
  expect(subject).to receive(:add_aio_defaults_on).never
175
196
  expect(subject).to receive(:add_puppet_paths_on).exactly(hosts.length).times
176
197
 
177
- subject.configure_foss_defaults_on( hosts )
198
+ subject.configure_foss_defaults_on(hosts)
178
199
  end
179
-
180
200
  end
181
201
 
182
202
  context 'lookup_in_env' do
183
203
  it 'returns a default properly' do
184
204
  env_var = subject.lookup_in_env('noway', 'nonesuch', 'returnme')
185
- expect(env_var).to be == 'returnme'
205
+ expect(env_var).to eq 'returnme'
186
206
  env_var = subject.lookup_in_env('noway', nil, 'returnme')
187
- expect(env_var).to be == 'returnme'
207
+ expect(env_var).to eq 'returnme'
188
208
  end
189
209
  it 'finds correct env variable' do
190
210
  allow(ENV).to receive(:[]).with(nil).and_return(nil)
@@ -192,13 +212,13 @@ describe ClassMixedWithDSLInstallUtils do
192
212
  allow(ENV).to receive(:[]).with('NONESUCH').and_return('present')
193
213
  allow(ENV).to receive(:[]).with('NOWAY_PROJ_NONESUCH').and_return('exists')
194
214
  env_var = subject.lookup_in_env('nonesuch', 'noway-proj', 'fail')
195
- expect(env_var).to be == 'exists'
215
+ expect(env_var).to eq 'exists'
196
216
  env_var = subject.lookup_in_env('nonesuch')
197
- expect(env_var).to be == 'present'
217
+ expect(env_var).to eq 'present'
198
218
  env_var = subject.lookup_in_env('reallynone')
199
- expect(env_var).to be == nil
200
- env_var = subject.lookup_in_env('reallynone',nil,'default')
201
- expect(env_var).to be == 'default'
219
+ expect(env_var).to eq nil # rubocop:disable Style/NilComparison
220
+ env_var = subject.lookup_in_env('reallynone', nil, 'default')
221
+ expect(env_var).to eq 'default'
202
222
  end
203
223
  end
204
224
 
@@ -209,21 +229,21 @@ describe ClassMixedWithDSLInstallUtils do
209
229
  allow(ENV).to receive(:[]).with('PUPPET_FORK').and_return(nil)
210
230
  allow(ENV).to receive(:[]).with('PUPPET_SERVER').and_return(nil)
211
231
  url = subject.build_giturl('puppet')
212
- expect(url).to be == 'https://github.com/puppetlabs/puppet.git'
232
+ expect(url).to eq 'https://github.com/puppetlabs/puppet.git'
213
233
  url = subject.build_giturl('puppet', 'er0ck')
214
- expect(url).to be == 'https://github.com/er0ck/puppet.git'
234
+ expect(url).to eq 'https://github.com/er0ck/puppet.git'
215
235
  url = subject.build_giturl('puppet', 'er0ck', 'bitbucket.com')
216
- expect(url).to be == 'https://bitbucket.com/er0ck-puppet.git'
236
+ expect(url).to eq 'https://bitbucket.com/er0ck-puppet.git'
217
237
  url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'https://')
218
- expect(url).to be == 'https://github.com/er0ck/puppet.git'
238
+ expect(url).to eq 'https://github.com/er0ck/puppet.git'
219
239
  url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'https')
220
- expect(url).to be == 'https://github.com/er0ck/puppet.git'
240
+ expect(url).to eq 'https://github.com/er0ck/puppet.git'
221
241
  url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'git@')
222
- expect(url).to be == 'git@github.com:er0ck/puppet.git'
242
+ expect(url).to eq 'git@github.com:er0ck/puppet.git'
223
243
  url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'git')
224
- expect(url).to be == 'git@github.com:er0ck/puppet.git'
244
+ expect(url).to eq 'git@github.com:er0ck/puppet.git'
225
245
  url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'ssh')
226
- expect(url).to be == 'git@github.com:er0ck/puppet.git'
246
+ expect(url).to eq 'git@github.com:er0ck/puppet.git'
227
247
  end
228
248
 
229
249
  it 'uses ENV to build urls properly' do
@@ -232,36 +252,35 @@ describe ClassMixedWithDSLInstallUtils do
232
252
  allow(ENV).to receive(:[]).with('PUPPET_FORK').and_return('er0ck/repo')
233
253
  allow(ENV).to receive(:[]).with('PUPPET_SERVER').and_return('gitlab.com')
234
254
  url = subject.build_giturl('puppet')
235
- expect(url).to be == 'https://gitlab.com/er0ck/repo-puppet.git'
255
+ expect(url).to eq 'https://gitlab.com/er0ck/repo-puppet.git'
236
256
  url = subject.build_giturl('puppet', 'er0ck')
237
- expect(url).to be == 'https://gitlab.com/er0ck-puppet.git'
257
+ expect(url).to eq 'https://gitlab.com/er0ck-puppet.git'
238
258
  url = subject.build_giturl('puppet', 'er0ck', 'bitbucket.com')
239
- expect(url).to be == 'https://bitbucket.com/er0ck-puppet.git'
259
+ expect(url).to eq 'https://bitbucket.com/er0ck-puppet.git'
240
260
  url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'https://')
241
- expect(url).to be == 'https://github.com/er0ck/puppet.git'
261
+ expect(url).to eq 'https://github.com/er0ck/puppet.git'
242
262
  url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'https')
243
- expect(url).to be == 'https://github.com/er0ck/puppet.git'
263
+ expect(url).to eq 'https://github.com/er0ck/puppet.git'
244
264
  url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'git@')
245
- expect(url).to be == 'git@github.com:er0ck/puppet.git'
265
+ expect(url).to eq 'git@github.com:er0ck/puppet.git'
246
266
  url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'git')
247
- expect(url).to be == 'git@github.com:er0ck/puppet.git'
267
+ expect(url).to eq 'git@github.com:er0ck/puppet.git'
248
268
  url = subject.build_giturl('puppet', 'er0ck', 'github.com', 'ssh')
249
- expect(url).to be == 'git@github.com:er0ck/puppet.git'
269
+ expect(url).to eq 'git@github.com:er0ck/puppet.git'
250
270
  end
251
271
  end
252
272
 
253
273
  context 'extract_repo_info_from' do
254
- [{ :protocol => 'git', :path => 'git://github.com/puppetlabs/project.git' },
255
- { :protocol => 'ssh', :path => 'git@github.com:puppetlabs/project.git' },
256
- { :protocol => 'https', :path => 'https://github.com:puppetlabs/project' },
257
- { :protocol => 'file', :path => 'file:///home/example/project' }
258
- ].each do |type|
259
- it "handles #{ type[:protocol] } uris" do
260
- uri = "#{ type[:path] }#master"
274
+ [{ protocol: 'git', path: 'git://github.com/puppetlabs/project.git' },
275
+ { protocol: 'ssh', path: 'git@github.com:puppetlabs/project.git' },
276
+ { protocol: 'https', path: 'https://github.com:puppetlabs/project' },
277
+ { protocol: 'file', path: 'file:///home/example/project' },].each do |type|
278
+ it "handles #{type[:protocol]} uris" do
279
+ uri = "#{type[:path]}#master"
261
280
  repo_info = subject.extract_repo_info_from uri
262
- expect( repo_info[:name] ).to be == 'project'
263
- expect( repo_info[:path] ).to be == type[:path]
264
- expect( repo_info[:rev] ).to be == 'master'
281
+ expect(repo_info[:name]).to eq 'project'
282
+ expect(repo_info[:path]).to eq type[:path]
283
+ expect(repo_info[:rev]).to eq 'master'
265
284
  end
266
285
  end
267
286
  end
@@ -269,66 +288,67 @@ describe ClassMixedWithDSLInstallUtils do
269
288
  context 'order_packages' do
270
289
  it 'orders facter, hiera before puppet, before anything else' do
271
290
  named_repos = [
272
- { :name => 'puppet_plugin' }, { :name => 'puppet' }, { :name => 'facter' }
291
+ { name: 'puppet_plugin' }, { name: 'puppet' }, { name: 'facter' },
273
292
  ]
274
293
  ordered_repos = subject.order_packages named_repos
275
- expect( ordered_repos[0][:name] ).to be == 'facter'
276
- expect( ordered_repos[1][:name] ).to be == 'puppet'
277
- expect( ordered_repos[2][:name] ).to be == 'puppet_plugin'
294
+ expect(ordered_repos[0][:name]).to eq 'facter'
295
+ expect(ordered_repos[1][:name]).to eq 'puppet'
296
+ expect(ordered_repos[2][:name]).to eq 'puppet_plugin'
278
297
  end
279
298
  end
280
299
 
281
300
  context 'find_git_repo_versions' do
282
301
  it 'returns a hash of :name => version' do
283
- host = double( 'Host' )
284
- repository = { :name => 'name' }
302
+ host = double('Host')
303
+ repository = { name: 'name' }
285
304
  path = '/path/to/repo'
286
305
  cmd = 'cd /path/to/repo/name && git describe || true'
287
306
  logger = double.as_null_object
288
307
 
289
- allow( subject ).to receive( :metadata ).and_return( metadata )
290
- expect( subject ).to receive( :logger ).and_return( logger )
291
- expect( subject ).to receive( :on ).with( host, cmd ).and_yield
292
- expect( subject ).to receive( :stdout ).and_return( '2' )
308
+ allow(subject).to receive(:metadata).and_return(metadata)
309
+ expect(subject).to receive(:logger).and_return(logger)
310
+ expect(subject).to receive(:on).with(host, cmd).and_yield
311
+ expect(subject).to receive(:stdout).and_return('2')
293
312
 
294
- subject.instance_variable_set( :@metadata, {} )
295
- version = subject.find_git_repo_versions( host, path, repository )
313
+ subject.instance_variable_set(:@metadata, {})
314
+ version = subject.find_git_repo_versions(host, path, repository)
296
315
 
297
- expect( version ).to be == { 'name' => '2' }
316
+ expect(version).to be == { 'name' => '2' } # rubocop:ignore RSpec/Eq
298
317
  end
299
318
  end
300
319
 
301
320
  context 'install_puppet_from_rpm_on' do
302
321
  it 'installs puppet release repo when set' do
303
- expect(subject).to receive(:install_puppetlabs_release_repo).with(el6hostaio,'puppet',{:puppet_collection => 'puppet'})
322
+ expect(subject).to receive(:install_puppetlabs_release_repo).with(el6hostaio, 'puppet',
323
+ { puppet_collection: 'puppet' })
304
324
 
305
- subject.install_puppet_from_rpm_on( el6hostaio, {:puppet_collection => 'puppet'} )
325
+ subject.install_puppet_from_rpm_on(el6hostaio, { puppet_collection: 'puppet' })
306
326
  end
307
327
 
308
328
  it 'installs PC1 release repo when AIO' do
309
- expect(subject).to receive(:install_puppetlabs_release_repo).with(el6hostaio,'pc1',{})
329
+ expect(subject).to receive(:install_puppetlabs_release_repo).with(el6hostaio, 'pc1', {})
310
330
 
311
- subject.install_puppet_from_rpm_on( el6hostaio, {} )
331
+ subject.install_puppet_from_rpm_on(el6hostaio, {})
312
332
  end
313
333
 
314
334
  it 'installs non-PC1 package when not-AIO' do
315
- expect(subject).to receive(:install_puppetlabs_release_repo).with(el6hostfoss,nil,{})
335
+ expect(subject).to receive(:install_puppetlabs_release_repo).with(el6hostfoss, nil, {})
316
336
 
317
- subject.install_puppet_from_rpm_on( el6hostfoss, {} )
337
+ subject.install_puppet_from_rpm_on(el6hostfoss, {})
318
338
  end
319
339
  end
320
340
 
321
341
  context 'install_puppet_from_freebsd_ports_on' do
322
- it 'installs puppet on FreeBSD 9' do
323
- expect(freebsdhost9).to receive(:install_package).with('puppet')
342
+ it 'installs puppet on FreeBSD 12' do
343
+ expect(freebsdhost12).to receive(:install_package).with('sysutils/puppet7')
324
344
 
325
- subject.install_puppet_from_freebsd_ports_on( freebsdhost9, {} )
345
+ subject.install_puppet_from_freebsd_ports_on(freebsdhost12, {})
326
346
  end
327
347
 
328
- it 'installs puppet on FreeBSD 10' do
329
- expect(freebsdhost10).to receive(:install_package).with('sysutils/puppet')
348
+ it 'installs puppet on FreeBSD 13' do
349
+ expect(freebsdhost13).to receive(:install_package).with('sysutils/puppet7')
330
350
 
331
- subject.install_puppet_from_freebsd_ports_on( freebsdhost10, {} )
351
+ subject.install_puppet_from_freebsd_ports_on(freebsdhost13, {})
332
352
  end
333
353
  end
334
354
 
@@ -340,206 +360,229 @@ describe ClassMixedWithDSLInstallUtils do
340
360
  end
341
361
 
342
362
  it 'installs puppet on cygwin windows' do
343
- allow(subject).to receive(:link_exists?).and_return( true )
344
- expect(subject).to receive(:on).with(winhost, "curl --location --output \"#{win_temp}\\puppet-3.7.1-x64.msi\" --remote-name http://downloads.puppet.com/windows/puppet-3.7.1-x64.msi")
345
- expect(subject).to receive(:on).with(winhost, " echo 'export PATH=$PATH:\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\"' > /etc/bash.bashrc ")
346
- expect(subject).to receive(:install_msi_on).with(winhost, "#{win_temp}\\puppet-3.7.1-x64.msi", {}, {:debug => nil})
363
+ allow(subject).to receive(:link_exists?).and_return(true)
364
+ expect(subject).to receive(:on).with(winhost,
365
+ "curl --location --output \"#{win_temp}\\puppet-3.7.1-x64.msi\" --remote-name http://downloads.puppet.com/windows/puppet-3.7.1-x64.msi")
366
+ expect(subject).to receive(:on).with(winhost,
367
+ " echo 'export PATH=$PATH:\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\"' > /etc/bash.bashrc ")
368
+ expect(subject).to receive(:install_msi_on).with(winhost, "#{win_temp}\\puppet-3.7.1-x64.msi", {}, { debug: nil })
347
369
 
348
- subject.install_puppet_from_msi( winhost, {:version => '3.7.1', :win_download_url => 'http://downloads.puppet.com/windows'} )
370
+ subject.install_puppet_from_msi(winhost,
371
+ { version: '3.7.1', win_download_url: 'http://downloads.puppet.com/windows' })
349
372
  end
350
373
 
351
374
  it 'installs puppet on cygwin windows via proxy' do
352
- allow(subject).to receive(:link_exists?).and_return( true )
353
- expect(subject).to receive(:on).with(winhost, "curl -x https://proxy.com --location --output \"#{win_temp}\\puppet-3.7.1-x64.msi\" --remote-name http://downloads.puppet.com/windows/puppet-3.7.1-x64.msi")
354
- expect(subject).to receive(:on).with(winhost, " echo 'export PATH=$PATH:\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\"' > /etc/bash.bashrc ")
355
- expect(subject).to receive(:install_msi_on).with(winhost, "#{win_temp}\\puppet-3.7.1-x64.msi", {}, {:debug => nil})
375
+ allow(subject).to receive(:link_exists?).and_return(true)
376
+ expect(subject).to receive(:on).with(winhost,
377
+ "curl -x https://proxy.com --location --output \"#{win_temp}\\puppet-3.7.1-x64.msi\" --remote-name http://downloads.puppet.com/windows/puppet-3.7.1-x64.msi")
378
+ expect(subject).to receive(:on).with(winhost,
379
+ " echo 'export PATH=$PATH:\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\"' > /etc/bash.bashrc ")
380
+ expect(subject).to receive(:install_msi_on).with(winhost, "#{win_temp}\\puppet-3.7.1-x64.msi", {}, { debug: nil })
356
381
 
357
- subject.install_puppet_from_msi( winhost, {:version => '3.7.1', :win_download_url => 'http://downloads.puppet.com/windows', :package_proxy => 'https://proxy.com'} )
382
+ subject.install_puppet_from_msi(winhost,
383
+ { version: '3.7.1', win_download_url: 'http://downloads.puppet.com/windows',
384
+ package_proxy: 'https://proxy.com', })
358
385
  end
359
386
 
360
387
  it 'installs puppet on non-cygwin windows' do
361
- allow(subject).to receive(:link_exists?).and_return( true )
388
+ allow(subject).to receive(:link_exists?).and_return(true)
362
389
 
363
390
  expect(winhost_non_cygwin).to receive(:mkdir_p).with('C:\\ProgramData\\PuppetLabs\\puppet\\etc\\modules')
364
391
 
365
- expect(subject).to receive(:on).with(winhost_non_cygwin, instance_of( Beaker::Command )) do |host, beaker_command|
392
+ expect(subject).to receive(:on).with(winhost_non_cygwin, instance_of(Beaker::Command)) do |host, beaker_command|
366
393
  expect(beaker_command.command).to eq('powershell.exe')
367
- expect(beaker_command.args).to eq(["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command $webclient = New-Object System.Net.WebClient; $webclient.DownloadFile('http://downloads.puppet.com/windows/puppet-3.7.1.msi','#{win_temp}\\puppet-3.7.1.msi')"])
394
+ expect(beaker_command.args).to eq(['-ExecutionPolicy Bypass', '-InputFormat None', '-NoLogo', '-NoProfile',
395
+ '-NonInteractive', "-Command $webclient = New-Object System.Net.WebClient; $webclient.DownloadFile('http://downloads.puppet.com/windows/puppet-3.7.1.msi','#{win_temp}\\puppet-3.7.1.msi')",])
368
396
  end.once
369
397
 
370
- expect(subject).to receive(:install_msi_on).with(winhost_non_cygwin, "#{win_temp}\\puppet-3.7.1.msi", {}, {:debug => nil})
398
+ expect(subject).to receive(:install_msi_on).with(winhost_non_cygwin, "#{win_temp}\\puppet-3.7.1.msi", {},
399
+ { debug: nil })
371
400
 
372
- subject.install_puppet_from_msi( winhost_non_cygwin, {:version => '3.7.1', :win_download_url => 'http://downloads.puppet.com/windows'} )
401
+ subject.install_puppet_from_msi(winhost_non_cygwin,
402
+ { version: '3.7.1', win_download_url: 'http://downloads.puppet.com/windows' })
373
403
  end
374
404
 
375
405
  it 'installs puppet on non-cygwin windows via proxy' do
376
- allow(subject).to receive(:link_exists?).and_return( true )
406
+ allow(subject).to receive(:link_exists?).and_return(true)
377
407
 
378
408
  expect(winhost_non_cygwin).to receive(:mkdir_p).with('C:\\ProgramData\\PuppetLabs\\puppet\\etc\\modules')
379
409
 
380
- expect(subject).to receive(:on).with(winhost_non_cygwin, instance_of( Beaker::Command )) do |host, beaker_command|
410
+ expect(subject).to receive(:on).with(winhost_non_cygwin, instance_of(Beaker::Command)) do |host, beaker_command|
381
411
  expect(beaker_command.command).to eq('powershell.exe')
382
- expect(beaker_command.args).to eq(["-ExecutionPolicy Bypass", "-InputFormat None", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command $webclient = New-Object System.Net.WebClient; $webclient.Proxy = New-Object System.Net.WebProxy('https://proxy.com',$true); $webclient.DownloadFile('http://downloads.puppet.com/windows/puppet-3.7.1.msi','#{win_temp}\\puppet-3.7.1.msi')"])
412
+ expect(beaker_command.args).to eq(['-ExecutionPolicy Bypass', '-InputFormat None', '-NoLogo', '-NoProfile',
413
+ '-NonInteractive', "-Command $webclient = New-Object System.Net.WebClient; $webclient.Proxy = New-Object System.Net.WebProxy('https://proxy.com',$true); $webclient.DownloadFile('http://downloads.puppet.com/windows/puppet-3.7.1.msi','#{win_temp}\\puppet-3.7.1.msi')",])
383
414
  end.once
384
415
 
385
- expect(subject).to receive(:install_msi_on).with(winhost_non_cygwin, "#{win_temp}\\puppet-3.7.1.msi", {}, {:debug => nil})
386
-
387
- subject.install_puppet_from_msi( winhost_non_cygwin, {:version => '3.7.1', :win_download_url => 'http://downloads.puppet.com/windows', :package_proxy => 'https://proxy.com'})
416
+ expect(subject).to receive(:install_msi_on).with(winhost_non_cygwin, "#{win_temp}\\puppet-3.7.1.msi", {},
417
+ { debug: nil })
388
418
 
419
+ subject.install_puppet_from_msi(winhost_non_cygwin,
420
+ { version: '3.7.1', win_download_url: 'http://downloads.puppet.com/windows',
421
+ package_proxy: 'https://proxy.com', })
389
422
  end
390
423
  end
391
424
 
392
425
  context 'clone_git_repo_on' do
393
426
  it 'does a ton of stuff it probably shouldnt' do
394
- repo = { :name => 'puppet',
395
- :path => 'git://my.server.net/puppet.git',
396
- :rev => 'master' }
427
+ repo = { name: 'puppet',
428
+ path: 'git://my.server.net/puppet.git',
429
+ rev: 'master', }
397
430
  path = '/path/to/repos'
398
431
  host = { 'platform' => 'debian' }
399
432
  logger = double.as_null_object
400
433
 
401
- allow( subject ).to receive( :metadata ).and_return( metadata )
402
- allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
434
+ allow(subject).to receive(:metadata).and_return(metadata)
435
+ allow(subject).to receive(:configure_foss_defaults_on).and_return(true)
403
436
 
404
- expect( subject ).to receive( :logger ).exactly( 2 ).times.and_return( logger )
405
- expect( subject ).to receive( :on ).exactly( 3 ).times
437
+ expect(subject).to receive(:logger).exactly(2).times.and_return(logger)
438
+ expect(subject).to receive(:on).exactly(3).times
406
439
 
407
- subject.instance_variable_set( :@metadata, {} )
408
- subject.clone_git_repo_on( host, path, repo )
440
+ subject.instance_variable_set(:@metadata, {})
441
+ subject.clone_git_repo_on(host, path, repo)
409
442
  end
410
443
 
411
444
  it 'allows a checkout depth of 1' do
412
- repo = { :name => 'puppet',
413
- :path => 'git://my.server.net/puppet.git',
414
- :rev => 'master',
415
- :depth => 1 }
445
+ repo = { name: 'puppet',
446
+ path: 'git://my.server.net/puppet.git',
447
+ rev: 'master',
448
+ depth: 1, }
416
449
 
417
450
  path = '/path/to/repos'
418
451
  cmd = "test -d #{path}/#{repo[:name]} || git clone --branch #{repo[:rev]} --depth #{repo[:depth]} #{repo[:path]} #{path}/#{repo[:name]}"
419
452
  host = { 'platform' => 'debian' }
420
453
  logger = double.as_null_object
421
- allow( subject ).to receive( :metadata ).and_return( metadata )
422
- allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
423
- expect( subject ).to receive( :logger ).exactly( 2 ).times.and_return( logger )
424
- expect( subject ).to receive( :on ).with( host, "test -d #{path} || mkdir -p #{path}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
454
+ allow(subject).to receive(:metadata).and_return(metadata)
455
+ allow(subject).to receive(:configure_foss_defaults_on).and_return(true)
456
+ expect(subject).to receive(:logger).exactly(2).times.and_return(logger)
457
+ expect(subject).to receive(:on).with(host, "test -d #{path} || mkdir -p #{path}",
458
+ { accept_all_exit_codes: true }).exactly(1).times
425
459
  # this is the the command we want to test
426
- expect( subject ).to receive( :on ).with( host, cmd, {:accept_all_exit_codes=>true} ).exactly( 1 ).times
427
- expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && git remote rm origin && git remote add origin #{repo[:path]} && git fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/* && git clean -fdx && git checkout -f #{repo[:rev]}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
460
+ expect(subject).to receive(:on).with(host, cmd, { accept_all_exit_codes: true }).exactly(1).times
461
+ expect(subject).to receive(:on).with(host,
462
+ "cd #{path}/#{repo[:name]} && git remote rm origin && git remote add origin #{repo[:path]} && git fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/* && git clean -fdx && git checkout -f #{repo[:rev]}", { accept_all_exit_codes: true }).exactly(1).times
428
463
 
429
- subject.instance_variable_set( :@metadata, {} )
430
- subject.clone_git_repo_on( host, path, repo )
464
+ subject.instance_variable_set(:@metadata, {})
465
+ subject.clone_git_repo_on(host, path, repo)
431
466
  end
432
467
 
433
468
  it 'allows a checkout depth with a rev from a specific branch' do
434
- repo = { :name => 'puppet',
435
- :path => 'git://my.server.net/puppet.git',
436
- :rev => 'a2340acddadfeafd234230faf',
437
- :depth => 50,
438
- :depth_branch => 'master' }
469
+ repo = { name: 'puppet',
470
+ path: 'git://my.server.net/puppet.git',
471
+ rev: 'a2340acddadfeafd234230faf',
472
+ depth: 50,
473
+ depth_branch: 'master', }
439
474
 
440
475
  path = '/path/to/repos'
441
476
  cmd = "test -d #{path}/#{repo[:name]} || git clone --branch #{repo[:depth_branch]} --depth #{repo[:depth]} #{repo[:path]} #{path}/#{repo[:name]}"
442
477
  host = { 'platform' => 'debian' }
443
- allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
478
+ allow(subject).to receive(:configure_foss_defaults_on).and_return(true)
444
479
  logger = double.as_null_object
445
- allow( subject ).to receive( :metadata ).and_return( metadata )
446
- expect( subject ).to receive( :logger ).exactly( 2 ).times.and_return( logger )
447
- expect( subject ).to receive( :on ).with( host, "test -d #{path} || mkdir -p #{path}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
480
+ allow(subject).to receive(:metadata).and_return(metadata)
481
+ expect(subject).to receive(:logger).exactly(2).times.and_return(logger)
482
+ expect(subject).to receive(:on).with(host, "test -d #{path} || mkdir -p #{path}",
483
+ { accept_all_exit_codes: true }).exactly(1).times
448
484
  # this is the the command we want to test
449
- expect( subject ).to receive( :on ).with( host, cmd, {:accept_all_exit_codes=>true} ).exactly( 1 ).times
450
- expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && git remote rm origin && git remote add origin #{repo[:path]} && git fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/* && git clean -fdx && git checkout -f #{repo[:rev]}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
485
+ expect(subject).to receive(:on).with(host, cmd, { accept_all_exit_codes: true }).exactly(1).times
486
+ expect(subject).to receive(:on).with(host,
487
+ "cd #{path}/#{repo[:name]} && git remote rm origin && git remote add origin #{repo[:path]} && git fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/* && git clean -fdx && git checkout -f #{repo[:rev]}", { accept_all_exit_codes: true }).exactly(1).times
451
488
 
452
- subject.instance_variable_set( :@metadata, {} )
453
- subject.clone_git_repo_on( host, path, repo )
489
+ subject.instance_variable_set(:@metadata, {})
490
+ subject.clone_git_repo_on(host, path, repo)
454
491
  end
455
492
  end
456
493
 
457
494
  context 'install_from_git' do
458
495
  it 'does a ton of stuff it probably shouldnt' do
459
- repo = { :name => 'puppet',
460
- :path => 'git://my.server.net/puppet.git',
461
- :rev => 'master' }
496
+ repo = { name: 'puppet',
497
+ path: 'git://my.server.net/puppet.git',
498
+ rev: 'master', }
462
499
  path = '/path/to/repos'
463
500
  host = { 'platform' => 'debian' }
464
501
  logger = double.as_null_object
465
502
 
466
- allow( subject ).to receive( :metadata ).and_return( metadata )
467
- allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
503
+ allow(subject).to receive(:metadata).and_return(metadata)
504
+ allow(subject).to receive(:configure_foss_defaults_on).and_return(true)
468
505
 
469
- expect( subject ).to receive( :logger ).exactly( 3 ).times.and_return( logger )
470
- expect( subject ).to receive( :on ).exactly( 4 ).times
506
+ expect(subject).to receive(:logger).exactly(3).times.and_return(logger)
507
+ expect(subject).to receive(:on).exactly(4).times
471
508
 
472
- subject.instance_variable_set( :@metadata, {} )
473
- subject.install_from_git( host, path, repo )
509
+ subject.instance_variable_set(:@metadata, {})
510
+ subject.install_from_git(host, path, repo)
474
511
  end
475
512
 
476
513
  it 'should attempt to install ruby code' do
477
- repo = { :name => 'puppet',
478
- :path => 'git://my.server.net/puppet.git',
479
- :rev => 'master',
480
- :depth => 1 }
514
+ repo = { name: 'puppet',
515
+ path: 'git://my.server.net/puppet.git',
516
+ rev: 'master',
517
+ depth: 1, }
481
518
 
482
519
  path = '/path/to/repos'
483
520
  cmd = "test -d #{path}/#{repo[:name]} || git clone --branch #{repo[:rev]} --depth #{repo[:depth]} #{repo[:path]} #{path}/#{repo[:name]}"
484
521
  host = { 'platform' => 'debian' }
485
522
  logger = double.as_null_object
486
- allow( subject ).to receive( :metadata ).and_return( metadata )
487
- allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
488
- expect( subject ).to receive( :logger ).exactly( 3 ).times.and_return( logger )
489
- expect( subject ).to receive( :on ).with( host, "test -d #{path} || mkdir -p #{path}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
490
- expect( subject ).to receive( :on ).with( host, cmd, {:accept_all_exit_codes=>true} ).exactly( 1 ).times
491
- expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && git remote rm origin && git remote add origin #{repo[:path]} && git fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/* && git clean -fdx && git checkout -f #{repo[:rev]}", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
492
- expect( subject ).to receive( :on ).with( host, "cd #{path}/#{repo[:name]} && if [ -f install.rb ]; then ruby ./install.rb ; else true; fi", {:accept_all_exit_codes=>true} ).exactly( 1 ).times
493
-
494
- subject.instance_variable_set( :@metadata, {} )
495
- subject.install_from_git_on( host, path, repo )
523
+ allow(subject).to receive(:metadata).and_return(metadata)
524
+ allow(subject).to receive(:configure_foss_defaults_on).and_return(true)
525
+ expect(subject).to receive(:logger).exactly(3).times.and_return(logger)
526
+ expect(subject).to receive(:on).with(host, "test -d #{path} || mkdir -p #{path}",
527
+ { accept_all_exit_codes: true }).exactly(1).times
528
+ expect(subject).to receive(:on).with(host, cmd, { accept_all_exit_codes: true }).exactly(1).times
529
+ expect(subject).to receive(:on).with(host,
530
+ "cd #{path}/#{repo[:name]} && git remote rm origin && git remote add origin #{repo[:path]} && git fetch origin +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/* && git clean -fdx && git checkout -f #{repo[:rev]}", { accept_all_exit_codes: true }).exactly(1).times
531
+ expect(subject).to receive(:on).with(host,
532
+ "cd #{path}/#{repo[:name]} && if [ -f install.rb ]; then ruby ./install.rb ; else true; fi", { accept_all_exit_codes: true }).exactly(1).times
533
+
534
+ subject.instance_variable_set(:@metadata, {})
535
+ subject.install_from_git_on(host, path, repo)
496
536
  end
497
- end
537
+ end
498
538
 
499
539
  describe '#install_puppet' do
500
540
  let(:hosts) do
501
- make_hosts({:platform => platform })
541
+ make_hosts({ platform: platform })
502
542
  end
503
543
 
504
544
  before do
505
- allow( subject ).to receive(:options).and_return(opts)
506
- allow( subject ).to receive(:hosts).and_return(hosts)
507
- allow( subject ).to receive(:on).and_return(Beaker::Result.new({},''))
545
+ allow(subject).to receive(:options).and_return(opts)
546
+ allow(subject).to receive(:hosts).and_return(hosts)
547
+ allow(subject).to receive(:on).and_return(Beaker::Result.new({}, ''))
508
548
  end
509
549
  context 'on el-6' do
510
550
  let(:platform) { Beaker::Platform.new('el-6-i386') }
511
551
  it 'installs' do
512
- expect(hosts[0]).to receive(:install_package_with_rpm).with(/puppet-release-el-6\.noarch\.rpm/, '--replacepkgs', {:package_proxy=>false})
552
+ expect(hosts[0]).to receive(:install_package_with_rpm).with(/puppet-release-el-6\.noarch\.rpm/,
553
+ '--replacepkgs', { package_proxy: false })
513
554
  expect(hosts[0]).to receive(:install_package).with('puppet')
514
555
  subject.install_puppet
515
556
  end
516
557
  it 'installs in parallel' do
517
558
  InParallel::InParallelExecutor.logger = logger
518
559
  FakeFS.deactivate!
519
- hosts.each{ |host|
520
- allow(host).to receive(:install_package_with_rpm).with(/puppet-release-el-6\.noarch\.rpm/, '--replacepkgs', {:package_proxy=>false})
560
+ hosts.each do |host|
561
+ allow(host).to receive(:install_package_with_rpm).with(/puppet-release-el-6\.noarch\.rpm/, '--replacepkgs',
562
+ { package_proxy: false })
521
563
  allow(host).to receive(:install_package).with('puppet')
522
- }
564
+ end
523
565
  opts[:run_in_parallel] = true
524
566
  # This will only get hit if forking processes is supported and at least 2 items are being submitted to run in parallel
525
- expect( InParallel::InParallelExecutor ).to receive(:_execute_in_parallel).with(any_args).and_call_original.exactly(3).times
567
+ expect(InParallel::InParallelExecutor).to receive(:_execute_in_parallel).with(any_args).and_call_original.exactly(3).times
526
568
  subject.install_puppet(opts)
527
569
  end
528
570
  it 'installs specific version of puppet when passed :version' do
529
571
  expect(hosts[0]).to receive(:install_package).with('puppet-3')
530
- subject.install_puppet( :version => '3' )
572
+ subject.install_puppet(version: '3')
531
573
  end
532
574
  it 'can install specific versions of puppets dependencies' do
533
575
  expect(hosts[0]).to receive(:install_package).with('puppet-3')
534
576
  expect(hosts[0]).to receive(:install_package).with('hiera-2001')
535
577
  expect(hosts[0]).to receive(:install_package).with('facter-1999')
536
- subject.install_puppet( :version => '3', :facter_version => '1999', :hiera_version => '2001' )
578
+ subject.install_puppet(version: '3', facter_version: '1999', hiera_version: '2001')
537
579
  end
538
580
  end
539
581
  context 'on el-5' do
540
582
  let(:platform) { Beaker::Platform.new('el-5-i386') }
541
583
  it 'installs' do
542
- expect(hosts[0]).to receive(:install_package_with_rpm).with(%r{puppet-release-el-5.noarch.rpm}, '--replacepkgs', {:package_proxy=>false})
584
+ expect(hosts[0]).to receive(:install_package_with_rpm).with(/puppet-release-el-5.noarch.rpm/, '--replacepkgs',
585
+ { package_proxy: false })
543
586
  expect(hosts[0]).to receive(:install_package).with('puppet')
544
587
  subject.install_puppet
545
588
  end
@@ -547,7 +590,8 @@ describe ClassMixedWithDSLInstallUtils do
547
590
  context 'on fedora' do
548
591
  let(:platform) { Beaker::Platform.new('fedora-18-x86_84') }
549
592
  it 'installs' do
550
- expect(hosts[0]).to receive(:install_package_with_rpm).with(%r{puppet-release-fedora-18.noarch.rpm}, '--replacepkgs', {:package_proxy=>false})
593
+ expect(hosts[0]).to receive(:install_package_with_rpm).with(/puppet-release-fedora-18.noarch.rpm/,
594
+ '--replacepkgs', { package_proxy: false })
551
595
  expect(hosts[0]).to receive(:install_package).with('puppet')
552
596
  subject.install_puppet
553
597
  end
@@ -559,6 +603,13 @@ describe ClassMixedWithDSLInstallUtils do
559
603
  subject.install_puppet
560
604
  end
561
605
  end
606
+ context 'on freebsd' do
607
+ let(:platform) { Beaker::Platform.new('freebsd-13-amd64') }
608
+ it 'installs' do
609
+ expect(hosts[0]).to receive(:install_package).with('sysutils/puppet7')
610
+ subject.install_puppet
611
+ end
612
+ end
562
613
  context 'on debian' do
563
614
  PlatformHelpers::DEBIANPLATFORMS.each do |platform|
564
615
  let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
@@ -573,14 +624,14 @@ describe ClassMixedWithDSLInstallUtils do
573
624
  it 'installs specific version of puppet when passed :version' do
574
625
  expect(hosts[0]).to receive(:install_package).with('puppet=3-1puppetlabs1')
575
626
  expect(hosts[0]).to receive(:install_package).with('puppet-common=3-1puppetlabs1')
576
- subject.install_puppet( :version => '3' )
627
+ subject.install_puppet(version: '3')
577
628
  end
578
629
  it 'can install specific versions of puppets dependencies' do
579
630
  expect(hosts[0]).to receive(:install_package).with('facter=1999-1puppetlabs1')
580
631
  expect(hosts[0]).to receive(:install_package).with('hiera=2001-1puppetlabs1')
581
632
  expect(hosts[0]).to receive(:install_package).with('puppet-common=3-1puppetlabs1')
582
633
  expect(hosts[0]).to receive(:install_package).with('puppet=3-1puppetlabs1')
583
- subject.install_puppet( :version => '3', :facter_version => '1999', :hiera_version => '2001' )
634
+ subject.install_puppet(version: '3', facter_version: '1999', hiera_version: '2001')
584
635
  end
585
636
  end
586
637
  context 'on windows' do
@@ -589,37 +640,40 @@ describe ClassMixedWithDSLInstallUtils do
589
640
  before :each do
590
641
  allow(winhost).to receive(:tmpdir).and_return(win_temp)
591
642
  allow(winhost).to receive(:is_cygwin?).and_return(true)
592
- allow(subject).to receive(:link_exists?).and_return( true )
643
+ allow(subject).to receive(:link_exists?).and_return(true)
593
644
  allow(subject).to receive(:install_msi_on).with(any_args)
594
645
  end
595
646
 
596
647
  it 'installs specific version of puppet when passed :version' do
597
648
  hosts.each do |host|
598
- if host != winhost
599
- allow(subject).to receive(:on).with(host, anything)
600
- else
649
+ if host == winhost
601
650
  expect(subject).to receive(:on).with(winhost, "curl -o \"#{win_temp}\\puppet-3.msi\" -O http://downloads.puppet.com/windows/puppet-3.msi")
602
- expect(subject).to receive(:on).with(winhost, " echo 'export PATH=$PATH:\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\"' > /etc/bash.bashrc ")
603
- expect(subject).to receive(:install_msi_on).with(winhost, "#{win_temp}\\puppet-3.msi", {}, {:debug => nil}).exactly(1).times
651
+ expect(subject).to receive(:on).with(winhost,
652
+ " echo 'export PATH=$PATH:\"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/bin\":\"/cygdrive/c/Program Files/Puppet Labs/Puppet/bin\"' > /etc/bash.bashrc ")
653
+ expect(subject).to receive(:install_msi_on).with(winhost, "#{win_temp}\\puppet-3.msi", {},
654
+ { debug: nil }).exactly(1).times
655
+ else
656
+ allow(subject).to receive(:on).with(host, anything)
604
657
  end
605
658
  end
606
- subject.install_puppet(:version => '3')
659
+ subject.install_puppet(version: '3')
607
660
  end
608
661
  it 'installs from custom url when passed :win_download_url' do
609
662
  hosts.each do |host|
610
- if host != winhost
611
- allow(subject).to receive(:on).with(host, anything)
612
- else
663
+ if host == winhost
613
664
  expect(subject).to receive(:on).with(winhost, "curl -o \"#{win_temp}\\puppet-3.msi\" -O http://nightlies.puppet.com/puppet-latest/repos/windows/puppet-3.msi")
614
- expect(subject).to receive(:install_msi_on).with(winhost, "#{win_temp}\\puppet-3.msi", {}, {:debug => nil})
665
+ expect(subject).to receive(:install_msi_on).with(winhost, "#{win_temp}\\puppet-3.msi", {}, { debug: nil })
666
+ else
667
+ allow(subject).to receive(:on).with(host, anything)
615
668
  end
616
669
  end
617
- subject.install_puppet( :version => '3', :win_download_url => 'http://nightlies.puppet.com/puppet-latest/repos/windows' )
670
+ subject.install_puppet(version: '3',
671
+ win_download_url: 'http://nightlies.puppet.com/puppet-latest/repos/windows')
618
672
  end
619
673
  end
620
674
  describe 'on unsupported platforms' do
621
675
  let(:platform) { Beaker::Platform.new('solaris-11-x86_64') }
622
- let(:host) { make_host('henry', :platform => 'solaris-11-x86_64') }
676
+ let(:host) { make_host('henry', platform: 'solaris-11-x86_64') }
623
677
  let(:hosts) { [host] }
624
678
  it 'by default raises an error' do
625
679
  expect(subject).to_not receive(:on)
@@ -628,10 +682,10 @@ describe ClassMixedWithDSLInstallUtils do
628
682
  it 'falls back to installing from gem when given :default_action => "gem_install"' do
629
683
  result = double
630
684
  gem_env_string = '{"RubyGems Environment": [ {"GEM PATHS": [], "EXECUTABLE DIRECTORY": "/does/not/exist" } ] }'
631
- allow( result ).to receive(:stdout).and_return gem_env_string
685
+ allow(result).to receive(:stdout).and_return gem_env_string
632
686
  allow(subject).to receive(:on).with(host, /gem environment/).and_return result
633
687
  expect(subject).to receive(:on).with(host, /gem install/)
634
- subject.install_puppet :default_action => 'gem_install'
688
+ subject.install_puppet default_action: 'gem_install'
635
689
  end
636
690
  end
637
691
  end
@@ -640,13 +694,13 @@ describe ClassMixedWithDSLInstallUtils do
640
694
  context 'on debian' do
641
695
  PlatformHelpers::DEBIANPLATFORMS.each do |platform|
642
696
  let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
643
- let(:host) { make_host('testbox.test.local', :platform => "#{platform}") }
697
+ let(:host) { make_host('testbox.test.local', platform: "#{platform}") }
644
698
  it "it sets the puppet.conf file to the provided config on #{platform}" do
645
- config = { 'main' => {'server' => 'testbox.test.local'} }
699
+ config = { 'main' => { 'server' => 'testbox.test.local' } }
646
700
  expected_config_string = "[main]\nserver=testbox.test.local\n\n"
647
701
 
648
- expect( subject ).to receive( :create_remote_file ).with(
649
- host, anything, expected_config_string
702
+ expect(subject).to receive(:create_remote_file).with(
703
+ host, anything, expected_config_string
650
704
  )
651
705
  subject.configure_puppet_on(host, config)
652
706
  end
@@ -654,13 +708,13 @@ describe ClassMixedWithDSLInstallUtils do
654
708
  end
655
709
  context 'on windows' do
656
710
  let(:platform) { 'windows-2008R2-amd64' }
657
- let(:host) { make_host('testbox.test.local', :platform => 'windows-2008R2-amd64') }
711
+ let(:host) { make_host('testbox.test.local', platform: 'windows-2008R2-amd64') }
658
712
 
659
713
  it 'it sets the puppet.conf file to the provided config' do
660
- config = { 'main' => {'server' => 'testbox.test.local'} }
714
+ config = { 'main' => { 'server' => 'testbox.test.local' } }
661
715
  expected_config_string = "[main]\nserver=testbox.test.local\n\n"
662
716
 
663
- expect( subject ).to receive( :create_remote_file ).with(
717
+ expect(subject).to receive(:create_remote_file).with(
664
718
  host, anything, expected_config_string
665
719
  )
666
720
  subject.configure_puppet_on(host, config)
@@ -670,22 +724,22 @@ describe ClassMixedWithDSLInstallUtils do
670
724
 
671
725
  describe 'configure_puppet' do
672
726
  let(:hosts) do
673
- make_hosts({:platform => platform })
727
+ make_hosts({ platform: platform })
674
728
  end
675
729
 
676
730
  before do
677
- allow( subject ).to receive(:hosts).and_return(hosts)
678
- allow( subject ).to receive(:on).and_return(Beaker::Result.new({},''))
731
+ allow(subject).to receive(:hosts).and_return(hosts)
732
+ allow(subject).to receive(:on).and_return(Beaker::Result.new({}, ''))
679
733
  end
680
734
 
681
735
  context 'on debian' do
682
736
  PlatformHelpers::DEBIANPLATFORMS.each do |platform|
683
737
  let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
684
738
  it "calls configure_puppet_on correctly on #{platform}" do
685
- config = { 'main' => {'server' => 'testbox.test.local'} }
686
- expect( subject ).to receive( :configure_puppet_on ).with(
687
- anything, config
688
- ).exactly( hosts.length ).times
739
+ config = { 'main' => { 'server' => 'testbox.test.local' } }
740
+ expect(subject).to receive(:configure_puppet_on).with(
741
+ anything, config
742
+ ).exactly(hosts.length).times
689
743
  subject.configure_puppet(config)
690
744
  end
691
745
  end
@@ -695,157 +749,154 @@ describe ClassMixedWithDSLInstallUtils do
695
749
  let(:platform) { 'windows-2008R2-amd64' }
696
750
 
697
751
  it 'calls configure_puppet_on correctly' do
698
- config = { 'main' => {'server' => 'testbox.test.local'} }
699
- expect( subject ).to receive( :configure_puppet_on ).with(
752
+ config = { 'main' => { 'server' => 'testbox.test.local' } }
753
+ expect(subject).to receive(:configure_puppet_on).with(
700
754
  anything, config
701
- ).exactly( hosts.length ).times
755
+ ).exactly(hosts.length).times
702
756
  subject.configure_puppet(config)
703
757
  end
704
758
  end
705
759
  end
706
760
 
707
- describe "#install_puppetlabs_release_repo" do
708
- let( :platform ) { Beaker::Platform.new('solaris-7-i386') }
709
- let( :host ) do
761
+ describe '#install_puppetlabs_release_repo' do
762
+ let(:platform) { Beaker::Platform.new('solaris-7-i386') }
763
+ let(:host) do
710
764
  FakeHost.create('fakevm', platform.to_s)
711
765
  end
712
766
 
713
767
  before do
714
768
  allow(subject).to receive(:options) { opts }
715
- allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
769
+ allow(subject).to receive(:configure_foss_defaults_on).and_return(true)
716
770
  end
717
771
 
718
- describe "When host is unsupported platform" do
719
- let( :platform ) { Beaker::Platform.new('solaris-7-i386') }
772
+ describe 'When host is unsupported platform' do
773
+ let(:platform) { Beaker::Platform.new('solaris-7-i386') }
720
774
 
721
- it "raises an exception." do
722
- expect{
775
+ it 'raises an exception.' do
776
+ expect do
723
777
  subject.install_puppetlabs_release_repo host
724
- }.to raise_error(RuntimeError, /No repository installation step for/)
778
+ end.to raise_error(RuntimeError, /No repository installation step for/)
725
779
  end
726
780
  end
727
781
 
728
- describe "When host is a debian-like platform" do
729
- let( :platform ) { Beaker::Platform.new('debian-7-i386') }
782
+ describe 'When host is a debian-like platform' do
783
+ let(:platform) { Beaker::Platform.new('debian-7-i386') }
730
784
 
731
- it "downloads a deb file, installs, and updates the apt cache." do
732
- expect(subject).to receive(:on).with( host, /wget .*/ ).ordered
733
- expect(subject).to receive(:on).with( host, /dpkg .*/ ).ordered
734
- expect(subject).to receive(:on).with( host, "apt-get update" ).ordered
785
+ it 'downloads a deb file, installs, and updates the apt cache.' do
786
+ expect(subject).to receive(:on).with(host, /wget .*/).ordered
787
+ expect(subject).to receive(:on).with(host, /dpkg .*/).ordered
788
+ expect(subject).to receive(:on).with(host, 'apt-get update').ordered
735
789
  subject.install_puppetlabs_release_repo host
736
790
  end
737
-
738
791
  end
739
-
740
792
  end
741
793
 
742
794
  describe '#install_puppetlabs_release_repo_on' do
743
- let( :host ) do
744
- FakeHost.create( 'fakevm', platform.to_s )
795
+ let(:host) do
796
+ FakeHost.create('fakevm', platform.to_s)
745
797
  end
746
798
 
747
799
  before :each do
748
- allow( subject ).to receive( :options ) { opts }
800
+ allow(subject).to receive(:options) { opts }
749
801
  end
750
802
 
751
803
  context 'on el 7' do
752
- let( :platform ) { Beaker::Platform.new( 'el-7-x86_64' ) }
804
+ let(:platform) { Beaker::Platform.new('el-7-x86_64') }
753
805
  it 'returns the correct url when repo is set to puppet8' do
754
- expect( host ).to receive( :install_package_with_rpm ).with( /puppet8-release-el-7\.noarch\.rpm$/, '--replacepkgs', {:package_proxy=>false} )
755
- subject.install_puppetlabs_release_repo_on( host, 'puppet8')
806
+ expect(host).to receive(:install_package_with_rpm).with(/puppet8-release-el-7\.noarch\.rpm$/,
807
+ '--replacepkgs', { package_proxy: false })
808
+ subject.install_puppetlabs_release_repo_on(host, 'puppet8')
756
809
  end
757
810
  it 'returns the correct url when opts[:puppet_collection] is set to puppet14' do
758
- expect( host ).to receive( :install_package_with_rpm ).with( /puppet14-release-el-7\.noarch\.rpm$/, '--replacepkgs', {:package_proxy=>false} )
759
- subject.install_puppetlabs_release_repo_on( host, nil, {:puppet_collection => 'puppet14'})
811
+ expect(host).to receive(:install_package_with_rpm).with(/puppet14-release-el-7\.noarch\.rpm$/,
812
+ '--replacepkgs', { package_proxy: false })
813
+ subject.install_puppetlabs_release_repo_on(host, nil, { puppet_collection: 'puppet14' })
760
814
  end
761
815
  it 'returns the correct url when both repo and opts[:puppet_collection] are nil' do
762
- expect( host ).to receive( :install_package_with_rpm ).with( /puppet-release-el-7\.noarch\.rpm$/, '--replacepkgs', {:package_proxy=>false} )
763
- subject.install_puppetlabs_release_repo_on( host )
816
+ expect(host).to receive(:install_package_with_rpm).with(/puppet-release-el-7\.noarch\.rpm$/,
817
+ '--replacepkgs', { package_proxy: false })
818
+ subject.install_puppetlabs_release_repo_on(host)
764
819
  end
765
820
  end
766
821
 
767
822
  context 'on debian 8' do
768
- let( :platform ) { Beaker::Platform.new( 'debian-8-i386' ) }
823
+ let(:platform) { Beaker::Platform.new('debian-8-i386') }
769
824
  it 'returns the correct url when repo is set to puppet4' do
770
- expect( subject ).to receive( :on ).with( host, /puppet4-release-jessie\.deb$/ ).once
771
- expect( subject ).to receive( :on ).with( host, "dpkg -i --force-all /tmp/puppet.deb" ).once
772
- expect( subject ).to receive( :on ).with( host, "apt-get update" ).once
773
- subject.install_puppetlabs_release_repo_on( host, 'puppet4' )
825
+ expect(subject).to receive(:on).with(host, /puppet4-release-jessie\.deb$/).once
826
+ expect(subject).to receive(:on).with(host, 'dpkg -i --force-all /tmp/puppet.deb').once
827
+ expect(subject).to receive(:on).with(host, 'apt-get update').once
828
+ subject.install_puppetlabs_release_repo_on(host, 'puppet4')
774
829
  end
775
830
  it 'returns the correct url when opts[:puppet_collection] is set to puppet7' do
776
- expect( subject ).to receive( :on ).with( host, /puppet7-release-jessie\.deb$/ ).once
777
- expect( subject ).to receive( :on ).with( host, "dpkg -i --force-all /tmp/puppet.deb" ).once
778
- expect( subject ).to receive( :on ).with( host, "apt-get update" ).once
779
- subject.install_puppetlabs_release_repo_on( host, nil, {:puppet_collection => 'puppet7'} )
831
+ expect(subject).to receive(:on).with(host, /puppet7-release-jessie\.deb$/).once
832
+ expect(subject).to receive(:on).with(host, 'dpkg -i --force-all /tmp/puppet.deb').once
833
+ expect(subject).to receive(:on).with(host, 'apt-get update').once
834
+ subject.install_puppetlabs_release_repo_on(host, nil, { puppet_collection: 'puppet7' })
780
835
  end
781
836
  it 'returns the correct url when both repo and opts[:puppet_collection] are nil' do
782
- expect( subject ).to receive( :on ).with( host, /puppet-release-jessie\.deb$/ ).once
783
- expect( subject ).to receive( :on ).with( host, "dpkg -i --force-all /tmp/puppet.deb" ).once
784
- expect( subject ).to receive( :on ).with( host, "apt-get update" ).once
785
- subject.install_puppetlabs_release_repo_on( host )
837
+ expect(subject).to receive(:on).with(host, /puppet-release-jessie\.deb$/).once
838
+ expect(subject).to receive(:on).with(host, 'dpkg -i --force-all /tmp/puppet.deb').once
839
+ expect(subject).to receive(:on).with(host, 'apt-get update').once
840
+ subject.install_puppetlabs_release_repo_on(host)
786
841
  end
787
842
  end
788
843
 
789
-
790
844
  context 'on cisco platforms' do
791
845
  context 'version 5' do
792
- let( :platform ) { Beaker::Platform.new( 'cisco_nexus-7-x86_64' ) }
846
+ let(:platform) { Beaker::Platform.new('cisco_nexus-7-x86_64') }
793
847
 
794
848
  it 'calls host.install_package' do
795
- expect( host ).to receive( :install_package ).with( /\.rpm$/ )
796
- subject.install_puppetlabs_release_repo_on( host )
849
+ expect(host).to receive(:install_package).with(/\.rpm$/)
850
+ subject.install_puppetlabs_release_repo_on(host)
797
851
  end
798
852
  end
799
853
 
800
854
  context 'version 7' do
801
- let( :platform ) { Beaker::Platform.new( 'cisco_ios_xr-6-x86_64' ) }
855
+ let(:platform) { Beaker::Platform.new('cisco_ios_xr-6-x86_64') }
802
856
 
803
857
  it 'uses yum localinstall to install the package' do
804
- expect( subject ).to receive( :on ).with( host, /^yum.*localinstall.*\.rpm$/ )
805
- subject.install_puppetlabs_release_repo_on( host )
858
+ expect(subject).to receive(:on).with(host, /^yum.*localinstall.*\.rpm$/)
859
+ subject.install_puppetlabs_release_repo_on(host)
806
860
  end
807
861
  end
808
862
  end
809
-
810
863
  end
811
864
 
812
- describe "#install_puppetlabs_dev_repo" do
813
- let( :package_name ) { "puppet" }
814
- let( :package_version ) { "7.5.6" }
815
- let( :host ) do
865
+ describe '#install_puppetlabs_dev_repo' do
866
+ let(:package_name) { 'puppet' }
867
+ let(:package_version) { '7.5.6' }
868
+ let(:host) do
816
869
  h = FakeHost.create('fakvm', platform.to_s, opts)
817
- allow( h ).to receive( :link_exists? ).and_return( true )
870
+ allow(h).to receive(:link_exists?).and_return(true)
818
871
  h
819
872
  end
820
- let( :logger_double ) do
873
+ let(:logger_double) do
821
874
  logger_double = Object.new
822
875
  allow(logger_double).to receive(:debug)
823
876
  allow(logger_double).to receive(:trace)
824
- allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
877
+ allow(subject).to receive(:configure_foss_defaults_on).and_return(true)
825
878
  subject.instance_variable_set(:@logger, logger_double)
826
879
  logger_double
827
880
  end
828
881
 
829
- RSpec.shared_examples "install-dev-repo" do
830
-
882
+ RSpec.shared_examples 'install-dev-repo' do
831
883
  it "scp's files to SUT then modifies them with find-and-sed 2-hit combo" do
832
884
  allow(rez).to receive(:exit_code) { 0 }
833
885
  allow(subject).to receive(:link_exists?).and_return(true)
834
- expect(subject).to receive(:scp_to).with( host, repo_config, /.*/ ).ordered
886
+ expect(subject).to receive(:scp_to).with(host, repo_config, /.*/).ordered
835
887
  subject.install_puppetlabs_dev_repo host, package_name, package_version
836
888
  end
837
-
838
889
  end
839
890
 
840
- describe "When host is unsupported platform" do
841
- let( :platform ) { Beaker::Platform.new('solaris-7-i386') }
891
+ describe 'When host is unsupported platform' do
892
+ let(:platform) { Beaker::Platform.new('solaris-7-i386') }
842
893
 
843
- it "raises an exception." do
894
+ it 'raises an exception.' do
844
895
  # expect(subject).to receive(:on).with( host, /^mkdir -p .*$/ ).ordered
845
896
  allow(subject).to receive(:options) { opts }
846
- expect{
897
+ expect do
847
898
  subject.install_puppetlabs_dev_repo host, package_name, package_version
848
- }.to raise_error(RuntimeError, /No repository installation step for/)
899
+ end.to raise_error(RuntimeError, /No repository installation step for/)
849
900
  end
850
901
  end
851
902
 
@@ -854,161 +905,154 @@ describe ClassMixedWithDSLInstallUtils do
854
905
  # are expectations in the share examples, but aren't interesting
855
906
  # beyond those basic tests
856
907
  def stub_uninteresting_portions_of_install_puppetlabs_dev_repo!
857
- allow(subject).to receive(:scp_to).with( host, repo_config, /.*/ ).ordered
908
+ allow(subject).to receive(:scp_to).with(host, repo_config, /.*/).ordered
858
909
  end
859
910
 
860
- let( :repo_config ) { "repoconfig" }
861
- let( :repo_dir ) { "repodir" }
862
- let( :rez ) { double }
911
+ let(:repo_config) { 'repoconfig' }
912
+ let(:repo_dir) { 'repodir' }
913
+ let(:rez) { double }
863
914
 
864
915
  before do
865
916
  allow(subject).to receive(:fetch_http_file) { repo_config }
866
917
  allow(subject).to receive(:fetch_http_dir) { repo_dir }
867
- allow(subject).to receive(:on).with(host, "apt-get update") { }
918
+ allow(subject).to receive(:on).with(host, 'apt-get update') {}
868
919
  allow(subject).to receive(:options) { opts }
869
- allow(subject).to receive(:on).with( host, /^.* -d .*/, {:acceptable_exit_codes =>[0,1]} ).and_return(rez)
920
+ allow(subject).to receive(:on).with(host, /^.* -d .*/, { acceptable_exit_codes: [0, 1] }).and_return(rez)
870
921
  end
871
922
 
872
- describe "that are debian-like" do
923
+ describe 'that are debian-like' do
873
924
  PlatformHelpers::DEBIANPLATFORMS.each do |platform|
874
925
  let(:platform) { Beaker::Platform.new("#{platform}-ver-arch") }
875
926
  before { allow(subject).to receive(:link_exists?).and_return(true) }
876
927
 
877
- include_examples "install-dev-repo"
878
-
928
+ include_examples 'install-dev-repo'
879
929
  end
880
930
  end
881
931
 
882
- describe "that are redhat-like" do
883
- let( :platform ) { Beaker::Platform.new('el-7-i386') }
884
- include_examples "install-dev-repo"
932
+ describe 'that are redhat-like' do
933
+ let(:platform) { Beaker::Platform.new('el-7-i386') }
934
+ include_examples 'install-dev-repo'
885
935
  end
886
936
  end
887
937
  end
888
938
 
889
939
  describe '#install_packages_from_local_dev_repo' do
890
- let( :package_name ) { 'puppet-agent' }
891
- let( :platform ) { @platform || 'other' }
892
- let( :host ) do
940
+ let(:package_name) { 'puppet-agent' }
941
+ let(:platform) { @platform || 'other' }
942
+ let(:host) do
893
943
  FakeHost.create('fakvm', platform, opts)
894
944
  end
895
945
 
896
946
  before :each do
897
- allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
947
+ allow(subject).to receive(:configure_foss_defaults_on).and_return(true)
898
948
  end
899
949
 
900
950
  it 'sets the find command correctly for el-based systems' do
901
951
  @platform = 'el-1-3'
902
- expect( subject ).to receive( :on ).with( host, /\*\.rpm.+rpm\s-ivh/ )
903
- subject.install_packages_from_local_dev_repo( host, package_name )
952
+ expect(subject).to receive(:on).with(host, /\*\.rpm.+rpm\s-ivh/)
953
+ subject.install_packages_from_local_dev_repo(host, package_name)
904
954
  end
905
955
 
906
956
  it 'sets the find command correctly for debian-based systems' do
907
957
  @platform = 'debian-1-3'
908
- expect( subject ).to receive( :on ).with( host, /\*\.deb.+dpkg\s-i/ )
909
- subject.install_packages_from_local_dev_repo( host, package_name )
958
+ expect(subject).to receive(:on).with(host, /\*\.deb.+dpkg\s-i/)
959
+ subject.install_packages_from_local_dev_repo(host, package_name)
910
960
  end
911
961
 
912
962
  it 'fails correctly for systems not accounted for' do
913
963
  @platform = 'eos-1-3'
914
- expect{ subject.install_packages_from_local_dev_repo( host, package_name ) }.to raise_error RuntimeError
964
+ expect { subject.install_packages_from_local_dev_repo(host, package_name) }.to raise_error RuntimeError
915
965
  end
916
-
917
966
  end
918
967
 
919
968
  describe '#msi_link_path' do
920
- let( :opts ) { { :puppet_agent_version => 'VERSION', :win_download_url => 'http://downloads.puppet.com/windows' } }
921
- let( :platform ) { 'windows' }
922
- let( :host ) { { :platform => platform, 'dist' => 'puppet-agent-VERSION-x64' } }
969
+ let(:opts) { { puppet_agent_version: 'VERSION', win_download_url: 'http://downloads.puppet.com/windows' } }
970
+ let(:platform) { 'windows' }
971
+ let(:host) { { :platform => platform, 'dist' => 'puppet-agent-VERSION-x64' } }
923
972
 
924
973
  it 'returns the right link when puppet collection is set' do
925
- allow(subject).to receive(:link_exists?).with(anything()).and_return( true )
974
+ allow(subject).to receive(:link_exists?).with(anything).and_return(true)
926
975
 
927
- expect(subject.msi_link_path( host, opts.merge({:puppet_collection => 'puppet'}) )).to eq "#{opts[:win_download_url]}/puppet/puppet-agent-VERSION-x64.msi"
976
+ expect(subject.msi_link_path(host,
977
+ opts.merge({ puppet_collection: 'puppet' }))).to eq "#{opts[:win_download_url]}/puppet/puppet-agent-VERSION-x64.msi"
928
978
  end
929
979
 
930
980
  it 'returns the right link when puppet collection is not set' do
931
- expect(subject).to receive(:link_exists?).with(anything()).and_return( true )
981
+ expect(subject).to receive(:link_exists?).with(anything).and_return(true)
932
982
 
933
- expect(subject.msi_link_path( host, opts )).to eq "#{opts[:win_download_url]}/puppet-agent-VERSION-x64.msi"
983
+ expect(subject.msi_link_path(host, opts)).to eq "#{opts[:win_download_url]}/puppet-agent-VERSION-x64.msi"
934
984
  end
935
985
 
936
986
  it 'returns error when link incorrect' do
937
- allow(subject).to receive(:link_exists?).with(anything()).and_return( false )
987
+ allow(subject).to receive(:link_exists?).with(anything).and_return(false)
938
988
 
939
- expect{
940
- subject.msi_link_path( host, opts )
941
- }.to raise_error(RuntimeError, /Puppet MSI at http:\/\/downloads.puppet.com\/windows\/puppet-agent-VERSION-x64.msi does not exist!/)
989
+ expect do
990
+ subject.msi_link_path(host, opts)
991
+ end.to raise_error(RuntimeError,
992
+ %r{Puppet MSI at http://downloads.puppet.com/windows/puppet-agent-VERSION-x64.msi does not exist!})
942
993
  end
943
994
  end
944
995
 
945
996
  describe '#install_puppet_agent_from_msi_on' do
946
- let( :opts ) { { :puppet_agent_version => 'VERSION', :win_download_url => 'http://downloads.puppet.com/windows' } }
947
- let( :platform ) { 'windows' }
948
- let( :host ) { { :platform => platform } }
997
+ let(:opts) { { puppet_agent_version: 'VERSION', win_download_url: 'http://downloads.puppet.com/windows' } }
998
+ let(:platform) { 'windows' }
999
+ let(:host) { { platform: platform } }
949
1000
 
950
1001
  it 'uses x86 msi when host is_x86_64 and install_32 is set on the host' do
951
1002
  host['install_32'] = true
952
1003
 
953
- expect( host ).to receive( :is_x86_64? ).and_return( true )
954
- expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
955
-
956
- subject.install_puppet_agent_from_msi_on( host, opts )
957
- expect( host['dist'] ).to be == "puppet-agent-VERSION-x86"
1004
+ expect(host).to receive(:is_x86_64?).and_return(true)
1005
+ expect(subject).to receive(:install_a_puppet_msi_on).with(host, opts)
958
1006
 
1007
+ subject.install_puppet_agent_from_msi_on(host, opts)
1008
+ expect(host['dist']).to eq 'puppet-agent-VERSION-x86'
959
1009
  end
960
1010
 
961
1011
  it 'uses x86 msi when host is_x86_64 and install_32 is set on the options' do
962
1012
  opts['install_32'] = true
963
1013
 
964
- expect( host ).to receive( :is_x86_64? ).and_return( true )
965
- expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
966
-
967
- subject.install_puppet_agent_from_msi_on( host, opts )
968
- expect( host['dist'] ).to be == "puppet-agent-VERSION-x86"
1014
+ expect(host).to receive(:is_x86_64?).and_return(true)
1015
+ expect(subject).to receive(:install_a_puppet_msi_on).with(host, opts)
969
1016
 
1017
+ subject.install_puppet_agent_from_msi_on(host, opts)
1018
+ expect(host['dist']).to eq 'puppet-agent-VERSION-x86'
970
1019
  end
971
1020
 
972
1021
  it 'uses x86 msi when host is_x86_64 and ruby_arch is x86 on the host' do
973
1022
  host['ruby_arch'] = 'x86'
974
1023
 
975
- expect( host ).to receive( :is_x86_64? ).and_return( true )
976
- expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
977
-
978
- subject.install_puppet_agent_from_msi_on( host, opts )
979
- expect( host['dist'] ).to be == "puppet-agent-VERSION-x86"
1024
+ expect(host).to receive(:is_x86_64?).and_return(true)
1025
+ expect(subject).to receive(:install_a_puppet_msi_on).with(host, opts)
980
1026
 
1027
+ subject.install_puppet_agent_from_msi_on(host, opts)
1028
+ expect(host['dist']).to eq 'puppet-agent-VERSION-x86'
981
1029
  end
982
1030
 
983
1031
  it 'uses x86 msi when host !is_x86_64' do
1032
+ expect(host).to receive(:is_x86_64?).and_return(false)
1033
+ expect(subject).to receive(:install_a_puppet_msi_on).with(host, opts)
984
1034
 
985
- expect( host ).to receive( :is_x86_64? ).and_return( false )
986
- expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
987
-
988
- subject.install_puppet_agent_from_msi_on( host, opts )
989
- expect( host['dist'] ).to be == "puppet-agent-VERSION-x86"
990
-
1035
+ subject.install_puppet_agent_from_msi_on(host, opts)
1036
+ expect(host['dist']).to eq 'puppet-agent-VERSION-x86'
991
1037
  end
992
1038
 
993
1039
  it 'uses x64 msi when host is_x86_64, no install_32 and ruby_arch != x86' do
1040
+ expect(host).to receive(:is_x86_64?).and_return(true)
1041
+ expect(subject).to receive(:install_a_puppet_msi_on).with(host, opts)
994
1042
 
995
- expect( host ).to receive( :is_x86_64? ).and_return( true )
996
- expect( subject ).to receive( :install_a_puppet_msi_on ).with( host, opts )
997
-
998
- subject.install_puppet_agent_from_msi_on( host, opts )
999
- expect( host['dist'] ).to be == "puppet-agent-VERSION-x64"
1000
-
1043
+ subject.install_puppet_agent_from_msi_on(host, opts)
1044
+ expect(host['dist']).to eq 'puppet-agent-VERSION-x64'
1001
1045
  end
1002
1046
  end
1003
1047
 
1004
1048
  describe '#install_cert_on_windows' do
1005
1049
  before do
1006
- allow(subject).to receive(:on).and_return(Beaker::Result.new({},''))
1050
+ allow(subject).to receive(:on).and_return(Beaker::Result.new({}, ''))
1007
1051
  end
1008
1052
 
1009
1053
  context 'on windows' do
1010
1054
  let(:platform) { 'windows-2008R2-amd64' }
1011
- let(:host) { make_host('testbox.test.local', :platform => 'windows-2008R2-amd64') }
1055
+ let(:host) { make_host('testbox.test.local', platform: 'windows-2008R2-amd64') }
1012
1056
 
1013
1057
  it 'should install all 3 certs' do
1014
1058
  cert = 'geotrust_global_ca'
@@ -1048,452 +1092,13 @@ describe ClassMixedWithDSLInstallUtils do
1048
1092
  end
1049
1093
  end
1050
1094
 
1051
- describe '#install_puppet_agent_dev_repo_on' do
1052
- let( :package_name ) { 'puppet-agent' }
1053
- let( :platform ) { @platform || 'other' }
1054
- let( :host ) do
1055
- FakeHost.create( 'fakvm', platform, opts )
1056
- end
1057
-
1058
- before :each do
1059
- allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
1060
- end
1061
-
1062
- it 'raises an exception when host platform is unsupported' do
1063
- platform = Object.new()
1064
- allow(platform).to receive(:to_array) { ['ptan', '5', 'x4']}
1065
- host = basic_hosts.first
1066
- host['platform'] = platform
1067
- opts = { :version => '0.1.0' }
1068
- allow( subject ).to receive( :options ).and_return( {} )
1069
-
1070
- expect{
1071
- subject.install_puppet_agent_dev_repo_on( host, opts )
1072
- }.to raise_error(RuntimeError, /No repository installation step for/)
1073
- end
1074
-
1075
- it 'runs the correct install for el-based platforms' do
1076
- platform = Object.new()
1077
- allow(platform).to receive(:to_array) { ['el', '5', 'x4']}
1078
- host = basic_hosts.first
1079
- host['platform'] = platform
1080
- sha_value = 'ereiuwoiur'
1081
- opts = { :version => '0.1.0', :puppet_agent_sha => sha_value }
1082
- allow( subject ).to receive( :options ).and_return( {} )
1083
-
1084
- expect( subject ).to receive( :install_puppetlabs_dev_repo ).with(
1085
- host, 'puppet-agent', sha_value, nil, anything )
1086
- expect( host ).to receive( :install_package ).with( 'puppet-agent' )
1087
-
1088
- subject.install_puppet_agent_dev_repo_on( host, opts )
1089
- end
1090
-
1091
- it 'runs the correct install for el-based platforms on s390x architectures' do
1092
- platform = Object.new()
1093
- allow(platform).to receive(:to_array) { ['el', '5', 's390x'] }
1094
- host = basic_hosts.first
1095
- host['platform'] = platform
1096
- sha_value = 'ereiuwoiur'
1097
- opts = { :version => '0.1.0', :puppet_agent_sha => sha_value }
1098
- allow( subject ).to receive( :options ).and_return( {} )
1099
-
1100
- release_path_end = 'fake_release_path_end'
1101
- release_file = 'fake_29835_release_file'
1102
- expect( host ).to receive( :puppet_agent_dev_package_info ).and_return(
1103
- [ release_path_end, release_file ] )
1104
-
1105
- expect(subject).not_to receive(:install_puppetlabs_dev_repo)
1106
- expect(host).not_to receive(:install_package)
1107
-
1108
- expect(subject).to receive(:fetch_http_file).once.with(/#{release_path_end}$/, release_file, /\/el$/)
1109
- expect(subject).to receive(:scp_to).once.with(host, /#{release_file}$/, anything)
1110
- expect(subject).to receive(:on).ordered.with(host, /rpm -ivh.*#{release_file}$/)
1111
-
1112
- subject.install_puppet_agent_dev_repo_on( host, opts )
1113
- end
1114
-
1115
- it 'runs the correct agent install for el-based platforms on ec2 hypervisor' do
1116
- platform = Object.new()
1117
- allow(platform).to receive(:to_array) { ['el', '5', 'x4'] }
1118
- host = basic_hosts.first
1119
- host['platform'] = platform
1120
- host['hypervisor'] = 'ec2'
1121
- sha_value = 'ereiuwoiur'
1122
- opts = { :version => '0.1.0', :puppet_agent_sha => sha_value }
1123
- allow( subject ).to receive( :options ).and_return( {} )
1124
-
1125
- release_path_end = 'fake_release_path_end'
1126
- release_file = 'fake_29835_release_file'
1127
- expect( host ).to receive( :puppet_agent_dev_package_info ).and_return(
1128
- [ release_path_end, release_file ] )
1129
-
1130
- expect(subject).not_to receive(:install_puppetlabs_dev_repo)
1131
- expect(host).not_to receive(:install_package)
1132
-
1133
- expect(subject).to receive(:fetch_http_file).once.with(/#{release_path_end}$/, release_file, /\/el$/)
1134
- expect(subject).to receive(:scp_to).once.with(host, /#{release_file}$/, anything)
1135
- expect(subject).to receive(:on).ordered.with(host, /rpm -ivh.*#{release_file}$/)
1136
-
1137
- subject.install_puppet_agent_dev_repo_on( host, opts )
1138
- end
1139
-
1140
- it 'runs the correct install for debian-based platforms' do
1141
- platform = Object.new()
1142
- allow(platform).to receive(:to_array) { ['debian', '5', 'x4']}
1143
- host = basic_hosts.first
1144
- host['platform'] = platform
1145
- sha_value = 'ereigregerge'
1146
- opts = { :version => '0.1.0', :puppet_agent_sha => sha_value }
1147
- allow( subject ).to receive( :options ).and_return( {} )
1148
-
1149
- expect( subject ).to receive( :install_puppetlabs_dev_repo ).with(
1150
- host, 'puppet-agent', sha_value, nil, anything )
1151
- expect( host ).to receive( :install_package ).with( 'puppet-agent' )
1152
-
1153
- subject.install_puppet_agent_dev_repo_on( host, opts )
1154
- end
1155
-
1156
- it 'runs the correct install for windows platforms' do
1157
- host = winhost
1158
- external_copy_base = 'tmp_install_windows_copy_base_1325'
1159
- allow( host ).to receive( :external_copy_base ).and_return( external_copy_base )
1160
- opts = { :version => '0.1.0' }
1161
- allow( subject ).to receive( :options ).and_return( {} )
1162
- copied_path = "#{win_temp}\\puppet-agent-0.1.0-x64.msi"
1163
- mock_echo = Object.new()
1164
- allow( mock_echo ).to receive( :raw_output ).and_return( copied_path )
1165
-
1166
- expect(subject).to receive(:fetch_http_file).once.with(/\/windows$/, 'puppet-agent-0.1.0-x64.msi', /\/windows$/)
1167
- expect(subject).to receive(:scp_to).once.with(host, /\/puppet-agent-0.1.0-x64.msi$/, /#{external_copy_base}/)
1168
- expect(subject).to receive(:install_msi_on).with(host, copied_path, {}, {:debug => nil}).once
1169
- expect(subject).to receive(:on).ordered.with(host, /echo/).and_return(mock_echo)
1170
-
1171
- subject.install_puppet_agent_dev_repo_on( host, opts )
1172
- end
1173
-
1174
- it 'runs the correct install for osx platforms' do
1175
- platform = Object.new()
1176
- allow(platform).to receive(:to_array) { ['osx', '10.9', 'x86_64', 'mavericks']}
1177
- host = machost
1178
- host['platform'] = platform
1179
- sha_value = 'runs the correct install for osx platforms'
1180
- copy_dir_external = 'fake_15_copy_dir_external'
1181
- opts = {
1182
- :version => '0.1.0',
1183
- :puppet_agent_sha => sha_value,
1184
- :copy_dir_external => copy_dir_external
1185
- }
1186
-
1187
- release_path_end = 'fake_release_path_end'
1188
- release_file = 'fake_29835_release_file'
1189
- expect( host ).to receive( :puppet_agent_dev_package_info ).and_return(
1190
- [ release_path_end, release_file ] )
1191
-
1192
- expect(subject).to receive(:fetch_http_file).once.with(/#{release_path_end}$/, release_file, /\/osx$/)
1193
- expect(subject).to receive(:scp_to).once.with(host, /#{release_file}$/, copy_dir_external)
1194
- # the star is necessary, as that's not the entire filename, & we rely on
1195
- # the globbing to get this right on OSX SUTs
1196
- expect(host).to receive( :install_package ).with( /^puppet-agent-0.1.0\*$/ )
1197
-
1198
- subject.install_puppet_agent_dev_repo_on( host, opts )
1199
- end
1200
-
1201
- it 'runs the correct install for solaris platforms' do
1202
- @platform = 'solaris-10-x86_64'
1203
- opts = { :version => '0.1.0' }
1204
- allow( subject ).to receive( :options ).and_return( {} )
1205
-
1206
- release_path_end = 'fake_release_path_end'
1207
- release_file = 'fake_sol10_8495_release_file'
1208
- expect( host ).to receive( :puppet_agent_dev_package_info ).and_return(
1209
- [ release_path_end, release_file ] )
1210
-
1211
- expect( subject ).to receive( :fetch_http_file ).once.with(
1212
- /#{release_path_end}$/, release_file, anything )
1213
- expect( subject ).to receive( :scp_to ).once.with(
1214
- host, /#{release_file}$/, anything )
1215
-
1216
- expect( host ).to receive( :solaris_install_local_package )
1217
-
1218
- allow( subject ).to receive( :configure_type_defaults_on )
1219
- subject.install_puppet_agent_dev_repo_on( host, opts )
1220
- end
1221
-
1222
- it 'allows you to override the local copy directory' do
1223
- # only applies to hosts that don't go down the
1224
- # install_puppetlabs_dev_repo route
1225
- platform = Object.new()
1226
- allow( platform ).to receive( :to_array ) { ['eos', '5', 'x4'] }
1227
- host = eoshost
1228
- host['platform'] = platform
1229
- sha_value = 'dahdahdahdah'
1230
- copy_base_local_override = 'face'
1231
- opts = {
1232
- :version => '0.1.0',
1233
- :copy_base_local => copy_base_local_override,
1234
- :puppet_agent_sha => sha_value
1235
- }
1236
- allow( subject ).to receive( :options ).and_return( {} )
1237
-
1238
- allow( host ).to receive( :puppet_agent_dev_package_info ).and_return( ['', ''] )
1239
-
1240
- allow( host ).to receive( :get_remote_file).once.with(anything)
1241
- allow( host ).to receive( :install_from_file )
1242
-
1243
- subject.install_puppet_agent_dev_repo_on( host, opts )
1244
- end
1245
-
1246
- it 'allows you to override the external copy directory' do
1247
- platform = Object.new()
1248
- allow(platform).to receive(:to_array) { ['osx', '5', 'x4']}
1249
- host = basic_hosts.first
1250
- host['platform'] = platform
1251
- copy_dir_custom = 'muppetsBB8-1435'
1252
- opts = { :version => '0.1.0', :copy_dir_external => copy_dir_custom }
1253
- allow( subject ).to receive( :options ).and_return( {} )
1254
-
1255
- allow( host ).to receive( :puppet_agent_dev_package_info ).and_return( ['', ''] )
1256
-
1257
- allow( subject ).to receive( :fetch_http_file ).once
1258
- expect( subject ).to receive( :scp_to ).once.with(
1259
- host, anything, /#{copy_dir_custom}/ )
1260
- allow( host ).to receive( :install_package )
1261
-
1262
- subject.install_puppet_agent_dev_repo_on( host, opts )
1263
- end
1264
-
1265
- it 'copies package to the cygwin root directory and installs it' do
1266
- @platform = 'windows-7-x86_64'
1267
- expect( subject ).to receive( :install_msi_on ).with( any_args )
1268
- copy_base = 'copy_base_cygwin'
1269
- allow( host ).to receive( :external_copy_base ).and_return( copy_base )
1270
- expect( subject ).to receive( :scp_to ).with( host, /puppet-agent-1\.0\.0-x64\.msi/, /#{copy_base}/ )
1271
- expect( subject ).to receive( :configure_type_defaults_on ).with(host)
1272
- expect( subject ).to receive( :fetch_http_file ).with( /[^\/]\z/, anything, anything )
1273
- subject.install_puppet_agent_dev_repo_on( host, opts.merge({ :puppet_agent_version => '1.0.0' }) )
1274
- end
1275
-
1276
- it 'installs on different hosts without erroring' do
1277
- mhosts = hosts
1278
- mhosts[3] = eoshost
1279
-
1280
- mhosts.each_with_index do |host, index|
1281
- platform = Object.new()
1282
- if index == 0
1283
- allow(platform).to receive(:to_array) { ['solaris', '5', 'x4']}
1284
- allow(host).to receive(:external_copy_base) {'/host0'}
1285
- elsif index == 1
1286
- allow(platform).to receive(:to_array) { ['windows', '5', 'x4']}
1287
- allow(host).to receive(:external_copy_base) {'/host1'}
1288
- elsif index == 2
1289
- allow(platform).to receive(:to_array) { ['osx', '5', 'x4']}
1290
- allow(host).to receive(:external_copy_base) {'/host2'}
1291
- elsif index == 3
1292
- allow(platform).to receive(:to_array) { ['eos', '5', 'x4']}
1293
- allow(host).to receive(:external_copy_base) {'/host3'}
1294
- end
1295
- host['platform'] = platform
1296
- allow(host).to receive(:puppet_agent_dev_package_info).with(any_args).and_return(["test", "blah"])
1297
- end
1298
-
1299
- expect( subject ).to receive(:add_role).with( any_args ).exactly(mhosts.length).times
1300
-
1301
- expect( subject ).to receive(:fetch_http_file).with( any_args ).exactly(3).times
1302
- expect( subject ).to receive(:scp_to).with( any_args ).exactly(3).times
1303
-
1304
- expect( subject ).to receive(:install_msi_on).with( mhosts[1], 'xyz', {}, anything).exactly(1).times
1305
- expect( mhosts[0] ).to receive(:solaris_install_local_package).with( "blah", "/host0" ).exactly(1).times
1306
- expect( mhosts[2] ).to receive(:install_package).with( any_args ).exactly(1).times
1307
- expect( mhosts[3] ).to receive(:install_from_file).with( "blah" ).exactly(1).times
1308
-
1309
- result = object_double(Beaker::Result.new({}, "foo"), :raw_output=> "xyz")
1310
- allow(subject).to receive(:on).with(mhosts[1], anything).and_return(result)
1311
-
1312
- expect( subject ).to receive(:configure_type_defaults_on).with( any_args ).exactly(mhosts.length).times
1313
-
1314
- subject.install_puppet_agent_dev_repo_on( mhosts, opts.merge({:puppet_agent_version => '1.0.0' }) )
1315
- end
1316
-
1317
- it 'installs on different hosts with options specifying :copy_dir_external' do
1318
- mhosts = hosts
1319
- mhosts[3] = eoshost
1320
-
1321
- mhosts.each_with_index do |host, index|
1322
- platform = Object.new()
1323
- if index == 0
1324
- allow(platform).to receive(:to_array) { ['solaris', '5', 'x4']}
1325
- allow(host).to receive(:external_copy_base) {'/host0'}
1326
- elsif index == 1
1327
- allow(platform).to receive(:to_array) { ['windows', '5', 'x4']}
1328
- allow(host).to receive(:external_copy_base) {'/host1'}
1329
- elsif index == 2
1330
- allow(platform).to receive(:to_array) { ['osx', '5', 'x4']}
1331
- allow(host).to receive(:external_copy_base) {'/host2'}
1332
- elsif index == 3
1333
- allow(platform).to receive(:to_array) { ['eos', '5', 'x4']}
1334
- allow(host).to receive(:external_copy_base) {'/host3'}
1335
- end
1336
- allow(host).to receive(:puppet_agent_dev_package_info).with(any_args).and_return(["test", "/blah"])
1337
- host['platform'] = platform
1338
- end
1339
-
1340
- expect( subject ).to receive(:add_role).with( any_args ).exactly(mhosts.length).times
1341
-
1342
- expect( subject ).to receive(:fetch_http_file).with( any_args ).exactly(3).times
1343
- expect( subject ).to receive(:scp_to).with( any_args ).exactly(3).times
1344
-
1345
- expect( subject ).to receive(:install_msi_on).with(mhosts[1], 'xyz', {}, anything ).exactly(1).times
1346
- expect( mhosts[0] ).to receive(:solaris_install_local_package).with( '/blah', '/tmp').exactly(1).times
1347
- expect( mhosts[2] ).to receive(:install_package).with( any_args ).exactly(1).times
1348
- expect( mhosts[3] ).to receive(:install_from_file).with( '/blah').exactly(1).times
1349
- expect( mhosts[0] ).to receive(:external_copy_base).with( no_args ).exactly(0).times
1350
- expect( mhosts[1] ).to receive(:external_copy_base).with( no_args ).exactly(0).times
1351
- expect( mhosts[2] ).to receive(:external_copy_base).with( no_args ).exactly(0).times
1352
- expect( mhosts[3] ).to receive(:external_copy_base).with( no_args ).exactly(0).times
1353
-
1354
- result = object_double(Beaker::Result.new({}, "foo"), :raw_output=> "xyz")
1355
- allow(subject).to receive(:on).with(mhosts[1], anything).and_return(result)
1356
-
1357
- expect( subject ).to receive(:configure_type_defaults_on).with( any_args ).exactly(mhosts.length).times
1358
-
1359
- subject.install_puppet_agent_dev_repo_on( mhosts, opts.merge({:puppet_agent_version => '1.0.0', :copy_dir_external => '/tmp' }) )
1360
- end
1361
- end
1362
-
1363
- describe '#install_puppet_agent_pe_promoted_repo_on' do
1364
- let( :package_name ) { 'puppet-agent' }
1365
- let( :platform ) { @platform || 'other' }
1366
- let( :host ) do
1367
- FakeHost.create( 'fakvm', platform, opts )
1368
- end
1369
-
1370
- before :each do
1371
- allow( subject ).to receive( :configure_foss_defaults_on ).and_return( true )
1372
- allow( subject ).to receive( :install_msi_on ).with( any_args )
1373
- end
1374
-
1375
- def test_fetch_http_file_no_ending_slash(platform)
1376
- @platform = platform
1377
- allow( subject ).to receive( :scp_to )
1378
- allow( subject ).to receive( :configure_type_defaults_on ).with(host)
1379
-
1380
- expect( subject ).to receive( :fetch_http_file ).with( /[^\/]\z/, anything, anything )
1381
- subject.install_puppet_agent_pe_promoted_repo_on( host, opts )
1382
- end
1383
-
1384
- context 'on windows' do
1385
-
1386
- it 'calls fetch_http_file with no ending slash' do
1387
- test_fetch_http_file_no_ending_slash( 'windows-7-x86_64' )
1388
- end
1389
- end
1390
-
1391
- it 'calls fetch_http_file with no ending slash' do
1392
- test_fetch_http_file_no_ending_slash( 'debian-5-x86_64' )
1393
- end
1394
-
1395
- context 'when setting different agent versions' do
1396
- let( :host ) { basic_hosts.first }
1397
- let( :platform ) { Object.new() }
1398
- let( :downloadurl ) { 'http://pm.puppet.com' }
1399
- before :each do
1400
- allow( platform ).to receive( :to_array ) { ['el', '6', 'x4'] }
1401
- allow( subject ).to receive( :options ).and_return( opts )
1402
- allow( subject ).to receive( :scp_to )
1403
- allow( subject ).to receive( :configure_type_defaults_on ).with( host )
1404
- end
1405
-
1406
- it 'sets correct file paths when agent version is set to latest' do
1407
- host['platform'] = platform
1408
- agentversion = 'latest'
1409
- collection = 'puppet'
1410
- opts = { :puppet_agent_version => "#{agentversion}" , :pe_promoted_builds_url => "#{downloadurl}" }
1411
-
1412
- expect(subject).to receive(:fetch_http_file).once.with(
1413
- /pm\.puppet\.com\/puppet-agent\/.*\/#{agentversion}\/repos/,
1414
- /puppet-agent-el-6*/,
1415
- /\/el$/
1416
- )
1417
- expect(host).to receive(:pe_puppet_agent_promoted_package_install).with(
1418
- anything,
1419
- /puppet-agent-el-6*/,
1420
- /.*\/el\/6\/#{collection}\/.*rpm/,
1421
- /puppet-agent-el-6/,
1422
- anything
1423
- )
1424
- subject.install_puppet_agent_pe_promoted_repo_on( host, opts )
1425
- end
1426
-
1427
- it 'sets correct file paths for agent version 1.x.x' do
1428
- host['platform'] = platform
1429
- agentversion = '1.x.x'
1430
- collection = 'pc1'
1431
- opts = { :puppet_agent_version => "#{agentversion}" , :pe_promoted_builds_url => "#{downloadurl}"}
1432
-
1433
- expect(subject).to receive(:fetch_http_file).once.with(
1434
- /pm\.puppet\.com\/puppet-agent\/.*\/#{agentversion}\/repos/,
1435
- /puppet-agent-el-6*/,/\/el$/
1436
- )
1437
- expect(host).to receive(:pe_puppet_agent_promoted_package_install).with(
1438
- anything,
1439
- /puppet-agent-el-6*/,
1440
- /.*\/el\/6\/#{collection}\/.*rpm/,
1441
- /puppet-agent-el-6/,
1442
- anything
1443
- )
1444
- subject.install_puppet_agent_pe_promoted_repo_on( host, opts )
1445
- end
1446
-
1447
- it 'sets correct file paths for agent version >= 5.5.4' do
1448
- host['platform'] = platform
1449
- agentversion = '5.5.4'
1450
- collection = 'puppet5'
1451
- opts = { :puppet_agent_version => "#{agentversion}" , :pe_promoted_builds_url => "#{downloadurl}"}
1452
-
1453
- expect(subject).to receive(:fetch_http_file).once.with(
1454
- /pm\.puppet\.com\/puppet-agent\/.*\/#{agentversion}\/repos/,
1455
- /puppet-agent-el-6*/,
1456
- /\/el$/
1457
- )
1458
- expect(host).to receive(:pe_puppet_agent_promoted_package_install).with(
1459
- anything,
1460
- /puppet-agent-el-6*/,
1461
- /.*\/el\/6\/#{collection}\/.*rpm/,
1462
- /puppet-agent-el-6/,
1463
- anything
1464
- )
1465
- subject.install_puppet_agent_pe_promoted_repo_on( host, opts )
1466
- end
1467
-
1468
- it 'sets correct file paths for agent version > 5.99' do
1469
- host['platform'] = platform
1470
- agentversion = '6.0.0'
1471
- collection = 'puppet6'
1472
- opts = { :puppet_agent_version => "#{agentversion}" , :pe_promoted_builds_url => "#{downloadurl}"}
1473
-
1474
- expect(subject).to receive(:fetch_http_file).once.with(
1475
- /pm\.puppet\.com\/puppet-agent\/.*\/#{agentversion}\/repos/,
1476
- /puppet-agent-el-6*/,
1477
- /\/el$/
1478
- )
1479
- expect(host).to receive(:pe_puppet_agent_promoted_package_install).with(
1480
- anything,
1481
- /puppet-agent-el-6*/,
1482
- /.*\/el\/6\/#{collection}\/.*rpm/,
1483
- /puppet-agent-el-6/,
1484
- anything
1485
- )
1486
- subject.install_puppet_agent_pe_promoted_repo_on( host, opts )
1487
- end
1488
- end
1489
- end
1490
-
1491
1095
  describe '#install_puppetserver_on' do
1492
1096
  let(:host) { make_host('master', platform: 'el-7-x86_64') }
1493
1097
 
1494
1098
  context 'with default arguments' do
1495
1099
  it "installs the latest puppetserver from the default 'puppet' release stream" do
1496
- expect(subject).to receive(:install_puppetlabs_release_repo_on).with(host, 'puppet', include(release_yum_repo_url: "https://yum.puppet.com"))
1100
+ expect(subject).to receive(:install_puppetlabs_release_repo_on).with(host, 'puppet',
1101
+ include(release_yum_repo_url: 'https://yum.puppet.com'))
1497
1102
  expect(subject).to receive(:install_package).with(host, 'puppetserver', nil)
1498
1103
  subject.install_puppetserver_on(host)
1499
1104
  end
@@ -1503,7 +1108,7 @@ describe ClassMixedWithDSLInstallUtils do
1503
1108
  version = '6.6.6'
1504
1109
 
1505
1110
  context 'on deb-based platform' do
1506
- let(:host) {make_host('master', platform: Beaker::Platform.new('ubuntu-16.04-amd64'))}
1111
+ let(:host) { make_host('master', platform: Beaker::Platform.new('ubuntu-16.04-amd64')) }
1507
1112
  it 'munges the version on ubuntu 16.04' do
1508
1113
  expect(subject).to receive(:install_puppetlabs_release_repo_on).with(host, 'puppet', anything)
1509
1114
  expect(subject).to receive(:install_package).with(host, 'puppetserver', "#{version}-1xenial")
@@ -1513,14 +1118,16 @@ describe ClassMixedWithDSLInstallUtils do
1513
1118
  end
1514
1119
 
1515
1120
  it 'installs puppetserver at the specific version from internal buildservers' do
1516
- expect(subject).to receive(:install_from_build_data_url).with('puppetserver', /^#{described_class::FOSS_DEFAULT_DOWNLOAD_URLS[:dev_builds_url]}.*#{version}/, host)
1121
+ expect(subject).to receive(:install_from_build_data_url).with('puppetserver',
1122
+ /^#{described_class::FOSS_DEFAULT_DOWNLOAD_URLS[:dev_builds_url]}.*#{version}/, host)
1517
1123
  allow(subject).to receive(:dev_builds_accessible_on?).with(host, anything).and_return true
1518
1124
  subject.install_puppetserver_on(host, version: version)
1519
1125
  end
1520
1126
 
1521
1127
  it 'installs puppetserver from the custom dev builds URL' do
1522
1128
  dev_builds_url = 'http://builds.corp.tld'
1523
- expect(subject).to receive(:install_from_build_data_url).with('puppetserver', /^#{dev_builds_url}.*#{version}/, host)
1129
+ expect(subject).to receive(:install_from_build_data_url).with('puppetserver', /^#{dev_builds_url}.*#{version}/,
1130
+ host)
1524
1131
  allow(subject).to receive(:dev_builds_accessible_on?).with(host, anything).and_return true
1525
1132
  subject.install_puppetserver_on(host, version: version, dev_builds_url: dev_builds_url)
1526
1133
  end
@@ -1554,9 +1161,10 @@ describe ClassMixedWithDSLInstallUtils do
1554
1161
  context 'with the nightlies option' do
1555
1162
  it 'installs puppetserver from the default puppet nightly repos' do
1556
1163
  expect(subject).to receive(:install_puppetlabs_release_repo_on)
1557
- .with(host, 'puppet-nightly', include(
1558
- nightly_yum_repo_url: described_class::FOSS_DEFAULT_DOWNLOAD_URLS[:nightly_yum_repo_url],
1559
- nightly_apt_repo_url: described_class::FOSS_DEFAULT_DOWNLOAD_URLS[:nightly_apt_repo_url]))
1164
+ .with(host, 'puppet-nightly', include(
1165
+ nightly_yum_repo_url: described_class::FOSS_DEFAULT_DOWNLOAD_URLS[:nightly_yum_repo_url],
1166
+ nightly_apt_repo_url: described_class::FOSS_DEFAULT_DOWNLOAD_URLS[:nightly_apt_repo_url],
1167
+ ))
1560
1168
  subject.install_puppetserver_on(host, nightlies: true)
1561
1169
  end
1562
1170
 
@@ -1565,23 +1173,26 @@ describe ClassMixedWithDSLInstallUtils do
1565
1173
 
1566
1174
  it 'uses a custom general nightlies url' do
1567
1175
  expect(subject).to receive(:install_puppetlabs_release_repo_on)
1568
- .with(host, 'puppet-nightly', include(
1569
- nightly_yum_repo_url: custom_nightlies_url,
1570
- nightly_apt_repo_url: custom_nightlies_url))
1176
+ .with(host, 'puppet-nightly', include(
1177
+ nightly_yum_repo_url: custom_nightlies_url,
1178
+ nightly_apt_repo_url: custom_nightlies_url,
1179
+ ))
1571
1180
  subject.install_puppetserver_on(host, nightlies: true, nightly_builds_url: custom_nightlies_url)
1572
1181
  end
1573
1182
 
1574
1183
  it 'uses a custom yum repo url' do
1575
1184
  expect(subject).to receive(:install_puppetlabs_release_repo_on)
1576
- .with(host, 'puppet-nightly', include(
1577
- nightly_yum_repo_url: custom_nightlies_url))
1185
+ .with(host, 'puppet-nightly', include(
1186
+ nightly_yum_repo_url: custom_nightlies_url,
1187
+ ))
1578
1188
  subject.install_puppetserver_on(host, nightlies: true, nightly_yum_repo_url: custom_nightlies_url)
1579
1189
  end
1580
1190
 
1581
1191
  it 'uses a custom apt repo url' do
1582
1192
  expect(subject).to receive(:install_puppetlabs_release_repo_on)
1583
- .with(host, 'puppet-nightly', include(
1584
- nightly_apt_repo_url: custom_nightlies_url))
1193
+ .with(host, 'puppet-nightly', include(
1194
+ nightly_apt_repo_url: custom_nightlies_url,
1195
+ ))
1585
1196
  subject.install_puppetserver_on(host, nightlies: true, nightly_apt_repo_url: custom_nightlies_url)
1586
1197
  end
1587
1198
  end
@@ -1589,47 +1200,44 @@ describe ClassMixedWithDSLInstallUtils do
1589
1200
  end
1590
1201
 
1591
1202
  describe '#remove_puppet_on' do
1592
- supported_platforms = [ 'aix-53-power',
1593
- 'aix-61-power',
1594
- 'aix-71-power',
1595
- 'solaris-10-x86_64',
1596
- 'solaris-10-x86_64',
1597
- 'solaris-11-x86_64',
1598
- 'cumulus-2.2-amd64',
1599
- 'el-6-x86_64',
1600
- 'redhat-7-x86_64',
1601
- 'centos-7-x86_64',
1602
- 'oracle-7-x86_64',
1603
- 'scientific-7-x86_64',
1604
- 'sles-10-x86_64',
1605
- 'sles-11-x86_64',
1606
- 'sles-12-s390x',
1607
- 'ubuntu-16.04-power8'
1608
- ]
1203
+ supported_platforms = ['aix-53-power',
1204
+ 'aix-61-power',
1205
+ 'aix-71-power',
1206
+ 'solaris-10-x86_64',
1207
+ 'solaris-10-x86_64',
1208
+ 'solaris-11-x86_64',
1209
+ 'el-6-x86_64',
1210
+ 'redhat-7-x86_64',
1211
+ 'centos-7-x86_64',
1212
+ 'oracle-7-x86_64',
1213
+ 'scientific-7-x86_64',
1214
+ 'sles-10-x86_64',
1215
+ 'sles-11-x86_64',
1216
+ 'sles-12-s390x',
1217
+ 'ubuntu-16.04-power8',]
1609
1218
 
1610
1219
  supported_platforms.each do |platform|
1611
- let(:host) { make_host(platform, :platform => platform) }
1220
+ let(:host) { make_host(platform, platform: platform) }
1612
1221
 
1613
1222
  pkg_list = 'foo bar'
1614
1223
 
1615
1224
  it "uninstalls packages on #{platform}" do
1616
- result = Beaker::Result.new(host,'')
1225
+ result = Beaker::Result.new(host, '')
1617
1226
  result.stdout = pkg_list
1618
1227
 
1619
1228
  expected_list = pkg_list
1620
1229
  cmd_args = ''
1621
1230
 
1622
- expect( subject ).to receive(:on).exactly(2).times.and_return(result, result)
1623
- expect( host ).to receive(:uninstall_package).with(expected_list, cmd_args)
1231
+ expect(subject).to receive(:on).exactly(2).times.and_return(result, result)
1232
+ expect(host).to receive(:uninstall_package).with(expected_list, cmd_args)
1624
1233
 
1625
- subject.remove_puppet_on( host )
1234
+ subject.remove_puppet_on(host)
1626
1235
  end
1627
1236
  end
1628
1237
 
1629
- let(:debian6) { make_host('debian-6-amd64', :platform => 'debian-6-amd64') }
1238
+ let(:debian6) { make_host('debian-6-amd64', platform: 'debian-6-amd64') }
1630
1239
  it 'raises error on unsupported platforms' do
1631
- expect { subject.remove_puppet_on( debian6 ) }.to raise_error(RuntimeError, /unsupported platform/)
1240
+ expect { subject.remove_puppet_on(debian6) }.to raise_error(RuntimeError, /unsupported platform/)
1632
1241
  end
1633
-
1634
1242
  end
1635
1243
  end