vagrant-orchestrate 0.0.1 → 0.0.2
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/Gemfile +1 -0
- data/README.md +4 -4
- data/lib/vagrant-orchestrate/command/init.rb +41 -5
- data/lib/vagrant-orchestrate/plugin.rb +3 -0
- data/lib/vagrant-orchestrate/version.rb +1 -1
- data/locales/en.yml +7 -0
- data/spec/vagrant-orchestrate/command/init_spec.rb +55 -1
- data/templates/puppet/Puppetfile.erb +7 -0
- data/templates/puppet/hiera/common.yaml.erb +0 -0
- data/templates/puppet/hiera.yaml.erb +10 -0
- data/templates/vagrant/Vagrantfile.erb +9 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23910236a77b4ef2a42c5bc7fbe15f21083387c6
|
4
|
+
data.tar.gz: 4337fc38a9860cfabbbf8caa76379f04350b5870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd6785a727f48143884d8d7455648a8f52f076ff8a703413872c17b55acb8d3936f9c890bd60cbf07e5b1b6f0fdc286365aebd5dec16c5887633531a47335939
|
7
|
+
data.tar.gz: bfedff81ef33fbd3ba404be46b9a342f485003f7ec36229f72036218370bd775359ddd5c88e77abb74943e5b5d2b34221d158ad0b4fc944f673f2b0e71f47e74
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -17,18 +17,18 @@ Initialize a Vagrantfile to orchestrate running a script on multiple managed ser
|
|
17
17
|
|
18
18
|
$ vagrant orchestrate init --shell
|
19
19
|
|
20
|
-
You'll need to edit your Vagrantfile and replace some
|
20
|
+
You'll need to edit your Vagrantfile and replace some variables, such as ssh username and
|
21
21
|
password, and the path to the script to run. The first line of the file defines an array of
|
22
22
|
managed servers that the `push` command will operate on.
|
23
23
|
|
24
24
|
This works for Windows managed servers as well
|
25
25
|
|
26
|
-
$ vagrant orchestrate init --winrm [--winrm-username
|
26
|
+
$ vagrant orchestrate init --winrm [--winrm-username USERNAME --winrm-password PASSWORD]
|
27
27
|
|
28
28
|
For a full list of init options, run `vagrant orchestrate init --help`
|
29
29
|
|
30
30
|
### Pushing changes
|
31
|
-
Go ahead and push changes to your managed servers
|
31
|
+
Go ahead and push changes to your managed servers
|
32
32
|
|
33
33
|
$ vagrant orchestrate push
|
34
34
|
|
@@ -46,7 +46,7 @@ merge that feature into downstream environments to avoid conflicts.
|
|
46
46
|
|
47
47
|
## Tips for Windows hosts
|
48
48
|
|
49
|
-
* Need rsync? Install [OpenSSH](http://www.mls-software.com/opensshd.html) and then run this [script]() to install rsync. Vagrant managed servers currently only works with cygwin based rsync implementations.
|
49
|
+
* Need rsync? Install [OpenSSH](http://www.mls-software.com/opensshd.html) and then run this [script](https://github.com/joefitzgerald/packer-windows/blob/master/scripts/rsync.bat) to install rsync. Vagrant managed servers currently only works with cygwin based rsync implementations.
|
50
50
|
|
51
51
|
## Contributing
|
52
52
|
|
@@ -17,7 +17,7 @@ module VagrantPlugins
|
|
17
17
|
DEFAULT_SSH_PRIVATE_KEY_PATH = "{{YOUR_SSH_PRIVATE_KEY_PATH}}"
|
18
18
|
DEFAULT_PLUGINS = ["vagrant-managed-servers"]
|
19
19
|
|
20
|
-
# rubocop:disable Metrics/AbcSize, MethodLength
|
20
|
+
# rubocop:disable Metrics/AbcSize, MethodLength, Metrics/CyclomaticComplexity
|
21
21
|
def execute
|
22
22
|
options = {}
|
23
23
|
|
@@ -52,6 +52,15 @@ module VagrantPlugins
|
|
52
52
|
options[:provisioners] << "puppet"
|
53
53
|
end
|
54
54
|
|
55
|
+
o.on("--puppet-hiera", "Include templates for hiera. Only with --puppet") do |p|
|
56
|
+
options[:puppet_hiera] = p
|
57
|
+
end
|
58
|
+
|
59
|
+
o.on("--puppet-librarian-puppet",
|
60
|
+
"Include a Puppetfile and the vagrant-librarian-puppet plugin. Only with --puppet") do |p|
|
61
|
+
options[:puppet_librarian_puppet] = p
|
62
|
+
end
|
63
|
+
|
55
64
|
o.on("--ssh-username USERNAME", String, "The username for communicating over ssh") do |u|
|
56
65
|
options[:ssh_username] = u
|
57
66
|
end
|
@@ -92,6 +101,31 @@ module VagrantPlugins
|
|
92
101
|
argv = parse_options(opts)
|
93
102
|
return unless argv
|
94
103
|
|
104
|
+
if options[:provisioners].include? "puppet"
|
105
|
+
options[:puppet_librarian_puppet] ||= true
|
106
|
+
if options[:puppet_librarian_puppet]
|
107
|
+
contents = TemplateRenderer.render(Orchestrate.source_root.join("templates/puppet/Puppetfile"))
|
108
|
+
write_file "Puppetfile", contents, options
|
109
|
+
FileUtils.mkdir_p(File.join(@env.cwd, "modules"))
|
110
|
+
contents = "# This is a placeholder file to keep the modules directory around."
|
111
|
+
write_file(File.join(@env.cwd, "modules", ".PLACEHOLDER"), contents, options)
|
112
|
+
options[:plugins] << "vagrant-librarian-puppet"
|
113
|
+
@env.ui.info(I18n.t("vagrant_orchestrate.librarian_puppet.gitignore"), prefix: false)
|
114
|
+
end
|
115
|
+
|
116
|
+
options[:puppet_hiera] ||= true
|
117
|
+
if options[:puppet_hiera]
|
118
|
+
contents = TemplateRenderer.render(Orchestrate.source_root.join("templates/puppet/hiera.yaml"))
|
119
|
+
write_file("hiera.yaml", contents, options)
|
120
|
+
FileUtils.mkdir_p(File.join(@env.cwd, "hiera"))
|
121
|
+
contents = TemplateRenderer.render(Orchestrate.source_root.join("templates/puppet/hiera/common.yaml"))
|
122
|
+
write_file(File.join(@env.cwd, "hiera", "common.yaml"), contents, options)
|
123
|
+
end
|
124
|
+
|
125
|
+
FileUtils.mkdir_p(File.join(@env.cwd, "manifests"))
|
126
|
+
write_file(File.join(@env.cwd, "manifests", "default.pp"), "# Your puppet code goes here", options)
|
127
|
+
end
|
128
|
+
|
95
129
|
options[:shell_paths] ||= options[:shell_inline] ? [] : [DEFAULT_SHELL_PATH]
|
96
130
|
options[:shell_inline] ||= DEFAULT_SHELL_INLINE
|
97
131
|
options[:winrm_username] ||= DEFAULT_WINRM_USERNAME
|
@@ -105,6 +139,8 @@ module VagrantPlugins
|
|
105
139
|
provisioners: options[:provisioners],
|
106
140
|
shell_paths: options[:shell_paths],
|
107
141
|
shell_inline: options[:shell_inline],
|
142
|
+
puppet_librarian_puppet: options[:puppet_librarian_puppet],
|
143
|
+
puppet_hiera: options[:puppet_hiera],
|
108
144
|
communicator: options[:communicator],
|
109
145
|
winrm_username: options[:winrm_username],
|
110
146
|
winrm_password: options[:winrm_password],
|
@@ -114,19 +150,19 @@ module VagrantPlugins
|
|
114
150
|
servers: options[:servers],
|
115
151
|
plugins: options[:plugins]
|
116
152
|
)
|
117
|
-
|
153
|
+
write_file("Vagrantfile", contents, options)
|
118
154
|
|
119
155
|
@env.ui.info(I18n.t("vagrant.commands.init.success"), prefix: false)
|
120
156
|
|
121
157
|
# Success, exit status 0
|
122
158
|
0
|
123
159
|
end
|
124
|
-
# rubocop:enable Metrics/AbcSize, MethodLength
|
160
|
+
# rubocop:enable Metrics/AbcSize, MethodLength, Metrics/CyclomaticComplexity
|
125
161
|
|
126
162
|
private
|
127
163
|
|
128
|
-
def
|
129
|
-
save_path = Pathname.new(
|
164
|
+
def write_file(filename, contents, options)
|
165
|
+
save_path = Pathname.new(filename).expand_path(@env.cwd)
|
130
166
|
save_path.delete if save_path.exist? && options[:force]
|
131
167
|
fail Vagrant::Errors::VagrantfileExistsError if save_path.exist?
|
132
168
|
|
data/locales/en.yml
CHANGED
@@ -75,13 +75,19 @@ describe VagrantPlugins::Orchestrate::Command::Init do
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
context "puppet
|
78
|
+
context "puppet" do
|
79
79
|
describe "basic operation" do
|
80
80
|
let(:argv) { ["--provision-with", "puppet"] }
|
81
81
|
it "creates a vagrantfile with a puppet provisioner" do
|
82
82
|
subject.execute
|
83
83
|
expect(iso_env.vagrantfile.config.vm.provisioners.first.type).to eq(:puppet)
|
84
84
|
end
|
85
|
+
|
86
|
+
it "creates the default files" do
|
87
|
+
subject.execute
|
88
|
+
expect(Dir.entries(iso_env.cwd)).to include("manifests")
|
89
|
+
expect(Dir.entries(File.join(iso_env.cwd, "manifests"))).to include("default.pp")
|
90
|
+
end
|
85
91
|
end
|
86
92
|
|
87
93
|
describe "shorthand" do
|
@@ -91,6 +97,54 @@ describe VagrantPlugins::Orchestrate::Command::Init do
|
|
91
97
|
expect(iso_env.vagrantfile.config.vm.provisioners.first.type).to eq(:puppet)
|
92
98
|
end
|
93
99
|
end
|
100
|
+
|
101
|
+
describe "librarian puppet" do
|
102
|
+
let(:argv) { ["--puppet", "--puppet-librarian-puppet"] }
|
103
|
+
it "is passed into the Vagrantfile" do
|
104
|
+
subject.execute
|
105
|
+
expect(iso_env.vagrantfile.config.librarian_puppet.placeholder_filename).to eq(".PLACEHOLDER")
|
106
|
+
end
|
107
|
+
|
108
|
+
it "creates the modules directory and placeholder" do
|
109
|
+
subject.execute
|
110
|
+
expect(Dir.entries(iso_env.cwd)).to include("modules")
|
111
|
+
expect(Dir.entries(File.join(iso_env.cwd, "modules"))).to include(".PLACEHOLDER")
|
112
|
+
end
|
113
|
+
|
114
|
+
it "creates the Puppetfile" do
|
115
|
+
subject.execute
|
116
|
+
expect(Dir.entries(iso_env.cwd)).to include("Puppetfile")
|
117
|
+
end
|
118
|
+
|
119
|
+
it "contains the plugin" do
|
120
|
+
subject.execute
|
121
|
+
vagrantfile = File.readlines(File.join(iso_env.cwd, "Vagrantfile")).join
|
122
|
+
expect(vagrantfile).to include("vagrant-librarian-puppet")
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "ui" do
|
126
|
+
let(:ui_class) { Vagrant::UI::Basic }
|
127
|
+
it "displays a .gitignore message" do
|
128
|
+
output = capture_stdout { subject.execute }
|
129
|
+
expect(output).to include(".gitignore")
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "hiera" do
|
135
|
+
let(:argv) { ["--puppet", "--puppet-hiera"] }
|
136
|
+
it "is passed into the Vagrantfile" do
|
137
|
+
subject.execute
|
138
|
+
expect(iso_env.vagrantfile.config.vm.provisioners.first.config.hiera_config_path).to eq("hiera.yaml")
|
139
|
+
end
|
140
|
+
|
141
|
+
it "creates the file" do
|
142
|
+
subject.execute
|
143
|
+
expect(Dir.entries(iso_env.cwd)).to include("hiera.yaml")
|
144
|
+
expect(Dir.entries(iso_env.cwd)).to include("hiera")
|
145
|
+
expect(Dir.entries(File.join(iso_env.cwd, "hiera"))).to include("common.yaml")
|
146
|
+
end
|
147
|
+
end
|
94
148
|
end
|
95
149
|
|
96
150
|
context "winrm" do
|
File without changes
|
@@ -16,7 +16,16 @@ Vagrant.configure("2") do |config|
|
|
16
16
|
<% end -%>
|
17
17
|
<% end -%>
|
18
18
|
<% if provisioners.include? "puppet" -%>
|
19
|
+
<% if puppet_librarian_puppet -%>
|
20
|
+
config.librarian_puppet.placeholder_filename = ".PLACEHOLDER"
|
21
|
+
<% end -%>
|
19
22
|
config.vm.provision "puppet" do |puppet|
|
23
|
+
<% if puppet_librarian_puppet -%>
|
24
|
+
puppet.module_path = 'modules'
|
25
|
+
<% end -%>
|
26
|
+
<% if puppet_hiera -%>
|
27
|
+
puppet.hiera_config_path = 'hiera.yaml'
|
28
|
+
<% end -%>
|
20
29
|
end
|
21
30
|
<% end -%>
|
22
31
|
<% if communicator == "ssh" -%>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-orchestrate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Baldauf
|
@@ -76,6 +76,9 @@ files:
|
|
76
76
|
- spec/spec_helper.rb
|
77
77
|
- spec/vagrant-orchestrate/command/init_spec.rb
|
78
78
|
- spec/vagrant-orchestrate/command/root_spec.rb
|
79
|
+
- templates/puppet/Puppetfile.erb
|
80
|
+
- templates/puppet/hiera.yaml.erb
|
81
|
+
- templates/puppet/hiera/common.yaml.erb
|
79
82
|
- templates/vagrant/Vagrantfile.erb
|
80
83
|
- vagrant-orchestrate.gemspec
|
81
84
|
homepage: ''
|