vagrant-bolt 0.1.0 → 0.3.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.
@@ -32,7 +32,7 @@ module VagrantBolt::Util
32
32
  # Generate a list of active machines in the environment
33
33
  # @param env [Object] The Environment
34
34
  # @return [Array<Object>]
35
- def self.nodes_in_environment(env)
35
+ def self.machines_in_environment(env)
36
36
  env.active_machines.map { |vm|
37
37
  begin
38
38
  env.machine(*vm)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VagrantBolt
4
- VERSION = '0.1.0'
4
+ VERSION = '0.3.0'
5
5
  end
@@ -72,6 +72,7 @@ describe VagrantBolt::Config::Bolt do
72
72
  context "defaults" do
73
73
  expected_values = {
74
74
  nodes: [],
75
+ targets: [],
75
76
  excludes: [],
76
77
  }
77
78
  expected_values.each do |val, expected|
@@ -86,6 +87,7 @@ describe VagrantBolt::Config::Bolt do
86
87
  "command",
87
88
  "params",
88
89
  "node_list",
90
+ "target_list",
89
91
  "user",
90
92
  "password",
91
93
  "port",
@@ -99,6 +101,8 @@ describe VagrantBolt::Config::Bolt do
99
101
  "verbose",
100
102
  "debug",
101
103
  "host_key_check",
104
+ "machine_alias",
105
+ "machine_name",
102
106
  "modulepath",
103
107
  "bolt_exe",
104
108
  "boltdir",
@@ -20,9 +20,12 @@ describe VagrantBolt::Config::Global do
20
20
  end
21
21
 
22
22
  context "defaults" do
23
+ before(:each) do
24
+ allow(File).to receive(:file?).with('/opt/puppetlabs/bin/bolt').and_return(true)
25
+ end
26
+
23
27
  expected_values = {
24
- modulepath: "modules",
25
- bolt_exe: "bolt",
28
+ bolt_exe: "/opt/puppetlabs/bin/bolt",
26
29
  boltdir: ".",
27
30
  }
28
31
  expected_values.each do |val, expected|
@@ -42,12 +45,14 @@ describe VagrantBolt::Config::Global do
42
45
  "run_as",
43
46
  "ssl",
44
47
  "ssl_verify",
48
+ "connect_timeout",
45
49
  "host_key_check",
46
50
  "verbose",
47
51
  "debug",
48
52
  "facts",
49
53
  "vars",
50
54
  "features",
55
+ "modulepath",
51
56
  ]
52
57
  expected_nil.each do |val|
53
58
  it "defaults #{val} to nil" do
@@ -28,13 +28,11 @@ describe VagrantBolt::Runner do
28
28
  allow(result).to receive(:stderr).and_return("")
29
29
  end
30
30
  end
31
- let(:root_path) { '/root/path' }
32
- let(:local_data_path) { '/local/data/path' }
33
- let(:inventory_path) { "#{local_data_path}/bolt_inventory.yaml" }
31
+ let(:root_path) { Dir.getwd }
32
+ let(:local_data_path) { "#{root_path}/.vagrant" }
33
+ let(:inventory_path) { ".vagrant/bolt_inventory.yaml" }
34
34
  before(:each) do
35
35
  allow(VagrantBolt::Util::Bolt).to receive(:update_inventory_file).with(iso_env).and_return(inventory_path)
36
- allow(iso_env).to receive(:root_path).and_return(root_path)
37
- allow(iso_env).to receive(:local_data_path).and_return(local_data_path)
38
36
  allow(machine).to receive(:env).and_return(:iso_env)
