Skip to content

Commit a6ad919

Browse files
committed
Extract acceptance node setup to its own file
This is a pattern we use in Vox Pupuli. In fact, voxpupuli-acceptance does this if it detects the file automatically. The biggest benefit is that editors and linters can work on the file, which increases quality.
1 parent 5d396bb commit a6ad919

File tree

2 files changed

+31
-35
lines changed

2 files changed

+31
-35
lines changed

Diff for: spec/setup_acceptance_node.pp

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
if $facts['os']['name'] == 'Ubuntu' and $facts['os']['release']['major'] == '18.04' {
2+
package { 'iproute2':
3+
ensure => installed,
4+
}
5+
}
6+
7+
# needed for netstat, for serverspec checks
8+
if $facts['os']['family'] in ['SLES', 'SUSE'] {
9+
exec { 'Enable legacy repos':
10+
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
11+
command => 'SUSEConnect --product sle-module-legacy/15.5/x86_64',
12+
unless => 'SUSEConnect --status-text | grep sle-module-legacy/15.5/x86_64',
13+
}
14+
15+
package { 'net-tools-deprecated':
16+
ensure => 'latest',
17+
require => Exec['Enable legacy repos'],
18+
}
19+
}
20+
21+
if $facts['os']['family'] == 'RedHat' {
22+
if versioncmp($facts['os']['release']['major'], '8') >= 0 {
23+
$package = ['iproute', 'policycoreutils-python-utils']
24+
} else {
25+
$package = 'policycoreutils-python'
26+
}
27+
package { $package:
28+
ensure => installed,
29+
}
30+
}

Diff for: spec/spec_helper_acceptance_local.rb

+1-35
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def unindent
1515

1616
RSpec.configure do |c|
1717
c.before :suite do
18-
install_dependencies
18+
LitmusHelper.instance.apply_manifest(File.read(File.join(__dir__, 'setup_acceptance_node.pp')))
1919
end
2020
end
2121

@@ -36,40 +36,6 @@ def pre_run
3636
LitmusHelper.instance.apply_manifest("class { 'postgresql::server': postgres_password => 'postgres' }", catch_failures: true)
3737
end
3838

39-
def install_dependencies
40-
LitmusHelper.instance.apply_manifest <<~MANIFEST
41-
if $facts['os']['name'] == 'Ubuntu' and $facts['os']['release']['major'] == '18.04' {
42-
package { 'iproute2':
43-
ensure => installed,
44-
}
45-
}
46-
47-
# needed for netstat, for serverspec checks
48-
if $facts['os']['family'] in ['SLES', 'SUSE'] {
49-
exec { 'Enable legacy repos':
50-
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
51-
command => 'SUSEConnect --product sle-module-legacy/15.5/x86_64',
52-
unless => 'SUSEConnect --status-text | grep sle-module-legacy/15.5/x86_64',
53-
}
54-
55-
package { 'net-tools-deprecated':
56-
ensure => 'latest',
57-
}
58-
}
59-
60-
if $facts['os']['family'] == 'RedHat' {
61-
if versioncmp($facts['os']['release']['major'], '8') >= 0 {
62-
$package = ['iproute', 'policycoreutils-python-utils']
63-
} else {
64-
$package = 'policycoreutils-python'
65-
}
66-
package { $package:
67-
ensure => installed,
68-
}
69-
}
70-
MANIFEST
71-
end
72-
7339
def postgresql_version
7440
result = LitmusHelper.instance.run_shell('psql --version')
7541
result.stdout.match(%r{\s(\d{1,2}\.\d)})[1]

0 commit comments

Comments
 (0)