vagrant-fabric 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,12 +5,18 @@ module VagrantPlugins
5
5
  attr_accessor :fabric_path
6
6
  attr_accessor :python_path
7
7
  attr_accessor :tasks
8
+ attr_accessor :remote
9
+ attr_accessor :remote_install
10
+ attr_accessor :remote_password
8
11
 
9
12
  def initialize
10
13
  @fabfile_path = UNSET_VALUE
11
- @fabric_path = UNSET_VALUE
12
- @python_path = UNSET_VALUE
13
- @tasks = UNSET_VALUE
14
+ @fabric_path = UNSET_VALUE
15
+ @python_path = UNSET_VALUE
16
+ @tasks = UNSET_VALUE
17
+ @remote = UNSET_VALUE
18
+ @remote_install = UNSET_VALUE
19
+ @remote_password = UNSET_VALUE
14
20
  end
15
21
 
16
22
  def finalize!
@@ -18,6 +24,9 @@ module VagrantPlugins
18
24
  @fabric_path = "fab" if @fabric_path == UNSET_VALUE
19
25
  @python_path = "python" if @python_path == UNSET_VALUE
20
26
  @tasks = [] if @tasks == UNSET_VALUE
27
+ @remote = false if @remote == UNSET_VALUE
28
+ @remote_install = false if @remote_install == UNSET_VALUE
29
+ @remote_password = "vagrant" if @remote_password == UNSET_VALUE
21
30
  end
22
31
 
23
32
  def execute(command)
@@ -34,26 +43,33 @@ module VagrantPlugins
34
43
  end
35
44
 
36
45
  def validate(env)
37
- errors = _detected_errors
46
+ if not @remote == true
47
+ errors = _detected_errors
38
48
 
39
- errors << "fabfile does not exist." if not File.exist?(fabfile_path)
49
+ errors << "fabfile does not exist." if not File.exist?(fabfile_path)
40
50
 
41
- command = "#{fabric_path} -V"
42
- output = execute(command)
43
- errors << "fabric command does not exist." if not output
51
+ install_fabric if @remote == true and @install == true
44
52
 
45
- command = "#{fabric_path} -f #{fabfile_path} -l"
46
- output = execute(command)
47
- errors << "#{fabfile_path} could not recognize by fabric." if not $?.success?
53
+ command = "#{fabric_path} -V"
54
+ output = execute(command)
55
+ errors << "fabric command does not exist." if not output
48
56
 
49
- for task in tasks
50
- task = task.split(':').first
51
- command = "#{fabric_path} -f #{fabfile_path} -d #{task}"
57
+ command = "#{fabric_path} -f #{fabfile_path} -l"
52
58
  output = execute(command)
53
- errors << "#{task} task does not exist." if not $?.success?
59
+ errors << "#{fabfile_path} could not recognize by fabric." if not $?.success?
60
+
61
+ for task in tasks
62
+ task = task.split(':').first
63
+ command = "#{fabric_path} -f #{fabfile_path} -d #{task}"
64
+ output = execute(command)
65
+ errors << "#{task} task does not exist." if not $?.success?
66
+ end
67
+
68
+ {"fabric provisioner" => errors}
54
69
  end
70
+ end
55
71
 
56
- { "fabric provisioner" => errors }
72
+ def install_fabric()
57
73
  end
58
74
  end
59
75
  end
@@ -2,12 +2,25 @@ module VagrantPlugins
2
2
  module Fabric
3
3
  class Provisioner < Vagrant.plugin("2", :provisioner)
4
4
  def provision
5
- ssh_info = machine.ssh_info
5
+ ssh_info = @machine.ssh_info
6
6
  user = ssh_info[:username]
7
7
  host = ssh_info[:host]
8
8
  port = ssh_info[:port]
9
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(' ')}"
10
+ if config.remote == false
11
+ system "#{config.fabric_path} -f #{config.fabfile_path} " +
12
+ "-i #{private_key} --user=#{user} --hosts=#{host} " +
13
+ "--port=#{port} #{config.tasks.join(' ')}"
14
+ else
15
+ if config.install
16
+ @machine.communicate.sudo("pip install fabric")
17
+ @machine.env.ui.info "Finished to install fabric library your VM."
18
+ end
19
+ @machine.communicate.execute("#{config.fabric_path} -f #{config.fabfile_path} " +
20
+ "--user=#{user} --hosts=127.0.0.1 --password=#{config.remote_password} " +
21
+ "#{config.tasks.join(' ')}")
22
+ @machine.env.ui.info"Finished to execute tasks of fabric."
23
+ end
11
24
  end
12
25
  end
13
26
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Fabric
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = VagrantPlugins::Fabric::VERSION
9
9
  spec.platform = Gem::Platform::RUBY
10
10
  spec.authors = ["Takahiro Fujiwara"]
11
- spec.email = ["wutali.no@gmail.com"]
11
+ spec.email = ["email@wuta.li"]
12
12
  spec.homepage = "http://blog.wuta.li"
13
13
  spec.description = "Enables Vagrant to provision with python fabric script."
14
14
  spec.summary = "Enables Vagrant to provision with python fabric script."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-fabric
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-28 00:00:00.000000000 Z
12
+ date: 2013-08-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: '0'
46
46
  description: Enables Vagrant to provision with python fabric script.
47
47
  email:
48
- - wutali.no@gmail.com
48
+ - email@wuta.li
49
49
  executables: []
50
50
  extensions: []
51
51
  extra_rdoc_files: []