39
37
  allow(machine).to receive(:ssh_info).and_return(
40
38
  host: 'foo',
@@ -48,7 +46,7 @@ describe VagrantBolt::Runner do
48
46
 
49
47
  context 'setup_overrides' do
50
48
  before(:each) do
51
- allow(VagrantBolt::Util::Machine).to receive(:nodes_in_environment).with(iso_env).and_return([machine, machine2])
49
+ allow(VagrantBolt::Util::Machine).to receive(:machines_in_environment).with(iso_env).and_return([machine, machine2])
52
50
  end
53
51
  it 'adds the command and name to the config' do
54
52
  result = subject.send(:setup_overrides, 'task', 'foo')
@@ -56,31 +54,47 @@ describe VagrantBolt::Runner do
56
54
  expect(result.name).to eq('foo')
57
55
  end
58
56
 
59
- it 'uses the server name for the nodes' do
57
+ it 'uses the server name for the targets' do
60
58
  result = subject.send(:setup_overrides, 'task', 'foo')
61
- expect(result.node_list).to eq('server')
59
+ expect(result.target_list).to eq('server')
62
60
  end
63
61
 
64
- it 'allows for using multiple nodes' do
62
+ it 'allows for using multiple targets' do
63
+ config.targets = ['server', 'server2']
64
+ config.finalize!
65
+ result = subject.send(:setup_overrides, 'task', 'foo')
66
+ expect(result.target_list).to eq('server,server2')
67
+ end
68
+
69
+ it 'allows for using nodes parameter' do
65
70
  config.nodes = ['server', 'server2']
66
71
  config.finalize!
67
72
  result = subject.send(:setup_overrides, 'task', 'foo')
68
- expect(result.node_list).to eq('server,server2')
73
+ expect(result.target_list).to eq('server,server2')
69
74
  end
70
75
 
71
- it 'adds all nodes when "all" is specified' do
72
- config.nodes = 'all'
76
+ it 'adds all targets when "all" is specified' do
77
+ config.targets = 'all'
73
78
  config.finalize!
74
79
  result = subject.send(:setup_overrides, 'task', 'foo')
75
- expect(result.node_list).to eq('server,server2')
80
+ expect(result.target_list).to eq('server,server2')
76
81
  end
77
82
 
78
83
  it 'does not override specified ssh settings' do
84
+ config.target_list = 'ssh://test:22'
85
+ config.user = 'root'
86
+ config.finalize!
87
+ result = subject.send(:setup_overrides, 'task', 'foo')
88
+ expect(result.target_list).to eq('ssh://test:22')
89
+ expect(result.user).to eq('root')
90
+ end
91
+
92
+ it 'target_list defaults to node_list' do
79
93
  config.node_list = 'ssh://test:22'
80
94
  config.user = 'root'
81
95
  config.finalize!
82
96
  result = subject.send(:setup_overrides, 'task', 'foo')
83
- expect(result.node_list).to eq('ssh://test:22')
97
+ expect(result.target_list).to eq('ssh://test:22')
84
98
  expect(result.user).to eq('root')
85
99
  end
86
100
 
@@ -94,6 +108,8 @@ describe VagrantBolt::Runner do
94
108
  let(:options) { { notify: [:stdout, :stderr], env: { PATH: nil } } }
95
109
  before(:each) do
96
110
  allow(Vagrant::Util::Subprocess).to receive(:execute).and_return(subprocess_result)
111
+ allow(iso_env).to receive(:root_path).and_return(root_path)
112
+ allow(iso_env).to receive(:local_data_path).and_return(local_data_path)
97
113
  end
98
114
 
99
115
  it 'does not raise an exeption when all parameters are specified' do
@@ -110,11 +126,10 @@ describe VagrantBolt::Runner do
110
126
 
111
127
  it 'creates a shell execution' do
112
128
  config.bolt_exe = 'bolt'
113
- config.modulepath = 'modules'
114
129
  config.boltdir = '.'
115
- config.node_list = 'ssh://test:22'
130
+ config.target_list = 'ssh://test:22'
116
131
  config.finalize!
117
- command = "bolt task run 'foo' --boltdir '#{root_path}/.' --modulepath '#{root_path}/modules' --inventoryfile '#{inventory_path}' --nodes 'ssh://test:22'"
132
+ command = "bolt task run 'foo' --boltdir '.' --inventoryfile '#{inventory_path}' --targets 'ssh://test:22'"
118
133
  expect(Vagrant::Util::Subprocess).to receive(:execute).with('bash', '-c', command, options).and_return(subprocess_result)
119
134
  subject.run('task', 'foo')
120
135
  end
@@ -26,9 +26,9 @@ describe VagrantBolt::Util::Bolt do
26
26
  end
27
27
  let(:machine_hash) do
28
28
  {
29
- "alias" => "machine",
30
29
  "config" => {
31
30
  "ssh" => {
31
+ "connect-timeout" => "30",
32
32
  "host-key-check" => false,
33
33
  "port" => "22",
34
34
  "user" => "vagrant",
@@ -38,8 +38,10 @@ describe VagrantBolt::Util::Bolt do
38
38
  },
39
39
  "transport" => "ssh",
40
40
  },
41
- "name" => "ssh://machine:22",
41
+ "uri" => "ssh://machine:22",
42
42
  "facts" => { 'a' => 'b' },
43
+ "alias" => 'machine',
44
+ "name" => 'somename',
43
45
  "vars" => { 'foo' => 'bar' },
44
46
  "features" => ['foo'],
45
47
  }
@@ -47,8 +49,9 @@ describe VagrantBolt::Util::Bolt do
47
49
  let(:config_hash) { { 'config' => { 'a' => 'b' } } }
48
50
  let(:node_hash) do
49
51
  {
50
- 'nodes' => [machine_hash],
52
+ 'targets' => [machine_hash],
51
53
  'config' => config_hash['config'],
54
+ 'version' => 2,
52
55
  }
53
56
  end
54
57
  before(:each) do
@@ -56,11 +59,13 @@ describe VagrantBolt::Util::Bolt do
56
59
  config.run_as = 'root'
57
60
  config.port = '22'
58
61
  config.private_key = 'bar'
62
+ config.connect_timeout = '30'
59
63
  config.host_key_check = false
60
64
  config.user = 'vagrant'
61
65
  config.facts = { 'a' => 'b' }
62
66
  config.features = ['foo']
63
67
  config.vars = { 'foo' => 'bar' }
68
+ config.machine_name = 'somename'
64
69
  config.finalize!
65
70
  allow(machine).to receive_message_chain("config.bolt.inventory_config").and_return(config.inventory_config)
66
71
  allow(machine).to receive_message_chain("config.vm.communicator").and_return(:ssh)
@@ -68,7 +73,7 @@ describe VagrantBolt::Util::Bolt do
68
73
  allow(env).to receive_message_chain("vagrantfile.config.bolt.inventory_config").and_return(config_hash)
69
74
  allow(env).to receive(:active_machines).and_return(['machine'])
70
75
  allow(env).to receive(:machine).and_return(machine)
71
- allow_any_instance_of(VagrantBolt::Util::Machine).to receive(:nodes_in_environment).with(env).and_return([machine])
76
+ allow_any_instance_of(VagrantBolt::Util::Machine).to receive(:machines_in_environment).with(env).and_return([machine])
72
77
  allow_any_instance_of(VagrantBolt::Util::Machine).to receive(:running?).with(machine).and_return(true)
73
78
  end
74
79
 
@@ -93,7 +98,7 @@ describe VagrantBolt::Util::Bolt do
93
98
  config.node_list = 'ssh://test:22'
94
99
  config.user = 'user'
95
100
  config.finalize!
96
- expected = "bolt task run 'foo' --user \'user\' --inventoryfile '#{inventory_path}' --nodes \'ssh://test:22\'"
101
+ expected = "bolt task run 'foo' --user \'user\' --inventoryfile '#{inventory_path}' --targets \'ssh://test:22\'"
97
102
  expect(subject.generate_bolt_command(config, inventory_path)).to eq(expected)
98
103
  end
99
104
 
@@ -0,0 +1,8 @@
1
+ require 'github_changelog_generator/task'
2
+ require_relative '../lib/vagrant-bolt/version'
3
+
4
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
5
+ config.user ='oscar-stack'
6
+ config.project = 'vagrant-bolt'
7
+ config.future_release = "v#{VagrantBolt::VERSION}"
8
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-bolt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarret Lavallee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-11 00:00:00.000000000 Z
11
+ date: 2020-06-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " Vagrant provisioning with Puppet Bolt\n"
14
14
  email:
@@ -22,6 +22,7 @@ files:
22
22
  - ".rubocop.yml"
23
23
  - ".travis.yml"
24
24
  - ".yardopts"
25
+ - CHANGELOG.md
25
26
  - Gemfile
26
27
  - LICENSE
27
28
  - Puppetfile
@@ -79,6 +80,7 @@ files:
79
80
  - spec/unit/util/config_spec.rb
80
81
  - spec/unit/vagrant_spec.rb
81
82
  - tasks/acceptance.rake
83
+ - tasks/changelog.rake
82
84
  - tasks/spec.rake
83
85
  - templates/locales/en.yml
84
86
  - vagrant-bolt.gemspec
@@ -102,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
104
  version: '0'
103
105
  requirements: []
104
106
  rubyforge_project:
105
- rubygems_version: 2.7.6
107
+ rubygems_version: 2.7.6.2
106
108
  signing_key:
107
109
  specification_version: 4
108
110
  summary: Vagrant provisioning with Puppet Bolt