vagrant-guest_ansible 0.0.1 → 0.0.2.dev

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,8 @@
1
1
  #!/bin/bash
2
2
 
3
- ANSIBLE_DIR=$1
4
- ANSIBLE_PLAYBOOK=$2
5
- ANSIBLE_HOSTS=$3
6
- ANSIBLE_EXTRA_VARS=$4
3
+ ANSIBLE_PLAYBOOK=$1
4
+ ANSIBLE_HOSTS=$2
5
+ ANSIBLE_EXTRA_VARS=$3
7
6
  TEMP_HOSTS="/tmp/ansible_hosts"
8
7
 
9
8
  if [ ! -f /vagrant/$ANSIBLE_PLAYBOOK ]; then
@@ -16,25 +15,39 @@ if [ ! -f /vagrant/$ANSIBLE_HOSTS ]; then
16
15
  exit 2
17
16
  fi
18
17
 
19
- if [ ! -d $ANSIBLE_DIR ]; then
20
- echo -n "Updating apt cache..."
21
- sudo apt-get update -qq
22
- echo " DONE!"
23
-
24
- echo -n "Installing Ansible dependencies and Git..."
25
- sudo apt-get install -y -qq git python-yaml python-paramiko python-jinja2
26
- echo " DONE!"
27
-
28
- # Clone ansible:
29
- sudo git clone git://github.com/ansible/ansible.git ${ANSIBLE_DIR}
18
+ if ! command -v ansible >/dev/null; then
19
+ echo "Installing Ansible dependencies and Git."
20
+ if command -v yum >/dev/null; then
21
+ sudo yum install -y git python python-devel
22
+ elif command -v apt-get >/dev/null; then
23
+ sudo apt-get update -qq
24
+ #sudo apt-get install -y -qq git python-yaml python-paramiko python-jinja2
25
+ sudo apt-get install -y -qq git python python-dev
26
+ else
27
+ echo "neither yum nor apt-get found!"
28
+ exit 1
29
+ fi
30
+ echo "Installing pip via easy_install."
31
+ wget http://peak.telecommunity.com/dist/ez_setup.py
32
+ sudo python ez_setup.py && rm -f ez_setup.py
33
+ sudo easy_install pip
34
+ # Make sure setuptools are installed crrectly.
35
+ sudo pip install setuptools --no-use-wheel --upgrade
36
+ echo "Installing required python modules."
37
+ sudo pip install paramiko pyyaml jinja2 markupsafe
38
+ sudo pip install ansible
30
39
  fi
31
40
 
32
41
  if [ ! -z "$ANSIBLE_EXTRA_VARS" -a "$ANSIBLE_EXTRA_VARS" != " " ]; then
33
42
  ANSIBLE_EXTRA_VARS=" --extra-vars \"$ANSIBLE_EXTRA_VARS\""
34
43
  fi
35
44
 
36
- cd ${ANSIBLE_DIR}
45
+ # stream output
46
+ export PYTHONUNBUFFERED=1
47
+ # show ANSI-colored output
48
+ export ANSIBLE_FORCE_COLOR=true
49
+
37
50
  cp /vagrant/${ANSIBLE_HOSTS} ${TEMP_HOSTS} && chmod -x ${TEMP_HOSTS}
38
51
  echo "Running Ansible as $USER:"
39
- bash -c "source hacking/env-setup && ansible-playbook /vagrant/${ANSIBLE_PLAYBOOK} --inventory-file=${TEMP_HOSTS} --connection=local $ANSIBLE_EXTRA_VARS"
52
+ ansible-playbook /vagrant/${ANSIBLE_PLAYBOOK} --inventory-file=${TEMP_HOSTS} --connection=local $ANSIBLE_EXTRA_VARS
40
53
  rm ${TEMP_HOSTS}
@@ -11,10 +11,9 @@ module VagrantPlugins
11
11
  def provision
12
12
 
13
13
  args = [
14
- './ansible',
15
14
  config.playbook,
16
15
  File.basename(self.setup_inventory_file),
17
- (config.extra_vars.blank? ? "''" : config.extra_vars.map { |k,v| "#{k}=#{v}" }.join(" "))
16
+ format_extra_vars(config.extra_vars)
18
17
  ].join(' ')
19
18
 
20
19
  command = "chmod +x #{config.upload_path} && #{config.upload_path} #{args}"
@@ -54,6 +53,15 @@ module VagrantPlugins
54
53
 
55
54
  protected
56
55
 
56
+ # converts the extra_vars to a properly formatted string
57
+ def format_extra_vars(extra_vars)
58
+ if extra_vars.kind_of?(String)
59
+ extra_vars.strip
60
+ elsif extra_vars.kind_of?(Hash)
61
+ extra_vars.map { |k,v| "#{k}=#{v}" }.join(" ")
62
+ end
63
+ end
64
+
57
65
  # This method yields the path to a script to upload and execute
58
66
  # on the remote server. This method will properly clean up the
59
67
  # script file if needed.
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module GuestAnsible
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2.dev"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-guest_ansible
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2.dev
5
+ prerelease: 6
5
6
  platform: ruby
6
7
  authors:
7
8
  - Roberto Quintanilla
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-03-06 00:00:00.000000000 Z
12
+ date: 2014-12-12 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,15 +30,17 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  description: Ansible provisioner intended to run in the guest machine.
@@ -60,25 +65,26 @@ files:
60
65
  homepage: https://github.com/vovimayhem/vagrant-guest_ansible
61
66
  licenses:
62
67
  - MIT
63
- metadata: {}
64
68
  post_install_message:
65
69
  rdoc_options: []
66
70
  require_paths:
67
71
  - lib
68
72
  required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
69
74
  requirements:
70
- - - '>='
75
+ - - ! '>='
71
76
  - !ruby/object:Gem::Version
72
77
  version: '0'
73
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
74
80
  requirements:
75
- - - '>='
81
+ - - ! '>'
76
82
  - !ruby/object:Gem::Version
77
- version: '0'
83
+ version: 1.3.1
78
84
  requirements: []
79
85
  rubyforge_project:
80
- rubygems_version: 2.0.14
86
+ rubygems_version: 1.8.23
81
87
  signing_key:
82
- specification_version: 4
88
+ specification_version: 3
83
89
  summary: Ansible provisioner for guest machine.
84
90
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: e79cdd8250c933184102b00d37202b3a19c550f2
4
- data.tar.gz: fdb8611d8fa378890a87360fece1149e5cb493e8
5
- SHA512:
6
- metadata.gz: cf2af14c8fac3d6e9f63839776407f6dc80453991c77b3f10c36e62cb5a2fd9d603ef3c64c503ceb451249109083c6e32d9768ad6599b7d47ed5be9d634a20c1
7
- data.tar.gz: 8fe3cb9abeeb92fba13fa7b8c5ffb3f83b71d88a8782c3fa768a40fde03211eabf2b54a0c653a82631c004e0735bd71e2e51652704b80ec96d6df78743dc5870