beaker 2.24.0 → 2.25.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.
- checksums.yaml +8 -8
- data/CONTRIBUTING.md +2 -7
- data/HISTORY.md +238 -2
- data/acceptance/tests/base/dsl/structure_test.rb +16 -0
- data/beaker.gemspec +4 -0
- data/lib/beaker/dsl/helpers.rb +3 -2
- data/lib/beaker/dsl/install_utils/foss_utils.rb +55 -6
- data/lib/beaker/dsl/structure.rb +28 -7
- data/lib/beaker/host.rb +2 -0
- data/lib/beaker/host_prebuilt_steps.rb +21 -9
- data/lib/beaker/hypervisor/aws_sdk.rb +86 -10
- data/lib/beaker/logger.rb +49 -1
- data/lib/beaker/options/presets.rb +1 -0
- data/lib/beaker/version.rb +1 -1
- data/spec/beaker/dsl/install_utils/foss_utils_spec.rb +49 -28
- data/spec/beaker/dsl/structure_spec.rb +44 -7
- data/spec/beaker/host_prebuilt_steps_spec.rb +7 -1
- data/spec/beaker/host_spec.rb +2 -0
- data/spec/beaker/hypervisor/aws_sdk_spec.rb +149 -9
- data/spec/beaker/logger_spec.rb +70 -0
- metadata +30 -4
- data/lib/beaker/dsl/helpers/hiera_helpers.rb +0 -60
- data/spec/beaker/dsl/helpers/hiera_helpers_spec.rb +0 -96
@@ -1,60 +0,0 @@
|
|
1
|
-
module Beaker
|
2
|
-
module DSL
|
3
|
-
module Helpers
|
4
|
-
# Methods that help you interact with your hiera installation, hiera must be installed
|
5
|
-
# for these methods to execute correctly
|
6
|
-
module HieraHelpers
|
7
|
-
|
8
|
-
# Write hiera config file on one or more provided hosts
|
9
|
-
#
|
10
|
-
# @param[Host, Array<Host>, String, Symbol] host One or more hosts to act upon,
|
11
|
-
# or a role (String or Symbol) that identifies one or more hosts.
|
12
|
-
# @param[Array] One or more hierarchy paths
|
13
|
-
def write_hiera_config_on(host, hierarchy)
|
14
|
-
|
15
|
-
block_on host do |host|
|
16
|
-
hiera_config=Hash.new
|
17
|
-
hiera_config[:backends] = 'yaml'
|
18
|
-
hiera_config[:yaml] = {}
|
19
|
-
hiera_config[:yaml][:datadir] = hiera_datadir(host)
|
20
|
-
hiera_config[:hierarchy] = hierarchy
|
21
|
-
hiera_config[:logger] = 'console'
|
22
|
-
create_remote_file host, host.puppet['hiera_config'], hiera_config.to_yaml
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# Write hiera config file for the default host
|
27
|
-
# @see #write_hiera_config_on
|
28
|
-
def write_hiera_config(hierarchy)
|
29
|
-
write_hiera_config_on(default, hierarchy)
|
30
|
-
end
|
31
|
-
|
32
|
-
# Copy hiera data files to one or more provided hosts
|
33
|
-
#
|
34
|
-
# @param[Host, Array<Host>, String, Symbol] host One or more hosts to act upon,
|
35
|
-
# or a role (String or Symbol) that identifies one or more hosts.
|
36
|
-
# @param[String] Directory containing the hiera data files.
|
37
|
-
def copy_hiera_data_to(host, source)
|
38
|
-
scp_to host, File.expand_path(source), hiera_datadir(host)
|
39
|
-
end
|
40
|
-
|
41
|
-
# Copy hiera data files to the default host
|
42
|
-
# @see #copy_hiera_data_to
|
43
|
-
def copy_hiera_data(source)
|
44
|
-
copy_hiera_data_to(default, source)
|
45
|
-
end
|
46
|
-
|
47
|
-
# Get file path to the hieradatadir for a given host.
|
48
|
-
# Handles whether or not a host is AIO-based & backwards compatibility
|
49
|
-
#
|
50
|
-
# @param[Host] host Host you want to use the hieradatadir from
|
51
|
-
#
|
52
|
-
# @return [String] Path to the hiera data directory
|
53
|
-
def hiera_datadir(host)
|
54
|
-
host[:type] =~ /aio/ ? File.join(host.puppet['codedir'], 'hieradata') : host[:hieradatadir]
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,96 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class ClassMixedWithDSLHelpers
|
4
|
-
include Beaker::DSL::Helpers
|
5
|
-
include Beaker::DSL::Wrappers
|
6
|
-
include Beaker::DSL::Roles
|
7
|
-
include Beaker::DSL::Patterns
|
8
|
-
|
9
|
-
def logger
|
10
|
-
RSpec::Mocks::Double.new('logger').as_null_object
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
describe ClassMixedWithDSLHelpers do
|
16
|
-
let( :opts ) { Beaker::Options::Presets.env_vars }
|
17
|
-
let( :command ){ 'ls' }
|
18
|
-
let( :host ) { double.as_null_object }
|
19
|
-
let( :result ) { Beaker::Result.new( host, command ) }
|
20
|
-
|
21
|
-
let( :master ) { make_host( 'master', :roles => %w( master agent default) ) }
|
22
|
-
let( :agent ) { make_host( 'agent', :roles => %w( agent ) ) }
|
23
|
-
let( :custom ) { make_host( 'custom', :roles => %w( custom agent ) ) }
|
24
|
-
let( :dash ) { make_host( 'console', :roles => %w( dashboard agent ) ) }
|
25
|
-
let( :db ) { make_host( 'db', :roles => %w( database agent ) ) }
|
26
|
-
let( :hosts ) { [ master, agent, dash, db, custom ] }
|
27
|
-
|
28
|
-
|
29
|
-
describe "#write_hiera_config_on" do
|
30
|
-
let(:hierarchy) { [ 'nodes/%{::fqdn}', 'common' ] }
|
31
|
-
it 'on FOSS host' do
|
32
|
-
host = make_host('testhost', { :platform => 'ubuntu' } )
|
33
|
-
expect(subject).to receive(:create_remote_file).with(host, host.puppet['hiera_config'], /#{host[:hieradatadir]}/)
|
34
|
-
subject.write_hiera_config_on(host, hierarchy)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'on PE host' do
|
38
|
-
host = make_host('testhost', { :platform => 'ubuntu', :type => 'pe' } )
|
39
|
-
expect(subject).to receive(:create_remote_file).with(host, host.puppet['hiera_config'], /#{host[:hieradatadir]}/)
|
40
|
-
subject.write_hiera_config_on(host, hierarchy)
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "#write_hiera_config" do
|
46
|
-
let(:hierarchy) { [ 'nodes/%{::fqdn}', 'common' ] }
|
47
|
-
it 'delegates to #write_hiera_config_on with the default host' do
|
48
|
-
allow( subject ).to receive( :hosts ).and_return( hosts )
|
49
|
-
expect( subject ).to receive( :write_hiera_config_on ).with( master, hierarchy).once
|
50
|
-
subject.write_hiera_config( hierarchy )
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "#copy_hiera_data_to" do
|
56
|
-
let(:path) { 'spec/fixtures/hieradata' }
|
57
|
-
it 'on FOSS host' do
|
58
|
-
host = make_host('testhost', { :platform => 'ubuntu' } )
|
59
|
-
expect(subject).to receive(:scp_to).with(host, File.expand_path(path), host[:hieradatadir])
|
60
|
-
subject.copy_hiera_data_to(host, path)
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'on PE host' do
|
64
|
-
host = make_host('testhost', { :platform => 'ubuntu', :type => 'pe' } )
|
65
|
-
expect(subject).to receive(:scp_to).with(host, File.expand_path(path), host[:hieradatadir])
|
66
|
-
subject.copy_hiera_data_to(host, path)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe "#copy_hiera_data" do
|
71
|
-
let(:path) { 'spec/fixtures/hieradata' }
|
72
|
-
it 'delegates to #copy_hiera_data_to with the default host' do
|
73
|
-
allow( subject ).to receive( :hosts ).and_return( hosts )
|
74
|
-
expect( subject ).to receive( :copy_hiera_data_to ).with( master, path).once
|
75
|
-
subject.copy_hiera_data( path )
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#hiera_datadir' do
|
81
|
-
it 'returns the codedir based hieradatadir for AIO' do
|
82
|
-
host = hosts[0]
|
83
|
-
host['type'] = :aio
|
84
|
-
correct_answer = File.join(host.puppet['codedir'], 'hieradata')
|
85
|
-
expect( subject.hiera_datadir(host) ).to be === correct_answer
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'returns the hieradata host value for anything not AIO (backwards compatible)' do
|
89
|
-
host_hieradatadir_value = '/home/fishing/man/pants'
|
90
|
-
host = hosts[0]
|
91
|
-
host[:hieradatadir] = host_hieradatadir_value
|
92
|
-
expect( subject.hiera_datadir(host) ).to be === host_hieradatadir_value
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|