vagrant-bolt 0.3.0 → 0.4.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 +4 -4
- data/.github/workflows/spec.yml +71 -0
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +19 -0
- data/Gemfile +3 -3
- data/README.md +6 -2
- data/acceptance/components/bolt_spec.rb +16 -17
- data/acceptance/skeletons/advanced/Vagrantfile +1 -1
- data/acceptance/skeletons/base/Puppetfile +2 -0
- data/acceptance/skeletons/base/Vagrantfile +1 -1
- data/acceptance/skeletons/provisioner/Vagrantfile +1 -1
- data/acceptance/skeletons/trigger/Vagrantfile +1 -1
- data/acceptance/vagrant-spec.config.rb +3 -3
- data/lib/vagrant-bolt/command.rb +6 -6
- data/lib/vagrant-bolt/config/bolt.rb +2 -0
- data/lib/vagrant-bolt/config/global.rb +9 -5
- data/lib/vagrant-bolt/config_builder/config.rb +6 -1
- data/lib/vagrant-bolt/config_builder/monkey_patches.rb +1 -0
- data/lib/vagrant-bolt/config_builder/provisioner.rb +5 -1
- data/lib/vagrant-bolt/runner.rb +2 -2
- data/lib/vagrant-bolt/util/bolt.rb +1 -1
- data/lib/vagrant-bolt/util/config.rb +3 -2
- data/lib/vagrant-bolt/util/machine.rb +3 -2
- data/lib/vagrant-bolt/version.rb +1 -1
- data/spec/unit/config/bolt_spec.rb +4 -1
- data/spec/unit/config/global_spec.rb +4 -2
- data/spec/unit/runner/runner_spec.rb +11 -1
- data/spec/unit/util/bolt_spec.rb +18 -2
- metadata +8 -25
- data/.travis.yml +0 -28
- data/acceptance/skeletons/base/modules/facts/CHANGELOG.md +0 -26
- data/acceptance/skeletons/base/modules/facts/CONTRIBUTING.md +0 -279
- data/acceptance/skeletons/base/modules/facts/Gemfile +0 -98
- data/acceptance/skeletons/base/modules/facts/LICENSE +0 -201
- data/acceptance/skeletons/base/modules/facts/README.md +0 -45
- data/acceptance/skeletons/base/modules/facts/Rakefile +0 -8
- data/acceptance/skeletons/base/modules/facts/checksums.json +0 -42
- data/acceptance/skeletons/base/modules/facts/lib/puppet/functions/facts/group_by.rb +0 -14
- data/acceptance/skeletons/base/modules/facts/metadata.json +0 -62
- data/acceptance/skeletons/base/modules/facts/plans/info.pp +0 -16
- data/acceptance/skeletons/base/modules/facts/plans/init.pp +0 -13
- data/acceptance/skeletons/base/modules/facts/tasks/bash.json +0 -5
- data/acceptance/skeletons/base/modules/facts/tasks/bash.sh +0 -93
- data/acceptance/skeletons/base/modules/facts/tasks/init.json +0 -10
- data/acceptance/skeletons/base/modules/facts/tasks/powershell.json +0 -4
- data/acceptance/skeletons/base/modules/facts/tasks/powershell.ps1 +0 -56
- data/acceptance/skeletons/base/modules/facts/tasks/ruby.json +0 -4
- data/acceptance/skeletons/base/modules/facts/tasks/ruby.rb +0 -40
data/lib/vagrant-bolt/runner.rb
CHANGED
@@ -51,7 +51,7 @@ class VagrantBolt::Runner
|
|
51
51
|
|
52
52
|
# Ensure these are absolute paths to allow for running vagrant commands outside of the root dir
|
53
53
|
config.modulepath = VagrantBolt::Util::Config.relative_path(config.modulepath, @env.root_path)
|
54
|
-
config.
|
54
|
+
config.project = VagrantBolt::Util::Config.relative_path(config.project, @env.root_path)
|
55
55
|
|
56
56
|
config
|
57
57
|
end
|
@@ -63,7 +63,7 @@ class VagrantBolt::Runner
|
|
63
63
|
errors.merge!(@boltconfig.validate(@machine))
|
64
64
|
errors.merge!(validate_config)
|
65
65
|
|
66
|
-
errors.
|
66
|
+
errors.each_key do |key|
|
67
67
|
errors.delete(key) if errors[key].empty?
|
68
68
|
end
|
69
69
|
|
@@ -45,7 +45,7 @@ module VagrantBolt::Util
|
|
45
45
|
# @param env [Object] The env object
|
46
46
|
# @return [Hash] The hash of config options for the inventory.yaml
|
47
47
|
def self.generate_inventory_hash(env)
|
48
|
-
inventory = { '
|
48
|
+
inventory = { 'targets' => [] }
|
49
49
|
inventory.merge!(env.vagrantfile.config.bolt.inventory_config.compact)
|
50
50
|
VagrantBolt::Util::Machine.machines_in_environment(env).each do |vm|
|
51
51
|
next unless VagrantBolt::Util::Machine.running?(vm)
|
@@ -18,10 +18,11 @@ module VagrantBolt::Util
|
|
18
18
|
[other, local].each do |obj|
|
19
19
|
obj.instance_variables.each do |key|
|
20
20
|
value = obj.instance_variable_get(key)
|
21
|
-
|
21
|
+
case value
|
22
|
+
when Array
|
22
23
|
res_value = result.instance_variable_get(key)
|
23
24
|
value = (value + res_value).uniq if res_value.is_a? Array
|
24
|
-
|
25
|
+
when Hash
|
25
26
|
res_value = result.instance_variable_get(key)
|
26
27
|
value = res_value.merge(value) if res_value.is_a? Hash
|
27
28
|
end
|
@@ -21,9 +21,10 @@ module VagrantBolt::Util
|
|
21
21
|
notify: [:stdout, :stderr],
|
22
22
|
env: { PATH: ENV["VAGRANT_OLD_ENV_PATH"] },
|
23
23
|
) do |io_name, data|
|
24
|
-
|
24
|
+
case io_name
|
25
|
+
when :stdout
|
25
26
|
localui.info data
|
26
|
-
|
27
|
+
when :stderr
|
27
28
|
localui.warn data
|
28
29
|
end
|
29
30
|
end
|
data/lib/vagrant-bolt/version.rb
CHANGED
@@ -106,6 +106,7 @@ describe VagrantBolt::Config::Bolt do
|
|
106
106
|
"modulepath",
|
107
107
|
"bolt_exe",
|
108
108
|
"boltdir",
|
109
|
+
"project",
|
109
110
|
"noop",
|
110
111
|
]
|
111
112
|
expected_nil.each do |val|
|
@@ -124,12 +125,13 @@ describe VagrantBolt::Config::Bolt do
|
|
124
125
|
"password" => "foo",
|
125
126
|
"port" => "22",
|
126
127
|
"run-as" => "root",
|
128
|
+
"user" => "Admin",
|
127
129
|
"host-key-check" => false,
|
128
130
|
},
|
129
131
|
"winrm" => {
|
130
132
|
"password" => "foo",
|
131
133
|
"port" => "22",
|
132
|
-
"
|
134
|
+
"user" => "Admin",
|
133
135
|
"ssl" => false,
|
134
136
|
},
|
135
137
|
},
|
@@ -138,6 +140,7 @@ describe VagrantBolt::Config::Bolt do
|
|
138
140
|
before(:each) do
|
139
141
|
subject.password = 'foo'
|
140
142
|
subject.run_as = 'root'
|
143
|
+
subject.user = 'Admin'
|
141
144
|
subject.port = '22'
|
142
145
|
subject.ssl = false
|
143
146
|
subject.host_key_check = false
|
@@ -26,7 +26,7 @@ describe VagrantBolt::Config::Global do
|
|
26
26
|
|
27
27
|
expected_values = {
|
28
28
|
bolt_exe: "/opt/puppetlabs/bin/bolt",
|
29
|
-
|
29
|
+
project: ".",
|
30
30
|
}
|
31
31
|
expected_values.each do |val, expected|
|
32
32
|
it "defaults #{val} to #{expected}" do
|
@@ -70,12 +70,13 @@ describe VagrantBolt::Config::Global do
|
|
70
70
|
"password" => "foo",
|
71
71
|
"port" => "22",
|
72
72
|
"run-as" => "root",
|
73
|
+
"user" => "Admin",
|
73
74
|
"host-key-check" => false,
|
74
75
|
},
|
75
76
|
"winrm" => {
|
76
77
|
"password" => "foo",
|
77
78
|
"port" => "22",
|
78
|
-
"
|
79
|
+
"user" => "Admin",
|
79
80
|
"ssl" => false,
|
80
81
|
},
|
81
82
|
},
|
@@ -84,6 +85,7 @@ describe VagrantBolt::Config::Global do
|
|
84
85
|
before(:each) do
|
85
86
|
subject.password = 'foo'
|
86
87
|
subject.run_as = 'root'
|
88
|
+
subject.user = 'Admin'
|
87
89
|
subject.port = '22'
|
88
90
|
subject.ssl = false
|
89
91
|
subject.host_key_check = false
|
@@ -125,11 +125,21 @@ describe VagrantBolt::Runner do
|
|
125
125
|
end
|
126
126
|
|
127
127
|
it 'creates a shell execution' do
|
128
|
+
config.bolt_exe = 'bolt'
|
129
|
+
config.project = '.'
|
130
|
+
config.target_list = 'ssh://test:22'
|
131
|
+
config.finalize!
|
132
|
+
command = "bolt task run 'foo' --project '.' --inventoryfile '#{inventory_path}' --targets 'ssh://test:22'"
|
133
|
+
expect(Vagrant::Util::Subprocess).to receive(:execute).with('bash', '-c', command, options).and_return(subprocess_result)
|
134
|
+
subject.run('task', 'foo')
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'creates a shell execution with a project' do
|
128
138
|
config.bolt_exe = 'bolt'
|
129
139
|
config.boltdir = '.'
|
130
140
|
config.target_list = 'ssh://test:22'
|
131
141
|
config.finalize!
|
132
|
-
command = "bolt task run 'foo' --
|
142
|
+
command = "bolt task run 'foo' --project '.' --inventoryfile '#{inventory_path}' --targets 'ssh://test:22'"
|
133
143
|
expect(Vagrant::Util::Subprocess).to receive(:execute).with('bash', '-c', command, options).and_return(subprocess_result)
|
134
144
|
subject.run('task', 'foo')
|
135
145
|
end
|
data/spec/unit/util/bolt_spec.rb
CHANGED
@@ -51,7 +51,6 @@ describe VagrantBolt::Util::Bolt do
|
|
51
51
|
{
|
52
52
|
'targets' => [machine_hash],
|
53
53
|
'config' => config_hash['config'],
|
54
|
-
'version' => 2,
|
55
54
|
}
|
56
55
|
end
|
57
56
|
before(:each) do
|
@@ -110,10 +109,18 @@ describe VagrantBolt::Util::Bolt do
|
|
110
109
|
end
|
111
110
|
|
112
111
|
it 'adds directories to the command' do
|
112
|
+
config.modulepath = 'baz'
|
113
|
+
config.project = 'foo'
|
114
|
+
config.finalize!
|
115
|
+
expected = "bolt task run 'foo' --modulepath 'baz' --project 'foo' --inventoryfile '#{inventory_path}'"
|
116
|
+
expect(subject.generate_bolt_command(config, inventory_path)).to eq(expected)
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'uses project when boltdir is specified' do
|
113
120
|
config.modulepath = 'baz'
|
114
121
|
config.boltdir = 'foo'
|
115
122
|
config.finalize!
|
116
|
-
expected = "bolt task run 'foo' --
|
123
|
+
expected = "bolt task run 'foo' --modulepath 'baz' --project 'foo' --inventoryfile '#{inventory_path}'"
|
117
124
|
expect(subject.generate_bolt_command(config, inventory_path)).to eq(expected)
|
118
125
|
end
|
119
126
|
|
@@ -141,6 +148,15 @@ describe VagrantBolt::Util::Bolt do
|
|
141
148
|
expect(subject.generate_bolt_command(config, inventory_path)).to eq(expected)
|
142
149
|
end
|
143
150
|
|
151
|
+
it 'run_as is not included' do
|
152
|
+
config.node_list = 'ssh://test:22'
|
153
|
+
config.user = 'user'
|
154
|
+
config.run_as = 'foo'
|
155
|
+
config.finalize!
|
156
|
+
expected = "bolt task run 'foo' --user \'user\' --inventoryfile '#{inventory_path}' --targets \'ssh://test:22\'"
|
157
|
+
expect(subject.generate_bolt_command(config, inventory_path)).to eq(expected)
|
158
|
+
end
|
159
|
+
|
144
160
|
it 'debug, verbose, and noop are omitted when false' do
|
145
161
|
config.debug = false
|
146
162
|
config.verbose = false
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarret Lavallee
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: " Vagrant provisioning with Puppet Bolt\n"
|
14
14
|
email:
|
@@ -17,10 +17,10 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".github/workflows/spec.yml"
|
20
21
|
- ".gitignore"
|
21
22
|
- ".rspec"
|
22
23
|
- ".rubocop.yml"
|
23
|
-
- ".travis.yml"
|
24
24
|
- ".yardopts"
|
25
25
|
- CHANGELOG.md
|
26
26
|
- Gemfile
|
@@ -32,25 +32,8 @@ files:
|
|
32
32
|
- acceptance/artifacts/.keep
|
33
33
|
- acceptance/components/bolt_spec.rb
|
34
34
|
- acceptance/skeletons/advanced/Vagrantfile
|
35
|
+
- acceptance/skeletons/base/Puppetfile
|
35
36
|
- acceptance/skeletons/base/Vagrantfile
|
36
|
-
- acceptance/skeletons/base/modules/facts/CHANGELOG.md
|
37
|
-
- acceptance/skeletons/base/modules/facts/CONTRIBUTING.md
|
38
|
-
- acceptance/skeletons/base/modules/facts/Gemfile
|
39
|
-
- acceptance/skeletons/base/modules/facts/LICENSE
|
40
|
-
- acceptance/skeletons/base/modules/facts/README.md
|
41
|
-
- acceptance/skeletons/base/modules/facts/Rakefile
|
42
|
-
- acceptance/skeletons/base/modules/facts/checksums.json
|
43
|
-
- acceptance/skeletons/base/modules/facts/lib/puppet/functions/facts/group_by.rb
|
44
|
-
- acceptance/skeletons/base/modules/facts/metadata.json
|
45
|
-
- acceptance/skeletons/base/modules/facts/plans/info.pp
|
46
|
-
- acceptance/skeletons/base/modules/facts/plans/init.pp
|
47
|
-
- acceptance/skeletons/base/modules/facts/tasks/bash.json
|
48
|
-
- acceptance/skeletons/base/modules/facts/tasks/bash.sh
|
49
|
-
- acceptance/skeletons/base/modules/facts/tasks/init.json
|
50
|
-
- acceptance/skeletons/base/modules/facts/tasks/powershell.json
|
51
|
-
- acceptance/skeletons/base/modules/facts/tasks/powershell.ps1
|
52
|
-
- acceptance/skeletons/base/modules/facts/tasks/ruby.json
|
53
|
-
- acceptance/skeletons/base/modules/facts/tasks/ruby.rb
|
54
37
|
- acceptance/skeletons/provisioner/Vagrantfile
|
55
38
|
- acceptance/skeletons/trigger/Vagrantfile
|
56
39
|
- acceptance/vagrant-spec.config.rb
|
@@ -88,7 +71,7 @@ homepage: https://github.com/oscar-stack/vagrant-bolt
|
|
88
71
|
licenses:
|
89
72
|
- Apache-2.0
|
90
73
|
metadata: {}
|
91
|
-
post_install_message:
|
74
|
+
post_install_message:
|
92
75
|
rdoc_options: []
|
93
76
|
require_paths:
|
94
77
|
- lib
|
@@ -103,9 +86,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
86
|
- !ruby/object:Gem::Version
|
104
87
|
version: '0'
|
105
88
|
requirements: []
|
106
|
-
rubyforge_project:
|
89
|
+
rubyforge_project:
|
107
90
|
rubygems_version: 2.7.6.2
|
108
|
-
signing_key:
|
91
|
+
signing_key:
|
109
92
|
specification_version: 4
|
110
93
|
summary: Vagrant provisioning with Puppet Bolt
|
111
94
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sudo: false
|
3
|
-
dist: trusty
|
4
|
-
language: ruby
|
5
|
-
cache: bundler
|
6
|
-
before_install:
|
7
|
-
- bundle -v
|
8
|
-
- rm -f Gemfile.lock
|
9
|
-
- gem update --system
|
10
|
-
- gem --version
|
11
|
-
- bundle -v
|
12
|
-
notifications:
|
13
|
-
email: false
|
14
|
-
script:
|
15
|
-
- 'bundle exec rake rubocop spec'
|
16
|
-
bundler_args: --without system_tests
|
17
|
-
env:
|
18
|
-
global:
|
19
|
-
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
20
|
-
rvm:
|
21
|
-
- 2.5.0
|
22
|
-
matrix:
|
23
|
-
fast_finish: true
|
24
|
-
include:
|
25
|
-
- rvm: 2.5.0
|
26
|
-
env: TEST_VAGRANT_VERSION=v2.2.9
|
27
|
-
- rvm: 2.6.6
|
28
|
-
env: TEST_VAGRANT_VERSION=HEAD
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# Change Log
|
2
|
-
|
3
|
-
## 0.3.1
|
4
|
-
### Fixed
|
5
|
-
- Allow setting Puppet gem version via `PUPPET_GEM_VERSION` so we can use Puppet 5 to ship the module.
|
6
|
-
|
7
|
-
## 0.3.0
|
8
|
-
### Fixed
|
9
|
-
- Task metadata specifies environment input to work around BOLT-691.
|
10
|
-
|
11
|
-
### Changed
|
12
|
-
- Stop hiding failures gathering facts in the `facts` plan.
|
13
|
-
|
14
|
-
### Removed
|
15
|
-
- `facts::retrieve` as redundant with the `facts` task when cross-platform
|
16
|
-
tasks are supported.
|
17
|
-
|
18
|
-
## 0.2.0
|
19
|
-
### Added
|
20
|
-
- Legacy facts added to results.
|
21
|
-
- Improve ability of bash and ruby task to find facter executable path.
|
22
|
-
|
23
|
-
## 0.1.2
|
24
|
-
|
25
|
-
### Changed
|
26
|
-
- Move facts to external module (from bolt).
|
@@ -1,279 +0,0 @@
|
|
1
|
-
# Contributing to Puppet modules
|
2
|
-
|
3
|
-
So you want to contribute to a Puppet module: Great! Below are some instructions to get you started doing
|
4
|
-
that very thing while setting expectations around code quality as well as a few tips for making the
|
5
|
-
process as easy as possible.
|
6
|
-
|
7
|
-
### Table of Contents
|
8
|
-
|
9
|
-
1. [Getting Started](#getting-started)
|
10
|
-
1. [Commit Checklist](#commit-checklist)
|
11
|
-
1. [Submission](#submission)
|
12
|
-
1. [More about commits](#more-about-commits)
|
13
|
-
1. [Testing](#testing)
|
14
|
-
- [Running Tests](#running-tests)
|
15
|
-
- [Writing Tests](#writing-tests)
|
16
|
-
1. [Get Help](#get-help)
|
17
|
-
|
18
|
-
## Getting Started
|
19
|
-
|
20
|
-
- Fork the module repository on GitHub and clone to your workspace
|
21
|
-
|
22
|
-
- Make your changes!
|
23
|
-
|
24
|
-
## Commit Checklist
|
25
|
-
|
26
|
-
### The Basics
|
27
|
-
|
28
|
-
- [x] my commit is a single logical unit of work
|
29
|
-
|
30
|
-
- [x] I have checked for unnecessary whitespace with "git diff --check"
|
31
|
-
|
32
|
-
- [x] my commit does not include commented out code or unneeded files
|
33
|
-
|
34
|
-
### The Content
|
35
|
-
|
36
|
-
- [x] my commit includes tests for the bug I fixed or feature I added
|
37
|
-
|
38
|
-
- [x] my commit includes appropriate documentation changes if it is introducing a new feature or changing existing functionality
|
39
|
-
|
40
|
-
- [x] my code passes existing test suites
|
41
|
-
|
42
|
-
### The Commit Message
|
43
|
-
|
44
|
-
- [x] the first line of my commit message includes:
|
45
|
-
|
46
|
-
- [x] an issue number (if applicable), e.g. "(MODULES-xxxx) This is the first line"
|
47
|
-
|
48
|
-
- [x] a short description (50 characters is the soft limit, excluding ticket number(s))
|
49
|
-
|
50
|
-
- [x] the body of my commit message:
|
51
|
-
|
52
|
-
- [x] is meaningful
|
53
|
-
|
54
|
-
- [x] uses the imperative, present tense: "change", not "changed" or "changes"
|
55
|
-
|
56
|
-
- [x] includes motivation for the change, and contrasts its implementation with the previous behavior
|
57
|
-
|
58
|
-
## Submission
|
59
|
-
|
60
|
-
### Pre-requisites
|
61
|
-
|
62
|
-
- Make sure you have a [GitHub account](https://github.com/join)
|
63
|
-
|
64
|
-
- [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for.
|
65
|
-
|
66
|
-
### Push and PR
|
67
|
-
|
68
|
-
- Push your changes to your fork
|
69
|
-
|
70
|
-
- [Open a Pull Request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) against the repository in the puppetlabs organization
|
71
|
-
|
72
|
-
## More about commits
|
73
|
-
|
74
|
-
1. Make separate commits for logically separate changes.
|
75
|
-
|
76
|
-
Please break your commits down into logically consistent units
|
77
|
-
which include new or changed tests relevant to the rest of the
|
78
|
-
change. The goal of doing this is to make the diff easier to
|
79
|
-
read for whoever is reviewing your code. In general, the easier
|
80
|
-
your diff is to read, the more likely someone will be happy to
|
81
|
-
review it and get it into the code base.
|
82
|
-
|
83
|
-
If you are going to refactor a piece of code, please do so as a
|
84
|
-
separate commit from your feature or bug fix changes.
|
85
|
-
|
86
|
-
We also really appreciate changes that include tests to make
|
87
|
-
sure the bug is not re-introduced, and that the feature is not
|
88
|
-
accidentally broken.
|
89
|
-
|
90
|
-
Describe the technical detail of the change(s). If your
|
91
|
-
description starts to get too long, that is a good sign that you
|
92
|
-
probably need to split up your commit into more finely grained
|
93
|
-
pieces.
|
94
|
-
|
95
|
-
Commits which plainly describe the things which help
|
96
|
-
reviewers check the patch and future developers understand the
|
97
|
-
code are much more likely to be merged in with a minimum of
|
98
|
-
bike-shedding or requested changes. Ideally, the commit message
|
99
|
-
would include information, and be in a form suitable for
|
100
|
-
inclusion in the release notes for the version of Puppet that
|
101
|
-
includes them.
|
102
|
-
|
103
|
-
Please also check that you are not introducing any trailing
|
104
|
-
whitespace or other "whitespace errors". You can do this by
|
105
|
-
running "git diff --check" on your changes before you commit.
|
106
|
-
|
107
|
-
2. Sending your patches
|
108
|
-
|
109
|
-
To submit your changes via a GitHub pull request, we _highly_
|
110
|
-
recommend that you have them on a topic branch, instead of
|
111
|
-
directly on "master".
|
112
|
-
It makes things much easier to keep track of, especially if
|
113
|
-
you decide to work on another thing before your first change
|
114
|
-
is merged in.
|
115
|
-
|
116
|
-
GitHub has some pretty good
|
117
|
-
[general documentation](http://help.github.com/) on using
|
118
|
-
their site. They also have documentation on
|
119
|
-
[creating pull requests](https://help.github.com/articles/creating-a-pull-request-from-a-fork/).
|
120
|
-
|
121
|
-
In general, after pushing your topic branch up to your
|
122
|
-
repository on GitHub, you can switch to the branch in the
|
123
|
-
GitHub UI and click "Pull Request" towards the top of the page
|
124
|
-
in order to open a pull request.
|
125
|
-
|
126
|
-
3. Update the related JIRA issue.
|
127
|
-
|
128
|
-
If there is a JIRA issue associated with the change you
|
129
|
-
submitted, then you should update the ticket to include the
|
130
|
-
location of your branch, along with any other commentary you
|
131
|
-
may wish to make.
|
132
|
-
|
133
|
-
# Testing
|
134
|
-
|
135
|
-
## Getting Started
|
136
|
-
|
137
|
-
Our Puppet modules provide [`Gemfile`](./Gemfile)s, which can tell a Ruby package manager such as [bundler](http://bundler.io/) what Ruby packages,
|
138
|
-
or Gems, are required to build, develop, and test this software.
|
139
|
-
|
140
|
-
Please make sure you have [bundler installed](http://bundler.io/#getting-started) on your system, and then use it to
|
141
|
-
install all dependencies needed for this project in the project root by running
|
142
|
-
|
143
|
-
```shell
|
144
|
-
% bundle install --path .bundle/gems
|
145
|
-
Fetching gem metadata from https://rubygems.org/........
|
146
|
-
Fetching gem metadata from https://rubygems.org/..
|
147
|
-
Using rake (10.1.0)
|
148
|
-
Using builder (3.2.2)
|
149
|
-
-- 8><-- many more --><8 --
|
150
|
-
Using rspec-system-puppet (2.2.0)
|
151
|
-
Using serverspec (0.6.3)
|
152
|
-
Using rspec-system-serverspec (1.0.0)
|
153
|
-
Using bundler (1.3.5)
|
154
|
-
Your bundle is complete!
|
155
|
-
Use `bundle show [gemname]` to see where a bundled gem is installed.
|
156
|
-
```
|
157
|
-
|
158
|
-
NOTE: some systems may require you to run this command with sudo.
|
159
|
-
|
160
|
-
If you already have those gems installed, make sure they are up-to-date:
|
161
|
-
|
162
|
-
```shell
|
163
|
-
% bundle update
|
164
|
-
```
|
165
|
-
|
166
|
-
## Running Tests
|
167
|
-
|
168
|
-
With all dependencies in place and up-to-date, run the tests:
|
169
|
-
|
170
|
-
### Unit Tests
|
171
|
-
|
172
|
-
```shell
|
173
|
-
% bundle exec rake spec
|
174
|
-
```
|
175
|
-
|
176
|
-
This executes all the [rspec tests](http://rspec-puppet.com/) in the directories defined [here](https://github.com/puppetlabs/puppetlabs_spec_helper/blob/699d9fbca1d2489bff1736bb254bb7b7edb32c74/lib/puppetlabs_spec_helper/rake_tasks.rb#L17) and so on.
|
177
|
-
rspec tests may have the same kind of dependencies as the module they are testing. Although the module defines these dependencies in its [metadata.json](./metadata.json),
|
178
|
-
rspec tests define them in [.fixtures.yml](./fixtures.yml).
|
179
|
-
|
180
|
-
### Acceptance Tests
|
181
|
-
|
182
|
-
Some Puppet modules also come with acceptance tests, which use [beaker][]. These tests spin up a virtual machine under
|
183
|
-
[VirtualBox](https://www.virtualbox.org/), controlled with [Vagrant](http://www.vagrantup.com/), to simulate scripted test
|
184
|
-
scenarios. In order to run these, you need both Virtualbox and Vagrant installed on your system.
|
185
|
-
|
186
|
-
Run the tests by issuing the following command
|
187
|
-
|
188
|
-
```shell
|
189
|
-
% bundle exec rake spec_clean
|
190
|
-
% bundle exec rspec spec/acceptance
|
191
|
-
```
|
192
|
-
|
193
|
-
This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml),
|
194
|
-
install Puppet, copy this module, and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb)
|
195
|
-
and then run all the tests under [spec/acceptance](./spec/acceptance).
|
196
|
-
|
197
|
-
A specific node set can be selected by setting the `BEAKER_set` environment variable
|
198
|
-
|
199
|
-
```shell
|
200
|
-
% export BEAKER_set=spec/acceptance/nodesets/centos-7-x64
|
201
|
-
```
|
202
|
-
|
203
|
-
If using a VM pooler node set, a password must be set via `BEAKER_password`.
|
204
|
-
|
205
|
-
## Writing Tests
|
206
|
-
|
207
|
-
### Unit Tests
|
208
|
-
|
209
|
-
When writing unit tests for Puppet, [rspec-puppet][] is your best friend. It provides tons of helper methods for testing your manifests against a
|
210
|
-
catalog (e.g. contain_file, contain_package, with_params, etc). It would be ridiculous to try and top rspec-puppet's [documentation][rspec-puppet_docs]
|
211
|
-
but here's a tiny sample:
|
212
|
-
|
213
|
-
Sample manifest:
|
214
|
-
|
215
|
-
```puppet
|
216
|
-
file { "a test file":
|
217
|
-
ensure => present,
|
218
|
-
path => "/etc/sample",
|
219
|
-
}
|
220
|
-
```
|
221
|
-
|
222
|
-
Sample test:
|
223
|
-
|
224
|
-
```ruby
|
225
|
-
it 'does a thing' do
|
226
|
-
expect(subject).to contain_file("a test file").with({:path => "/etc/sample"})
|
227
|
-
end
|
228
|
-
```
|
229
|
-
|
230
|
-
### Acceptance Tests
|
231
|
-
|
232
|
-
Writing acceptance tests for Puppet involves [beaker][] and its cousin [beaker-rspec][]. A common pattern for acceptance tests is to create a test manifest, apply it
|
233
|
-
twice to check for idempotency or errors, then run expectations.
|
234
|
-
|
235
|
-
```ruby
|
236
|
-
it 'does an end-to-end thing' do
|
237
|
-
pp = <<-EOF
|
238
|
-
file { 'a test file':
|
239
|
-
ensure => present,
|
240
|
-
path => "/etc/sample",
|
241
|
-
content => "test string",
|
242
|
-
}
|
243
|
-
|
244
|
-
apply_manifest(pp, :catch_failures => true)
|
245
|
-
apply_manifest(pp, :catch_changes => true)
|
246
|
-
|
247
|
-
end
|
248
|
-
|
249
|
-
describe file("/etc/sample") do
|
250
|
-
it { is_expected.to contain "test string" }
|
251
|
-
end
|
252
|
-
|
253
|
-
```
|
254
|
-
|
255
|
-
# If you have commit access to the repository
|
256
|
-
|
257
|
-
Even if you have commit access to the repository, you still need to go through the process above, and have someone else review and merge
|
258
|
-
in your changes. The rule is that **all changes must be reviewed by a project developer that did not write the code to ensure that
|
259
|
-
all changes go through a code review process.**
|
260
|
-
|
261
|
-
The record of someone performing the merge is the record that they performed the code review. Again, this should be someone other than the author of the topic branch.
|
262
|
-
|
263
|
-
# Get Help
|
264
|
-
|
265
|
-
### On the web
|
266
|
-
* [Puppet help messageboard](http://puppet.com/community/get-help)
|
267
|
-
* [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing)
|
268
|
-
* [General GitHub documentation](http://help.github.com/)
|
269
|
-
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
|
270
|
-
|
271
|
-
### On chat
|
272
|
-
* Slack (slack.puppet.com) #forge-modules, #puppet-dev, #windows, #voxpupuli
|
273
|
-
* IRC (freenode) #puppet-dev, #voxpupuli
|
274
|
-
|
275
|
-
|
276
|
-
[rspec-puppet]: http://rspec-puppet.com/
|
277
|
-
[rspec-puppet_docs]: http://rspec-puppet.com/documentation/
|
278
|
-
[beaker]: https://github.com/puppetlabs/beaker
|
279
|
-
[beaker-rspec]: https://github.com/puppetlabs/beaker-rspec
|