vagrant-ansible 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gemtest ADDED
File without changes
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ## vagrant-ansible
1
+ ## vagrant-ansible [![Build Status](https://secure.travis-ci.org/dsander/vagrant-ansible.png?branch=master)](http://travis-ci.org/dsander/vagrant-ansible)
2
2
 
3
3
  https://github.com/dsander/vagrant-ansible
4
4
 
data/Rakefile CHANGED
@@ -1,22 +1,27 @@
1
1
  # -*- ruby -*-
2
2
 
3
3
  require 'rubygems'
4
- require 'hoe'
4
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby'
5
+ require 'hoe'
5
6
 
6
- Hoe.plugin :git
7
- Hoe.plugin :gemspec
8
- Hoe.plugin :bundler
9
- Hoe.plugin :gemcutter
10
- Hoe.plugins.delete :rubyforge
7
+ Hoe.plugin :git
8
+ Hoe.plugin :gemspec
9
+ Hoe.plugin :bundler
10
+ Hoe.plugin :gemcutter
11
+ Hoe.plugins.delete :rubyforge
11
12
 
12
- Hoe.spec 'vagrant-ansible' do
13
- developer('Dominik Sander', 'git@dsander.de')
14
- self.description ="Develop & test your ansible playbooks with Vagrant"
15
- self.summary = "Vagrant-ansible is a provisioning plugin for Vagrant, that makes developing and testing playbooks for ansible easy."
16
-
17
- self.readme_file = 'README.md'
18
- self.history_file = 'CHANGELOG.md'
19
- self.extra_deps << ["vagrant"]
13
+ Hoe.spec 'vagrant-ansible' do
14
+ developer('Dominik Sander', 'git@dsander.de')
15
+ self.description ="Develop & test your ansible playbooks with Vagrant"
16
+ self.summary = "Vagrant-ansible is a provisioning plugin for Vagrant, that makes developing and testing playbooks for ansible easy."
17
+
18
+ self.readme_file = 'README.md'
19
+ self.history_file = 'CHANGELOG.md'
20
+ self.extra_deps << ["vagrant"]
21
+ end
20
22
  end
21
23
 
24
+ task :default => :spec
25
+ task :test => :spec
26
+
22
27
  # vim: syntax=ruby
@@ -3,15 +3,16 @@ require 'tempfile'
3
3
  module Vagrant
4
4
  module Provisioners
5
5
  class Ansible < Base
6
- VERSION = '0.0.1'
6
+ VERSION = '0.0.2'
7
7
  include Util::SafeExec
8
8
 
9
9
  class Config < Vagrant::Config::Base
10
10
  attr_accessor :playbook
11
11
  attr_accessor :hosts
12
+ attr_accessor :inventory_file
12
13
 
13
14
  def initialize
14
-
15
+
15
16
  end
16
17
 
17
18
  def validate(env, errors)
@@ -19,7 +20,7 @@ module Vagrant
19
20
  if playbook.nil?
20
21
  errors.add(I18n.t("vagrant.provisioners.ansible.no_playbook"))
21
22
  end
22
- if hosts.nil?
23
+ if hosts.nil? and inventory_file.nil?
23
24
  errors.add(I18n.t("vagrant.provisioners.ansible.no_hosts"))
24
25
  end
25
26
  end
@@ -32,33 +33,37 @@ module Vagrant
32
33
  # This methods yield the path to a temporally created inventory
33
34
  # file.
34
35
  def with_inventory_file(ssh)
35
- begin
36
- forward = env[:vm].config.vm.forwarded_ports.select do |x|
37
- x[:guestport] == ssh.guest_port
38
- end.first[:hostport]
39
- file = Tempfile.new('inventory')
40
- file.write("[#{config.hosts}]\n")
41
- file.write("#{ssh.host}:#{forward}")
42
- file.fsync
43
- file.close
44
- yield file.path
45
- ensure
46
- file.unlink
36
+ if not config.inventory_file.nil?
37
+ yield config.inventory_file
38
+ else
39
+ begin
40
+ forward = env[:vm].config.vm.forwarded_ports.select do |x|
41
+ x[:guestport] == ssh.guest_port
42
+ end.first[:hostport]
43
+ file = Tempfile.new('inventory')
44
+ file.write("[#{config.hosts}]\n")
45
+ file.write("#{ssh.host}:#{forward}")
46
+ file.fsync
47
+ file.close
48
+ yield file.path
49
+ ensure
50
+ file.unlink
51
+ end
47
52
  end
48
53
  end
49
54
 
50
55
  def provision!
51
56
  ssh = env[:vm].config.ssh
52
-
57
+
53
58
  with_inventory_file(ssh) do |inventory_file|
54
59
  puts ["ansible-playbook",
55
- "--user=#{ssh.username}",
56
- "--inventory-file=#{inventory_file}",
60
+ "--user=#{ssh.username}",
61
+ "--inventory-file=#{inventory_file}",
57
62
  "--private-key=#{env[:vm].env.default_private_key_path}",
58
63
  config.playbook].join(' ')
59
64
  safe_exec("ansible-playbook",
60
- "--user=#{ssh.username}",
61
- "--inventory-file=#{inventory_file}",
65
+ "--user=#{ssh.username}",
66
+ "--inventory-file=#{inventory_file}",
62
67
  "--private-key=#{env[:vm].env.default_private_key_path}",
63
68
  config.playbook)
64
69
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-ansible
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-17 00:00:00.000000000 Z
12
+ date: 2012-08-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: vagrant
16
- requirement: &12257060 !ruby/object:Gem::Requirement
16
+ requirement: &19992640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *12257060
24
+ version_requirements: *19992640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &12270200 !ruby/object:Gem::Requirement
27
+ requirement: &20005240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.10'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *12270200
35
+ version_requirements: *20005240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: hoe
38
- requirement: &12267880 !ruby/object:Gem::Requirement
38
+ requirement: &20002620 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '3.0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *12267880
46
+ version_requirements: *20002620
47
47
  description: Develop & test your ansible playbooks with Vagrant
48
48
  email:
49
49
  - git@dsander.de
@@ -61,6 +61,7 @@ files:
61
61
  - lib/vagrant-ansible.rb
62
62
  - lib/vagrant-ansible/provisioner.rb
63
63
  - lib/vagrant_init.rb
64
+ - .gemtest
64
65
  homepage: https://github.com/dsander/vagrant-ansible
65
66
  licenses: []
66
67
  post_install_message: