vagrant-orchestrate 0.0.7 → 0.1.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/.gitignore +1 -0
- data/Gemfile +2 -1
- data/README.md +111 -12
- data/Rakefile +4 -0
- data/lib/vagrant-orchestrate/action/filtermanaged.rb +27 -0
- data/lib/vagrant-orchestrate/command/push.rb +11 -3
- data/lib/vagrant-orchestrate/config.rb +17 -0
- data/lib/vagrant-orchestrate/plugin.rb +23 -0
- data/lib/vagrant-orchestrate/version.rb +1 -1
- data/spec/vagrant-orchestrate/command/init_spec.rb +10 -1
- data/templates/vagrant/Vagrantfile.erb +10 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae428a0690c14047e05845e7f3a24da592882c9d
|
4
|
+
data.tar.gz: 6f3269c537f110f8c9b66c03e3b8cd2cf689d462
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd77d6176cf9fc391905c6f913a84719b0a6fecc1ead0a75e25d6d8ff390b97a45422db484b8a0a831de7090b9e4cfd36d7ecb1de044c855673584de51be3fdd
|
7
|
+
data.tar.gz: 5502b1cef7a68f9c8f5438d1958f9ec51ffb9ed5f50967029cc989a42b2fb75d386a89e1b05b691ac94dd35cf299af61ec9282e53818baef49d7c752192ce26e
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -4,7 +4,7 @@ source "https://rubygems.org"
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
group :development do
|
7
|
-
gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
|
7
|
+
gem "vagrant", git: "https://github.com/mitchellh/vagrant.git", ref: "v1.7.2"
|
8
8
|
gem "vagrant-spec", git: "https://github.com/mitchellh/vagrant-spec.git"
|
9
9
|
end
|
10
10
|
|
@@ -12,4 +12,5 @@ group :plugins do
|
|
12
12
|
gem "vagrant-orchestrate", path: "."
|
13
13
|
gem "vagrant-managed-servers"
|
14
14
|
gem "vagrant-librarian-puppet"
|
15
|
+
gem "vagrant-winrm-s"
|
15
16
|
end
|
data/README.md
CHANGED
@@ -1,10 +1,37 @@
|
|
1
1
|
# Vagrant Orchestrate
|
2
2
|
|
3
3
|
This is a Vagrant 1.6+ plugin that allows orchestrated deployments
|
4
|
-
to
|
4
|
+
to already provisioned (non-elastic) servers on top of the excellent vagrant-managed-servers plugin.
|
5
5
|
It features a powerful templating `init` command and is designed from the
|
6
|
-
ground up to be cross-platform, with first class support for Windows,
|
7
|
-
Linux, and Mac
|
6
|
+
ground up to be cross-platform, with first class support for **Windows,
|
7
|
+
Linux, and Mac**.
|
8
|
+
|
9
|
+
## Quick start
|
10
|
+
|
11
|
+
```
|
12
|
+
$ vagrant orchestrate init --shell --shell-inline "echo Hello" \
|
13
|
+
--servers myserver1.mydomain.com,myserver2.mydomain.com \
|
14
|
+
--ssh-username USERNAME --ssh-private-key-path PATH
|
15
|
+
$ vagrant orchestrate push
|
16
|
+
==> managed-myserver1.mydomain.com: Linking vagrant with managed server myserver1.mydomain.com
|
17
|
+
==> managed-myserver1.mydomain.com: -- Server: myserver1.mydomain.com
|
18
|
+
==> managed-myserver1.mydomain.com: Rsyncing folder: ~/dev/demo => /vagrant
|
19
|
+
==> managed-myserver1.mydomain.com: Running provisioner: shell...
|
20
|
+
==> managed-myserver1.mydomain.com: Running: inline script
|
21
|
+
==> managed-myserver1.mydomain.com: Hello
|
22
|
+
==> managed-myserver1.mydomain.com: Unlinking vagrant from managed server myserver1.mydomain.com
|
23
|
+
==> managed-myserver1.mydomain.com: -- Server: myserver1.mydomain.com
|
24
|
+
==> managed-myserver2.mydomain.com: Linking vagrant with managed server myserver2.mydomain.com
|
25
|
+
==> managed-myserver2.mydomain.com: -- Server: myserver2.mydomain.com
|
26
|
+
==> managed-myserver2.mydomain.com: Rsyncing folder: ~/dev/demo => /vagrant
|
27
|
+
==> managed-myserver2.mydomain.com: Running provisioner: shell...
|
28
|
+
==> managed-myserver2.mydomain.com: Running: inline script
|
29
|
+
==> managed-myserver2.mydomain.com: Hello
|
30
|
+
==> managed-myserver2.mydomain.com: Unlinking vagrant from managed server myserver2.mydomain.com
|
31
|
+
==> managed-myserver2.mydomain.com: -- Server: myserver2.mydomain.com
|
32
|
+
```
|
33
|
+
|
34
|
+
This also works for Windows with the `--winrm --winrm-username --wirnm-password` parameters, but currently must be initiated from a Windows host.
|
8
35
|
|
9
36
|
## Usage
|
10
37
|
|
@@ -17,21 +44,99 @@ Initialize a Vagrantfile to orchestrate running a script on multiple managed ser
|
|
17
44
|
|
18
45
|
$ vagrant orchestrate init --shell
|
19
46
|
|
47
|
+
Which produces a simple default Vagrantfile that can push to managed servers:
|
48
|
+
```ruby
|
49
|
+
managed_servers = %w( )
|
50
|
+
|
51
|
+
required_plugins = %w( vagrant-managed-servers )
|
52
|
+
required_plugins.each do |plugin|
|
53
|
+
system "vagrant plugin install #{plugin}" unless Vagrant.has_plugin? plugin
|
54
|
+
end
|
55
|
+
Vagrant.configure("2") do |config|
|
56
|
+
config.vm.provision "shell", path: "{{YOUR_SCRIPT_PATH}}"
|
57
|
+
config.ssh.username = "{{YOUR_SSH_USERNAME}}"
|
58
|
+
config.ssh.private_key_path = "{{YOUR_SSH_PRIVATE_KEY_PATH}}"
|
59
|
+
|
60
|
+
managed_servers.each do |instance|
|
61
|
+
config.vm.define "managed-#{instance}" do |box|
|
62
|
+
box.vm.box = "tknerr/managed-server-dummy"
|
63
|
+
box.vm.box_url = "./dummy.box"
|
64
|
+
box.vm.provider :managed do |provider|
|
65
|
+
provider.server = instance
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
20
72
|
You'll need to edit your Vagrantfile and replace some variables, such as ssh username and
|
21
|
-
|
73
|
+
private key, and the path to the script to run. Alternatively, you can pass them on the command
|
74
|
+
line with `--ssh-username` and `--ssh-private-key-path`. The first line of the file defines an array of
|
22
75
|
managed servers that the `push` command will operate on.
|
23
76
|
|
24
|
-
|
77
|
+
```ruby
|
78
|
+
managed_servers = %w( myserver1.mydomain.com myserver2.mydomain.com )
|
79
|
+
```
|
80
|
+
|
81
|
+
This works for Windows managed servers using WinRM as well
|
25
82
|
|
26
83
|
$ vagrant orchestrate init --winrm [--winrm-username USERNAME --winrm-password PASSWORD]
|
27
84
|
|
85
|
+
```ruby
|
86
|
+
required_plugins = %w( vagrant-managed-servers vagrant-winrm-s )
|
87
|
+
|
88
|
+
...
|
89
|
+
|
90
|
+
config.vm.communicator = "winrm"
|
91
|
+
config.winrm.username = "{{YOUR_WINRM_USERNAME}}"
|
92
|
+
config.winrm.password = "{{YOUR_WINRM_PASSWORD}}"
|
93
|
+
config.winrm.transport = :sspinegotiate
|
94
|
+
```
|
95
|
+
|
96
|
+
This also supports a self-contained way to install plugins, just list them in the required_plugins section
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
required_plugins = %w( vagrant-managed-servers vagrant-hostsupdater )
|
100
|
+
```
|
101
|
+
|
102
|
+
Experimental puppet templating support is available as well with the `--puppet` flag and associated options
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
required_plugins = %w( vagrant-managed-servers vagrant-librarian-puppet )
|
106
|
+
|
107
|
+
...
|
108
|
+
|
109
|
+
config.librarian_puppet.placeholder_filename = ".gitignore"
|
110
|
+
config.vm.provision "puppet" do |puppet|
|
111
|
+
puppet.module_path = 'modules'
|
112
|
+
puppet.hiera_config_path = 'hiera.yaml'
|
113
|
+
end
|
114
|
+
```
|
115
|
+
|
116
|
+
The following files and folders will be placed in the current directory
|
117
|
+
|
118
|
+
```
|
119
|
+
Puppetfile
|
120
|
+
Vagrantfile
|
121
|
+
dummy.box
|
122
|
+
hiera/
|
123
|
+
common.yaml
|
124
|
+
hiera.yaml
|
125
|
+
manifests/
|
126
|
+
default.pp
|
127
|
+
modules/
|
128
|
+
.gitignore
|
129
|
+
```
|
130
|
+
|
28
131
|
For a full list of init options, run `vagrant orchestrate init --help`
|
29
132
|
|
30
133
|
### Pushing changes
|
31
|
-
Go ahead and push changes to your managed servers
|
134
|
+
Go ahead and push changes to your managed servers, one at a time. Support for parallel deployments is planned.
|
32
135
|
|
33
136
|
$ vagrant orchestrate push
|
34
137
|
|
138
|
+
The push command is currently limited by convention to vagrant machines that start with the "managed-" prefix. So if you have other, local machines defined in the Vagrantfile, `vagrant orchestrate push` will not operate on those, but be cautioned that `vagrant up`, `provision` and `destroy` will by default.
|
139
|
+
|
35
140
|
You can run vagrant with increased verbosity if you run into problems
|
36
141
|
|
37
142
|
$ vagrant orchestrate push --debug
|
@@ -60,12 +165,6 @@ merge that feature into downstream environments to avoid conflicts.
|
|
60
165
|
|
61
166
|
You'll want Ruby v2.0.0* and bundler for developing changes.
|
62
167
|
|
63
|
-
You can install bundler by running
|
64
|
-
|
65
|
-
$ gem install bundler
|
66
|
-
|
67
|
-
Bundler documentation is available here (http://bundler.io/).
|
68
|
-
|
69
168
|
During the course of development you'll want to run the code you're working on,
|
70
169
|
not the version of Vagrant Orchestrate you've installed. In order to accomplish
|
71
170
|
this, run your vagrant orchestrate commands in the bundler environment.
|
data/Rakefile
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Orchestrate
|
3
|
+
module Action
|
4
|
+
class FilterManaged
|
5
|
+
def initialize(app, _env)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
# rubocop:disable Metrics/AbcSize
|
10
|
+
def call(env)
|
11
|
+
machine = env[:machine]
|
12
|
+
if machine.provider_name == :managed
|
13
|
+
if (machine.config.orchestrate.filter_managed_commands) && (ENV["VAGRANT_ORCHESTRATE_COMMAND"] != "PUSH")
|
14
|
+
env[:ui].info("Ignoring action #{env[:machine_action]} for managed server #{machine.name}.")
|
15
|
+
env[:ui].info("Set `config.orchestrate.filter_managed_commands = false` in your vagrantfile to disable.")
|
16
|
+
else
|
17
|
+
@app.call(env)
|
18
|
+
end
|
19
|
+
else
|
20
|
+
@app.call(env)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
# rubocop:enable Metrics/AbcSize
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -22,16 +22,24 @@ module VagrantPlugins
|
|
22
22
|
# Parse the options
|
23
23
|
argv = parse_options(opts)
|
24
24
|
|
25
|
-
with_target_vms(argv
|
26
|
-
unless machine.
|
27
|
-
@
|
25
|
+
with_target_vms(argv) do |machine|
|
26
|
+
unless machine.provider_name.to_sym == :managed
|
27
|
+
@env.ui.info("Skipping machine #{machine.name}")
|
28
28
|
next
|
29
29
|
end
|
30
|
+
push(options)
|
31
|
+
end
|
32
|
+
end
|
30
33
|
|
34
|
+
def push(options)
|
35
|
+
ENV["VAGRANT_ORCHESTRATE_COMMAND"] = "PUSH"
|
36
|
+
begin
|
31
37
|
machine.action(:up, options)
|
32
38
|
machine.action(:provision, options)
|
33
39
|
machine.action(:reload, options) if options[:reboot]
|
34
40
|
machine.action(:destroy, options)
|
41
|
+
ensure
|
42
|
+
ENV.delete "VAGRANT_ORCHESTRATE_COMMAND"
|
35
43
|
end
|
36
44
|
end
|
37
45
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Orchestrate
|
5
|
+
class Config < Vagrant.plugin(2, :config)
|
6
|
+
attr_accessor :filter_managed_commands
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@filter_managed_commands = UNSET_VALUE
|
10
|
+
end
|
11
|
+
|
12
|
+
def finalize!
|
13
|
+
@filter_managed_commands = false if @filter_managed_commands == UNSET_VALUE
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "vagrant-orchestrate/action/filtermanaged"
|
2
|
+
|
1
3
|
begin
|
2
4
|
require "vagrant"
|
3
5
|
rescue LoadError
|
@@ -18,6 +20,11 @@ module VagrantPlugins
|
|
18
20
|
This plugin installs commands that make pushing changes to vagrant-managed-servers easy.
|
19
21
|
DESC
|
20
22
|
|
23
|
+
config "orchestrate" do
|
24
|
+
require_relative "config"
|
25
|
+
Config
|
26
|
+
end
|
27
|
+
|
21
28
|
command(:orchestrate) do
|
22
29
|
setup_i18n
|
23
30
|
setup_logging
|
@@ -26,6 +33,22 @@ module VagrantPlugins
|
|
26
33
|
Command::Root
|
27
34
|
end
|
28
35
|
|
36
|
+
action_hook(:orchestrate, :machine_action_up) do |hook|
|
37
|
+
hook.prepend Action::FilterManaged
|
38
|
+
end
|
39
|
+
|
40
|
+
action_hook(:orchestrate, :machine_action_provision) do |hook|
|
41
|
+
hook.prepend Action::FilterManaged
|
42
|
+
end
|
43
|
+
|
44
|
+
action_hook(:orchestrate, :machine_action_destroy) do |hook|
|
45
|
+
hook.prepend Action::FilterManaged
|
46
|
+
end
|
47
|
+
|
48
|
+
action_hook(:orchestrate, :machine_action_reload) do |hook|
|
49
|
+
hook.prepend Action::FilterManaged
|
50
|
+
end
|
51
|
+
|
29
52
|
# This initializes the internationalization strings.
|
30
53
|
def self.setup_i18n
|
31
54
|
I18n.load_path << File.expand_path("locales/en.yml", Orchestrate.source_root)
|
@@ -166,7 +166,7 @@ describe VagrantPlugins::Orchestrate::Command::Init do
|
|
166
166
|
it "includes the vagrant-winrm-s plugin"do
|
167
167
|
subject.execute
|
168
168
|
vagrantfile = File.readlines(File.join(iso_env.cwd, "Vagrantfile")).join
|
169
|
-
expect(vagrantfile).to include("vagrant-winrm-s")
|
169
|
+
expect(vagrantfile).to include("vagrant-winrm-s")
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
@@ -272,4 +272,13 @@ describe VagrantPlugins::Orchestrate::Command::Init do
|
|
272
272
|
end
|
273
273
|
end
|
274
274
|
end
|
275
|
+
|
276
|
+
context "orchestrate config" do
|
277
|
+
describe "filter_managed_servers" do
|
278
|
+
it "is set to true" do
|
279
|
+
subject.execute
|
280
|
+
expect(iso_env.vagrantfile.config.orchestrate.filter_managed_commands).to be true
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
275
284
|
end
|
@@ -7,6 +7,10 @@ required_plugins.each do |plugin|
|
|
7
7
|
end
|
8
8
|
<% end %>
|
9
9
|
Vagrant.configure("2") do |config|
|
10
|
+
# This disables up, provision, reload, and destroy for managed servers. Use
|
11
|
+
# `vagrant orchestrate push` to communicate with managed servers.
|
12
|
+
config.orchestrate.filter_managed_commands = true
|
13
|
+
|
10
14
|
<% if provisioners.include? "shell" -%>
|
11
15
|
<% shell_paths.each do |path| -%>
|
12
16
|
config.vm.provision "shell", path: "<%= path %>"
|
@@ -44,9 +48,13 @@ Vagrant.configure("2") do |config|
|
|
44
48
|
config.winrm.transport = :sspinegotiate
|
45
49
|
<% end -%>
|
46
50
|
|
51
|
+
config.vm.define "local", primary: true do |local|
|
52
|
+
local.vm.box = "ubuntu/trusty64"
|
53
|
+
end
|
54
|
+
|
47
55
|
managed_servers.each do |instance|
|
48
|
-
config.vm.define
|
49
|
-
box.vm.box = "
|
56
|
+
config.vm.define instance, autostart: false do |box|
|
57
|
+
box.vm.box = "managed-server-dummy"
|
50
58
|
box.vm.box_url = "./dummy.box"
|
51
59
|
box.vm.provider :managed do |provider|
|
52
60
|
provider.server = instance
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Baldauf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,9 +82,11 @@ files:
|
|
82
82
|
- Rakefile
|
83
83
|
- dummy.box
|
84
84
|
- lib/vagrant-orchestrate.rb
|
85
|
+
- lib/vagrant-orchestrate/action/filtermanaged.rb
|
85
86
|
- lib/vagrant-orchestrate/command/init.rb
|
86
87
|
- lib/vagrant-orchestrate/command/push.rb
|
87
88
|
- lib/vagrant-orchestrate/command/root.rb
|
89
|
+
- lib/vagrant-orchestrate/config.rb
|
88
90
|
- lib/vagrant-orchestrate/plugin.rb
|
89
91
|
- lib/vagrant-orchestrate/version.rb
|
90
92
|
- locales/en.yml
|