vagrant-syllabus-provisioner 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 92441c2ce3ba699c450443a9f2df1c76a744f560
4
+ data.tar.gz: f446c20430ab4356bd74fe1e84260b2a8f2345ac
5
+ SHA512:
6
+ metadata.gz: eb78c50c83b43b160f555d45f1d96e55f6136d1a2b9e6dd9ab7c66d9b283db9c4ea8a73902249906ddba028531946c086a4a4f561b3c468b45e4f25eba3f18e8
7
+ data.tar.gz: 5796da24adea8efe973fac2b2dbcf283f098ab14fdc70a5a84f1c9d790e629efe409b9664125d9deca699e426861cf122fcf62bd255842fe5748502010caeccb
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ Vagrantfile
19
+ .vagrant
20
+ syllabus.rb
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vagrant-syllabus-provisioner.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ # We depend on Vagrant for development, but we don't add it as a
8
+ # gem dependency because we expect to be installed within the
9
+ # Vagrant environment itself using `vagrant plugin`.
10
+ gem "vagrant", :git => "https://github.com/mitchellh/vagrant.git", :tag => "v1.3.5"
11
+
12
+ # specinfra has not supported commands on debian yet.
13
+ gem "specinfra", :git => "https://github.com/ryotarai/specinfra.git", :branch => "debian-install-command"
14
+ end
15
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Ryota Arai
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # vagrant-syllabus-provisioner
2
+
3
+ This plugin installs a provisioner that allows [Syllabus](https://github.com/serverspec/syllabus) to provision machines.
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ $ vagrant plugin install vagrant-syllabus-provisioner
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ruby
14
+ VAGRANTFILE_API_VERSION = "2"
15
+
16
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
17
+ config.vm.box = "your_box"
18
+
19
+ config.vm.provision :syllabus do |syllabus|
20
+ # What files does syllabus use for provisioning?
21
+ # (default: ["syllabus.rb"])
22
+ syllabus.files = ["syllabus/default.rb"]
23
+ end
24
+ end
25
+ ```
26
+
27
+ ## TODO
28
+
29
+ * Add specs
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
38
+
39
+ ## Development
40
+
41
+ Create `Vagrantfile`:
42
+
43
+ ```
44
+ $ bundle exec vagrant init
45
+ ```
46
+
47
+ Require this plugin in `Vagrantfile`:
48
+
49
+ ```ruby
50
+ Vagrant.require_plugin "vagrant-syllabus-provisioner"
51
+ ```
52
+
53
+ Use vagrant:
54
+
55
+ ```
56
+ $ bundle exec vagrant up
57
+ $ bundle exec vagrant provision
58
+ ```
59
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ require 'vagrant_syllabus_provisioner/plugin'
2
+ require 'vagrant_syllabus_provisioner/provisioner'
3
+ require 'vagrant_syllabus_provisioner/config'
4
+ require 'vagrant_syllabus_provisioner/spec_infra_backend'
5
+
@@ -0,0 +1,16 @@
1
+ require 'vagrant-syllabus-provisioner'
2
+
3
+ module VagrantSyllabusProvisioner
4
+ class Config < Vagrant.plugin("2", :config)
5
+ attr_accessor :files
6
+
7
+ def initialize
8
+ @files = UNSET_VALUE
9
+ end
10
+
11
+ def finalize!
12
+ @files = nil if @files == UNSET_VALUE
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,21 @@
1
+ require 'vagrant-syllabus-provisioner'
2
+ require "vagrant"
3
+
4
+ module VagrantSyllabusProvisioner
5
+ class Plugin < Vagrant.plugin("2")
6
+ name "syllabus"
7
+ description <<-DESC
8
+ This plugin installs a provisioner that allows Syllabus to provision machines.
9
+ DESC
10
+
11
+ config :syllabus, :provisioner do
12
+ require_relative "config"
13
+ Config
14
+ end
15
+
16
+ provisioner :syllabus do
17
+ require_relative 'provisioner'
18
+ Provisioner
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,55 @@
1
+ require 'vagrant-syllabus-provisioner'
2
+ require 'syllabus'
3
+
4
+ module VagrantSyllabusProvisioner
5
+ class Provisioner < Vagrant.plugin("2", :provisioner)
6
+ class ExecutionError < Vagrant::Errors::VagrantError
7
+ def error_message
8
+ "Execution failed. Abort."
9
+ end
10
+ end
11
+
12
+ def finalize!
13
+ p config
14
+ end
15
+
16
+ def provision
17
+ with_backend do |backend|
18
+ files.each do |file|
19
+ config = Syllabus::Config.new_from_file(file: file, backend: backend)
20
+ config.commands.each do |command|
21
+ result = backend.run_command(command, with_output: true)
22
+ handle_result(command, result)
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ private
29
+ def handle_result(command, result)
30
+ if result[:exit_status] != 0
31
+ msg = "`#{command}` failed (exit status is #{result[:exit_status]})"
32
+ machine.ui.error msg, color: :red
33
+ raise ExecutionError
34
+ end
35
+ end
36
+
37
+ def files
38
+ fs = config.files || ["syllabus.rb"]
39
+ fs.map do |f|
40
+ File.expand_path(f, machine.env.root_path)
41
+ end
42
+ end
43
+
44
+ def with_backend
45
+ machine.communicate.tap do |comm|
46
+ backend = SpecInfraBackend.instance
47
+ backend.communicator = comm
48
+ backend.ui = machine.ui
49
+ backend.set_commands(SpecInfra::Command.const_get(backend.check_os[:family]).new)
50
+ yield backend
51
+ end
52
+ end
53
+ end
54
+ end
55
+
@@ -0,0 +1,32 @@
1
+ require 'vagrant-syllabus-provisioner'
2
+ require 'specinfra'
3
+
4
+ module VagrantSyllabusProvisioner
5
+ class SpecInfraBackend < SpecInfra::Backend::Ssh
6
+ attr_accessor :communicator
7
+ attr_accessor :ui
8
+
9
+ def run_command(cmd, opts={})
10
+ opts = {with_output: false}.merge(opts)
11
+
12
+ stdout = ""
13
+ stderr = ""
14
+
15
+ @ui.info cmd, color: :green if opts[:with_output]
16
+
17
+ exit_status = @communicator.sudo(cmd, error_check: false) do |type, data|
18
+ case type
19
+ when :stdout
20
+ stdout << data
21
+ when :stderr
22
+ stderr << data
23
+ end
24
+ @ui.info data.chomp if opts[:with_output]
25
+ end
26
+
27
+ { :stdout => stdout, :stderr => stderr,
28
+ :exit_status => exit_status, :exit_signal => nil }
29
+ end
30
+ end
31
+ end
32
+
@@ -0,0 +1,3 @@
1
+ module VagrantSyllabusProvisioner
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant_syllabus_provisioner/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-syllabus-provisioner"
8
+ spec.version = VagrantSyllabusProvisioner::VERSION
9
+ spec.authors = ["Ryota Arai"]
10
+ spec.email = ["ryota.arai@gmail.com"]
11
+ spec.summary = %q{Syllabus Provisioner for Vagrant}
12
+ spec.description = %q{This plugin installs a provisioner that allows Syllabus to provision machines.}
13
+ spec.homepage = "https://github.com/ryotarai/vagrant-syllabus-provisioner"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "syllabus"
22
+
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "rake"
25
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-syllabus-provisioner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ryota Arai
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: syllabus
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: This plugin installs a provisioner that allows Syllabus to provision
56
+ machines.
57
+ email:
58
+ - ryota.arai@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - lib/vagrant-syllabus-provisioner.rb
69
+ - lib/vagrant_syllabus_provisioner/config.rb
70
+ - lib/vagrant_syllabus_provisioner/plugin.rb
71
+ - lib/vagrant_syllabus_provisioner/provisioner.rb
72
+ - lib/vagrant_syllabus_provisioner/spec_infra_backend.rb
73
+ - lib/vagrant_syllabus_provisioner/version.rb
74
+ - vagrant-syllabus-provisioner.gemspec
75
+ homepage: https://github.com/ryotarai/vagrant-syllabus-provisioner
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.0.3
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Syllabus Provisioner for Vagrant
99
+ test_files: []