vagrant-fabric 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
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
+ *.pyc
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vagrant-my-plugin.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 => "git://github.com/mitchellh/vagrant.git"
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Takahiro Fujiwara
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,22 @@
1
+ # Vagrant Fabric Provisioner
2
+
3
+ This is a [Vagrant](http://www.vagrantup.com) plugin that adds an [Fabric](http://docs.fabfile.org/en/latest/)
4
+ provisioner to Vagrant, supporting to provision your virtual machines with fabric scripts.
5
+
6
+ ## Installation
7
+
8
+ Just type it on your vagrant environment::
9
+
10
+ vagrant plugin install vagrant-fabric
11
+
12
+ ## Usage
13
+
14
+ TODO: Write usage instructions here
15
+
16
+ ## Contributing
17
+
18
+ 1. Fork it
19
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
20
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
21
+ 4. Push to the branch (`git push origin my-new-feature`)
22
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # For development, it is not needed when run on the production environment.
5
+ #Vagrant.require_plugin "vagrant-fabric"
6
+
7
+ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
8
+ VAGRANTFILE_API_VERSION = "2"
9
+
10
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
11
+ config.vm.box = "precise64"
12
+
13
+ # Enable provisioning with fabric script, specifiying jobs you want execute,
14
+ # and the path of fabfile.
15
+ config.vm.provision :fabric do |fabric|
16
+ fabric.fabfile_path = "./fabfile.py"
17
+ fabric.tasks = ["host_type", ]
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ from fabric.api import run
2
+
3
+ def host_type():
4
+ run('uname -s')
@@ -0,0 +1,60 @@
1
+ module VagrantPlugins
2
+ module Fabric
3
+ class Config < Vagrant.plugin("2", :config)
4
+ attr_accessor :fabfile_path
5
+ attr_accessor :fabric_path
6
+ attr_accessor :python_path
7
+ attr_accessor :tasks
8
+
9
+ def initialize
10
+ @fabfile_path = UNSET_VALUE
11
+ @fabric_path = UNSET_VALUE
12
+ @python_path = UNSET_VALUE
13
+ @tasks = UNSET_VALUE
14
+ end
15
+
16
+ def finalize!
17
+ @fabfile_path = "fabfile.py" if @fabfile_path == UNSET_VALUE
18
+ @fabric_path = "fab" if @fabric_path == UNSET_VALUE
19
+ @python_path = "python" if @python_path == UNSET_VALUE
20
+ @tasks = [] if @tasks == UNSET_VALUE
21
+ end
22
+
23
+ def execute(command)
24
+ output = ''
25
+ begin
26
+ IO.popen(command, "w+") do |f|
27
+ f.close_write
28
+ output = f.read
29
+ end
30
+ output
31
+ rescue Errno::ENOENT
32
+ false
33
+ end
34
+ end
35
+
36
+ def validate(env)
37
+ errors = _detected_errors
38
+
39
+ errors << "fabfile does not exist." if not File.exist?(fabfile_path)
40
+
41
+ command = "#{fabric_path} -V"
42
+ output = execute(command)
43
+ errors << "fabric command does not exist." if not output
44
+
45
+ command = "#{fabric_path} -f #{fabfile_path} -l"
46
+ output = execute(command)
47
+ errors << "#{fabfile_path} could not recognize by fabric." if not $?.success?
48
+
49
+ for task in tasks
50
+ task = task.split(':').first
51
+ command = "#{fabric_path} -f #{fabfile_path} -d #{task}"
52
+ output = execute(command)
53
+ errors << "#{task} task does not exist." if not $?.success?
54
+ end
55
+
56
+ { "fabric provisioner" => errors }
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,23 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module Fabric
5
+ class Plugin < Vagrant.plugin("2")
6
+ name "fabric"
7
+ description <<-DESC
8
+ Provides support for porvisioning your virtual machines with
9
+ python fabric scripts.
10
+ DESC
11
+
12
+ config(:fabric, :provisioner) do
13
+ require File.expand_path("../config", __FILE__)
14
+ Config
15
+ end
16
+
17
+ provisioner(:fabric) do
18
+ require File.expand_path("../provisioner", __FILE__)
19
+ Provisioner
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ module VagrantPlugins
2
+ module Fabric
3
+ class Provisioner < Vagrant.plugin("2", :provisioner)
4
+ def provision
5
+ ssh_info = machine.ssh_info
6
+ user = ssh_info[:username]
7
+ host = ssh_info[:host]
8
+ port = ssh_info[:port]
9
+ private_key = ssh_info[:private_key_path]
10
+ system "#{config.fabric_path} -f #{config.fabfile_path} -i #{private_key} --user=#{user} --hosts=#{host} --port=#{port} #{config.tasks.join(' ')}"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module Fabric
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require "pathname"
2
+
3
+ require "vagrant-fabric/plugin"
4
+
5
+ module VagrantPlugins
6
+ module Fabric
7
+ lib_path = Pathname.new(File.expand_path("../vagrant-fabric", __FILE__))
8
+
9
+ # This returns the path to the source of this plugin.
10
+ #
11
+ # @return [Pathname]
12
+ def self.source_root
13
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-fabric/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-fabric"
8
+ spec.version = VagrantPlugins::Fabric::VERSION
9
+ spec.platform = Gem::Platform::RUBY
10
+ spec.authors = ["Takahiro Fujiwara"]
11
+ spec.email = ["wutali.no@gmail.com"]
12
+ spec.homepage = "http://blog.wuta.li"
13
+ spec.description = "Enables Vagrant to provision with python fabric script."
14
+ spec.summary = "Enables Vagrant to provision with python fabric script."
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-fabric
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Takahiro Fujiwara
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Enables Vagrant to provision with python fabric script.
47
+ email:
48
+ - wutali.no@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - example/Vagrantfile
59
+ - example/fabfile.py
60
+ - lib/vagrant-fabric.rb
61
+ - lib/vagrant-fabric/config.rb
62
+ - lib/vagrant-fabric/plugin.rb
63
+ - lib/vagrant-fabric/provisioner.rb
64
+ - lib/vagrant-fabric/version.rb
65
+ - vagrant-fabric.gemspec
66
+ homepage: http://blog.wuta.li
67
+ licenses:
68
+ - MIT
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 1.8.23
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Enables Vagrant to provision with python fabric script.
91
+ test_files: []