vagrant-converge 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +9 -0
- data/README.md +5 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/vagrant-converge.rb +7 -0
- data/lib/vagrant-converge/cap/guest/linux/converge_install.rb +20 -0
- data/lib/vagrant-converge/cap/guest/linux/converge_installed.rb +19 -0
- data/lib/vagrant-converge/config/guest.rb +44 -0
- data/lib/vagrant-converge/errors.rb +19 -0
- data/lib/vagrant-converge/plugin.rb +31 -0
- data/lib/vagrant-converge/provisioner/guest.rb +80 -0
- data/lib/vagrant-converge/version.rb +3 -0
- data/templates/locales/en.yml +16 -0
- data/templates/locales/en.yml.bak +19 -0
- data/vagrant-converge.gemspec +31 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a1b5109f969da70a8e02fd9ac1a4c9764fd85bf5
|
4
|
+
data.tar.gz: b6b081f6f7e461df90fe4acc829f1e55d9ed271c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0a81fa080e1fea2a6d8c695445cf9dfa1647ad0d329e294cbb12a2679a2db4e680c0222a95de3c54a31a7f6b190453201a9dea97d552536f25dbca1f8242d93f
|
7
|
+
data.tar.gz: ac02e2e7a627c2835dd3b1c4f0f590057a63806aee8432de350c8f685a292381e55bd990a2fce65de2904b9ba6eda37020a421ca49952838b808c364abd24880
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "vagrant/converge"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative "../../../errors"
|
2
|
+
|
3
|
+
module VagrantConverge
|
4
|
+
module Cap
|
5
|
+
module Guest
|
6
|
+
module Linux
|
7
|
+
module ConvergeInstall
|
8
|
+
def self.converge_install(machine, install_mode, version)
|
9
|
+
if install_mode == :pip
|
10
|
+
raise Converge::Errors::ConvergePipInstallIsNotSupported
|
11
|
+
else
|
12
|
+
machine.communicate.sudo "curl -L -o /usr/bin/converge https://bintray.com/chrisaubuchon/generic/download_file?file_path=converge"
|
13
|
+
machine.communicate.sudo "chmod 0755 /usr/bin/converge"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module VagrantConverge
|
2
|
+
module Cap
|
3
|
+
module Guest
|
4
|
+
module Linux
|
5
|
+
module ConvergeInstalled
|
6
|
+
def self.converge_installed(machine, version)
|
7
|
+
command = 'text -x "$(command -v converge)"'
|
8
|
+
|
9
|
+
if !version.empty?
|
10
|
+
command << "&& converge version | grep 'converge #{version}'"
|
11
|
+
end
|
12
|
+
|
13
|
+
machine.communicate.test command, sudo: false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module VagrantConverge
|
2
|
+
module Config
|
3
|
+
class Guest < Vagrant.plugin("2", :config)
|
4
|
+
|
5
|
+
attr_accessor :bikeshed
|
6
|
+
attr_accessor :params
|
7
|
+
attr_accessor :local
|
8
|
+
attr_accessor :install
|
9
|
+
attr_accessor :install_mode
|
10
|
+
attr_accessor :verbose
|
11
|
+
attr_accessor :version
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super
|
15
|
+
|
16
|
+
@bikeshed = UNSET_VALUE
|
17
|
+
@install = UNSET_VALUE
|
18
|
+
@install_mode = UNSET_VALUE
|
19
|
+
@local = UNSET_VALUE
|
20
|
+
@params = UNSET_VALUE
|
21
|
+
@verbose = UNSET_VALUE
|
22
|
+
@version = UNSET_VALUE
|
23
|
+
end
|
24
|
+
|
25
|
+
def finalize!
|
26
|
+
@bikeshed = nil if @bikeshed == UNSET_VALUE
|
27
|
+
@install = true if @install == UNSET_VALUE
|
28
|
+
@install_mode = :default if @install_mode == UNSET_VALUE
|
29
|
+
@local = true if @local == UNSET_VALUE
|
30
|
+
@params = nil if @params == UNSET_VALUE
|
31
|
+
@verbose = false if @verbose == UNSET_VALUE
|
32
|
+
@version = "" if @version == UNSET_VALUE
|
33
|
+
end
|
34
|
+
|
35
|
+
def validate(machine)
|
36
|
+
@errors = _detected_errors
|
37
|
+
|
38
|
+
if !bikeshed
|
39
|
+
@errors << I18n.t("vagrant.provisioners.converge.no_bikeshed")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module VagrantConverge
|
2
|
+
module Errors
|
3
|
+
class ConvergeError < Vagrant::Errors::VagrantError
|
4
|
+
error_namespace("vagrant.provisioners.converge.errors")
|
5
|
+
end
|
6
|
+
|
7
|
+
class ConvergePipInstallIsNotSupported < ConvergeError
|
8
|
+
error_key(:cannot_support_pip_install)
|
9
|
+
end
|
10
|
+
|
11
|
+
class ConvergeNotFoundOnGuest < ConvergeError
|
12
|
+
error_key(:converge_not_found_on_guest)
|
13
|
+
end
|
14
|
+
|
15
|
+
class ConvergeCommandFailed < ConvergeError
|
16
|
+
error_key(:converge_command_failed)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantConverge
|
4
|
+
class Plugin < Vagrant.plugin("2")
|
5
|
+
name 'converge'
|
6
|
+
|
7
|
+
description <<-DESC
|
8
|
+
Provides support for provisioning your virtual machines with Converge.
|
9
|
+
DESC
|
10
|
+
|
11
|
+
config(:converge, :provisioner) do
|
12
|
+
require_relative "config/guest"
|
13
|
+
Config::Guest
|
14
|
+
end
|
15
|
+
|
16
|
+
provisioner(:converge) do
|
17
|
+
require_relative "provisioner/guest"
|
18
|
+
Provisioner::Guest
|
19
|
+
end
|
20
|
+
|
21
|
+
guest_capability(:linux, :converge_installed) do
|
22
|
+
require_relative "cap/guest/linux/converge_installed"
|
23
|
+
Cap::Guest::Linux::ConvergeInstalled
|
24
|
+
end
|
25
|
+
|
26
|
+
guest_capability(:linux, :converge_install) do
|
27
|
+
require_relative "cap/guest/linux/converge_install"
|
28
|
+
Cap::Guest::Linux::ConvergeInstall
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module VagrantConverge
|
2
|
+
module Provisioner
|
3
|
+
class Guest < Vagrant.plugin("2", :provisioner)
|
4
|
+
|
5
|
+
def initialize(machine, config)
|
6
|
+
super
|
7
|
+
|
8
|
+
@logger = Log4r::Logger.new("vagrant::provisioners::converge")
|
9
|
+
end
|
10
|
+
|
11
|
+
def provision
|
12
|
+
install_converge
|
13
|
+
execute_converge_command prepare_command
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def install_converge
|
19
|
+
return if !config.install
|
20
|
+
|
21
|
+
@logger.info("Checking for Converge installation...")
|
22
|
+
if !@machine.guest.capability?(:converge_installed)
|
23
|
+
@machine.ui.warn(I18n.t("vagrant.provisioners.converge.cannot_detect"))
|
24
|
+
return
|
25
|
+
end
|
26
|
+
|
27
|
+
if config.install && !machine.guest.capability(:converge_installed, config.version)
|
28
|
+
@machine.guest.capability(:converge_install, config.install_mode, config.version)
|
29
|
+
end
|
30
|
+
|
31
|
+
@machine.communicate.execute(
|
32
|
+
"converge version",
|
33
|
+
error_class: VagrantConverge::Errors::ConvergeNotFoundOnGuest,
|
34
|
+
error_key: :converge_not_found_on_guest
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute_converge_command(command)
|
39
|
+
ui_running_converge_command command
|
40
|
+
|
41
|
+
result = execute_on_guest(command)
|
42
|
+
raise VagrantConverge::Errors::ConvergeCommandFailed if result != 0
|
43
|
+
end
|
44
|
+
|
45
|
+
def execute_on_guest(command)
|
46
|
+
@machine.communicate.execute(command, error_check: false) do |type, data|
|
47
|
+
if [:stderr, :stdout].include?(type)
|
48
|
+
@machine.env.ui.info(data, new_line: false, prefix: false)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def ui_running_converge_command(command)
|
54
|
+
@machine.ui.detail I18n.t("vagrant.provisioners.converge.running")
|
55
|
+
if verbosity_is_enabled?
|
56
|
+
@machine.env.ui.detail command
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def verbosity_is_enabled?
|
61
|
+
config.verbose && !config.verbose.to_s.empty?
|
62
|
+
end
|
63
|
+
|
64
|
+
def prepare_command
|
65
|
+
shell_command = []
|
66
|
+
shell_command << "converge"
|
67
|
+
shell_command << "apply"
|
68
|
+
|
69
|
+
shell_command << "--local" if config.local
|
70
|
+
shell_command << "--paramsJSON='" + config.params.to_json + "'" if config.params
|
71
|
+
|
72
|
+
config.bikeshed.each do |arg|
|
73
|
+
shell_command << arg
|
74
|
+
end
|
75
|
+
|
76
|
+
shell_command.flatten.join(' ')
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
|
3
|
+
en:
|
4
|
+
vagrant:
|
5
|
+
provisioners:
|
6
|
+
converge:
|
7
|
+
cannot_detect: |-
|
8
|
+
Vagrant does not support detecting whether Converge is installed
|
9
|
+
for the guest OS running in the machine. Vagrant will assume it is
|
10
|
+
installed and attempt to continue.
|
11
|
+
errors:
|
12
|
+
converge_not_found_on_guest: |-
|
13
|
+
Converge not found on guest
|
14
|
+
converge_command_failed: |-
|
15
|
+
Converge execution failed
|
16
|
+
running: Running converge...
|
@@ -0,0 +1,19 @@
|
|
1
|
+
---
|
2
|
+
|
3
|
+
en:
|
4
|
+
converge:
|
5
|
+
provisioners:
|
6
|
+
converge:
|
7
|
+
errors:
|
8
|
+
converge_not_found_on_guest: |-
|
9
|
+
Converge not found on guest
|
10
|
+
vagrant:
|
11
|
+
provisioners:
|
12
|
+
converge:
|
13
|
+
cannot_detect: |-
|
14
|
+
Vagrant does not support detecting whether Converge is installed
|
15
|
+
for the guest OS running in the machine. Vagrant will assume it is
|
16
|
+
installed and attempt to continue.
|
17
|
+
errors:
|
18
|
+
converge_not_found_on_guest: |-
|
19
|
+
Converge not found on guest
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vagrant-converge/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vagrant-converge"
|
8
|
+
spec.version = VagrantConverge::VERSION
|
9
|
+
spec.authors = ["Chris Aubuchon"]
|
10
|
+
spec.email = ["Chris.Aubuchon@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Vagrant plugin for converge.}
|
13
|
+
spec.description = %q{}
|
14
|
+
spec.homepage = ""
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
#if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata['allowed_push_host'] = "http'"
|
20
|
+
#else
|
21
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
#end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-converge
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Aubuchon
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: ''
|
42
|
+
email:
|
43
|
+
- Chris.Aubuchon@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- bin/console
|
53
|
+
- bin/setup
|
54
|
+
- lib/vagrant-converge.rb
|
55
|
+
- lib/vagrant-converge/cap/guest/linux/converge_install.rb
|
56
|
+
- lib/vagrant-converge/cap/guest/linux/converge_installed.rb
|
57
|
+
- lib/vagrant-converge/config/guest.rb
|
58
|
+
- lib/vagrant-converge/errors.rb
|
59
|
+
- lib/vagrant-converge/plugin.rb
|
60
|
+
- lib/vagrant-converge/provisioner/guest.rb
|
61
|
+
- lib/vagrant-converge/version.rb
|
62
|
+
- templates/locales/en.yml
|
63
|
+
- templates/locales/en.yml.bak
|
64
|
+
- vagrant-converge.gemspec
|
65
|
+
homepage: ''
|
66
|
+
licenses: []
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.5.1
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Vagrant plugin for converge.
|
88
|
+
test_files: []
|
89
|
+
has_rdoc:
|