vagrant-carpet 0.3.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e730b0a5aa95df902051d0af085d8ca24cda4caa
4
+ data.tar.gz: 54cfea497b50e9b480025f18718d0902c141eb67
5
+ SHA512:
6
+ metadata.gz: c30ec92d45b01da51cbc15d88e4ae5234f8d82ffab3589a6ede190c289fee1ab7027b83dbd5e4338f0951ce017720e89ad2d0d3f3eef2dc5197d01b5a0df6d26
7
+ data.tar.gz: f0da6e9dc11117cae389488aa469dd2a9e7803fa0830bf0771dd976466dda1380308f1f77937de1812d2b76e7c15eafaa514f17911502acc8e6a584b02a45362
@@ -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
@@ -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.
@@ -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
@@ -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 @@
1
+ require 'vagrant-fabric'
@@ -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,79 @@
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
+ attr_accessor :remote
9
+ attr_accessor :remote_install
10
+ attr_accessor :remote_password
11
+ attr_accessor :remote_current_dir
12
+
13
+ def initialize
14
+ @fabfile_path = UNSET_VALUE
15
+ @fabric_path = UNSET_VALUE
16
+ @python_path = UNSET_VALUE
17
+ @tasks = UNSET_VALUE
18
+ @remote = UNSET_VALUE
19
+ @remote_install = UNSET_VALUE
20
+ @remote_password = UNSET_VALUE
21
+ @remote_current_dir = UNSET_VALUE
22
+ end
23
+
24
+ def finalize!
25
+ @fabfile_path = "fabfile.py" if @fabfile_path == UNSET_VALUE
26
+ @fabric_path = "fab" if @fabric_path == UNSET_VALUE
27
+ @python_path = "python" if @python_path == UNSET_VALUE
28
+ @tasks = [] if @tasks == UNSET_VALUE
29
+ @remote = false if @remote == UNSET_VALUE
30
+ @remote_install = false if @remote_install == UNSET_VALUE
31
+ @remote_password = "vagrant" if @remote_password == UNSET_VALUE
32
+ @remote_current_dir = "." if @remote_current_dir == UNSET_VALUE
33
+ end
34
+
35
+ def execute(command)
36
+ output = ''
37
+ begin
38
+ IO.popen(command, "w+") do |f|
39
+ f.close_write
40
+ output = f.read
41
+ end
42
+ output
43
+ rescue Errno::ENOENT
44
+ false
45
+ end
46
+ end
47
+
48
+ def validate(env)
49
+ if not @remote == true
50
+ errors = _detected_errors
51
+
52
+ errors << "fabfile does not exist." if not File.exist?(fabfile_path)
53
+
54
+ install_fabric if @remote == true and @install == true
55
+
56
+ command = "#{fabric_path} -V"
57
+ output = execute(command)
58
+ errors << "fabric command does not exist." if not output
59
+
60
+ command = "#{fabric_path} -f #{fabfile_path} -l"
61
+ output = execute(command)
62
+ errors << "#{fabfile_path} could not recognize by fabric." if not $?.success?
63
+
64
+ for task in tasks
65
+ task = task.split(':').first
66
+ command = "#{fabric_path} -f #{fabfile_path} -d #{task}"
67
+ output = execute(command)
68
+ errors << "#{task} task does not exist." if not $?.success?
69
+ end
70
+
71
+ {"fabric provisioner" => errors}
72
+ end
73
+ end
74
+
75
+ def install_fabric()
76
+ end
77
+ end
78
+ end
79
+ 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,36 @@
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
+
11
+ # After https://github.com/mitchellh/vagrant/pull/907 (Vagrant 1.4.0+),
12
+ # private_key_path is an array.
13
+ if ! private_key.kind_of?(Array)
14
+ private_key = [private_key]
15
+ end
16
+ private_key_option = private_key.map { |k| '-i ' + k }.join(' ')
17
+
18
+ if config.remote == false
19
+ system "#{config.fabric_path} -f #{config.fabfile_path} " +
20
+ "#{private_key_option} --user=#{user} --hosts=#{host} " +
21
+ "--port=#{port} #{config.tasks.join(' ')}"
22
+ else
23
+ if config.install
24
+ @machine.communicate.sudo("pip install fabric")
25
+ @machine.env.ui.info "Finished to install fabric library your VM."
26
+ end
27
+ @machine.communicate.execute("cd #{config.remote_current_dir} && " +
28
+ "#{config.fabric_path} -f #{config.fabfile_path} " +
29
+ "--user=#{user} --hosts=127.0.0.1 --password=#{config.remote_password} " +
30
+ "#{config.tasks.join(' ')}")
31
+ @machine.env.ui.info "Finished to execute tasks of fabric."
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module Fabric
3
+ VERSION = "0.3.0"
4
+ end
5
+ 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-carpet"
8
+ spec.version = VagrantPlugins::Fabric::VERSION
9
+ spec.platform = Gem::Platform::RUBY
10
+ spec.authors = ["Takahiro Fujiwara"]
11
+ spec.email = ["email@wuta.li"]
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,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-carpet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Takahiro Fujiwara
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-11 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
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
+ description: Enables Vagrant to provision with python fabric script.
42
+ email:
43
+ - email@wuta.li
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - example/Vagrantfile
54
+ - example/fabfile.py
55
+ - lib/vagrant-carpet.rb
56
+ - lib/vagrant-fabric.rb
57
+ - lib/vagrant-fabric/config.rb
58
+ - lib/vagrant-fabric/plugin.rb
59
+ - lib/vagrant-fabric/provisioner.rb
60
+ - lib/vagrant-fabric/version.rb
61
+ - vagrant-carpet.gemspec
62
+ homepage: http://blog.wuta.li
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.0.3
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Enables Vagrant to provision with python fabric script.
86
+ test_files: []