vagrant-ansible-fixed 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +9 -0
- data/README.md +37 -0
- data/Rakefile +3 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/cap/guest/arch/ansible_install.rb +19 -0
- data/lib/cap/guest/debian/ansible_install.rb +28 -0
- data/lib/cap/guest/fedora/ansible_install.rb +26 -0
- data/lib/cap/guest/freebsd/ansible_install.rb +18 -0
- data/lib/cap/guest/posix/ansible_installed.rb +25 -0
- data/lib/cap/guest/redhat/ansible_install.rb +27 -0
- data/lib/cap/guest/suse/ansible_install.rb +18 -0
- data/lib/cap/guest/ubuntu/ansible_install.rb +22 -0
- data/lib/config/base.rb +119 -0
- data/lib/config/guest.rb +69 -0
- data/lib/config/host.rb +64 -0
- data/lib/errors.rb +27 -0
- data/lib/helpers.rb +43 -0
- data/lib/plugin.rb +80 -0
- data/lib/provisioner/base.rb +219 -0
- data/lib/provisioner/guest.rb +149 -0
- data/lib/provisioner/host.rb +257 -0
- data/lib/version.rb +5 -0
- data/vagrant-ansible-fixed.gemspec +23 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d3a31f0677f1725420e201a98b8a489031c46094
|
4
|
+
data.tar.gz: f54d7f71c2662af72ebbecc1ff70b7c979d398a0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8a805228c9b42db74228f66911c5327972005db38960db9b9f3e6e1e156b9004bc43139d500d4ab961de4dcbba13710b670cd5a94040c1c3cdb3b241f940d72b
|
7
|
+
data.tar.gz: 958d61cf06ec5da2f8a3ebec5faf8e5277d75036d4714adc2f0a1cc1c38e854dd2f0f2efda8647023a70de33e6fe6f8b1a0c54c952d6388a24c7407927c4ad61
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Vagrant::Ansible::Fixed
|
2
|
+
|
3
|
+
WProvides support for provisioning your virtual machines with Ansible
|
4
|
+
from the Vagrant host (`ansible`) or from the guests (`ansible_local`).
|
5
|
+
DESC with patch for Wi
|
6
|
+
|
7
|
+
TODO: Delete this and the text above, and describe your gem
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'vagrant-ansible-fixed'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install vagrant-ansible-fixed
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
TODO: Write usage instructions here
|
28
|
+
|
29
|
+
## Development
|
30
|
+
|
31
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
32
|
+
|
33
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/vagrant-ansible-fixed.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "vagrant/ansible/fixed"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
module VagrantPlugins
|
3
|
+
module Ansible
|
4
|
+
module Cap
|
5
|
+
module Guest
|
6
|
+
module Arch
|
7
|
+
module AnsibleInstall
|
8
|
+
|
9
|
+
def self.ansible_install(machine)
|
10
|
+
machine.communicate.sudo("pacman -Syy --noconfirm")
|
11
|
+
machine.communicate.sudo("pacman -S --noconfirm ansible")
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
module VagrantPlugins
|
3
|
+
module Ansible
|
4
|
+
module Cap
|
5
|
+
module Guest
|
6
|
+
module Debian
|
7
|
+
module AnsibleInstall
|
8
|
+
|
9
|
+
def self.ansible_install(machine)
|
10
|
+
|
11
|
+
install_backports_if_wheezy_release = <<INLINE_CRIPT
|
12
|
+
CODENAME=`lsb_release -cs`
|
13
|
+
if [ x$CODENAME == 'xwheezy' ]; then
|
14
|
+
echo 'deb http://http.debian.net/debian wheezy-backports main' > /etc/apt/sources.list.d/wheezy-backports.list
|
15
|
+
fi
|
16
|
+
INLINE_CRIPT
|
17
|
+
|
18
|
+
machine.communicate.sudo(install_backports_if_wheezy_release)
|
19
|
+
machine.communicate.sudo("apt-get update -y -qq")
|
20
|
+
machine.communicate.sudo("apt-get install -y -qq ansible")
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
module VagrantPlugins
|
3
|
+
module Ansible
|
4
|
+
module Cap
|
5
|
+
module Guest
|
6
|
+
module Fedora
|
7
|
+
module AnsibleInstall
|
8
|
+
|
9
|
+
def self.ansible_install(machine)
|
10
|
+
if dnf?(machine)
|
11
|
+
machine.communicate.sudo("dnf -y install ansible")
|
12
|
+
else
|
13
|
+
machine.communicate.sudo("yum -y install ansible")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.dnf?(machine)
|
18
|
+
machine.communicate.test("/usr/bin/which -s dnf")
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
module VagrantPlugins
|
3
|
+
module Ansible
|
4
|
+
module Cap
|
5
|
+
module Guest
|
6
|
+
module FreeBSD
|
7
|
+
module AnsibleInstall
|
8
|
+
|
9
|
+
def self.ansible_install(machine)
|
10
|
+
machine.communicate.sudo("yes | pkg install ansible")
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Ansible
|
3
|
+
module Cap
|
4
|
+
module Guest
|
5
|
+
module POSIX
|
6
|
+
module AnsibleInstalled
|
7
|
+
|
8
|
+
# Check if Ansible is installed (at the given version).
|
9
|
+
# @return [true, false]
|
10
|
+
def self.ansible_installed(machine, version)
|
11
|
+
command = 'test -x "$(command -v ansible)"'
|
12
|
+
|
13
|
+
if !version.empty?
|
14
|
+
command << "&& ansible --version | grep 'ansible #{version}'"
|
15
|
+
end
|
16
|
+
|
17
|
+
machine.communicate.test(command, sudo: false)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
module VagrantPlugins
|
3
|
+
module Ansible
|
4
|
+
module Cap
|
5
|
+
module Guest
|
6
|
+
module RedHat
|
7
|
+
module AnsibleInstall
|
8
|
+
|
9
|
+
def self.ansible_install(machine)
|
10
|
+
epel = machine.communicate.execute("#{yum_dnf(machine)} repolist epel | grep -q epel", :error_check => false)
|
11
|
+
if epel != 0
|
12
|
+
machine.communicate.sudo('sudo rpm -i https://dl.fedoraproject.org/pub/epel/epel-release-latest-`rpm -E %dist | sed -n \'s/.*el\([0-9]\).*/\1/p\'`.noarch.rpm')
|
13
|
+
end
|
14
|
+
|
15
|
+
machine.communicate.sudo("#{yum_dnf(machine)} -y --enablerepo=epel install ansible")
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.yum_dnf(machine)
|
19
|
+
machine.communicate.test("/usr/bin/which -s dnf") ? "dnf" : "yum"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
module VagrantPlugins
|
3
|
+
module Ansible
|
4
|
+
module Cap
|
5
|
+
module Guest
|
6
|
+
module SUSE
|
7
|
+
module AnsibleInstall
|
8
|
+
|
9
|
+
def self.ansible_install(machine)
|
10
|
+
machine.communicate.sudo("zypper --non-interactive --quiet install ansible")
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
module VagrantPlugins
|
3
|
+
module Ansible
|
4
|
+
module Cap
|
5
|
+
module Guest
|
6
|
+
module Ubuntu
|
7
|
+
module AnsibleInstall
|
8
|
+
|
9
|
+
def self.ansible_install(machine)
|
10
|
+
machine.communicate.sudo("apt-get update -y -qq")
|
11
|
+
machine.communicate.sudo("apt-get install -y -qq software-properties-common python-software-properties")
|
12
|
+
machine.communicate.sudo("add-apt-repository ppa:ansible/ansible -y")
|
13
|
+
machine.communicate.sudo("apt-get update -y -qq")
|
14
|
+
machine.communicate.sudo("apt-get install -y -qq ansible")
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/config/base.rb
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Ansible_Fixed
|
3
|
+
module Config
|
4
|
+
class Base < Vagrant.plugin("2", :config)
|
5
|
+
|
6
|
+
GALAXY_COMMAND_DEFAULT = "ansible-galaxy install --role-file=%{role_file} --roles-path=%{roles_path} --force".freeze
|
7
|
+
|
8
|
+
attr_accessor :extra_vars
|
9
|
+
attr_accessor :galaxy_role_file
|
10
|
+
attr_accessor :galaxy_roles_path
|
11
|
+
attr_accessor :galaxy_command
|
12
|
+
attr_accessor :host_vars
|
13
|
+
attr_accessor :groups
|
14
|
+
attr_accessor :inventory_path
|
15
|
+
attr_accessor :limit
|
16
|
+
attr_accessor :playbook
|
17
|
+
attr_accessor :raw_arguments
|
18
|
+
attr_accessor :skip_tags
|
19
|
+
attr_accessor :start_at_task
|
20
|
+
attr_accessor :sudo
|
21
|
+
attr_accessor :sudo_user
|
22
|
+
attr_accessor :tags
|
23
|
+
attr_accessor :vault_password_file
|
24
|
+
attr_accessor :verbose
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
@extra_vars = UNSET_VALUE
|
28
|
+
@galaxy_role_file = UNSET_VALUE
|
29
|
+
@galaxy_roles_path = UNSET_VALUE
|
30
|
+
@galaxy_command = UNSET_VALUE
|
31
|
+
@host_vars = UNSET_VALUE
|
32
|
+
@groups = UNSET_VALUE
|
33
|
+
@inventory_path = UNSET_VALUE
|
34
|
+
@limit = UNSET_VALUE
|
35
|
+
@playbook = UNSET_VALUE
|
36
|
+
@raw_arguments = UNSET_VALUE
|
37
|
+
@skip_tags = UNSET_VALUE
|
38
|
+
@start_at_task = UNSET_VALUE
|
39
|
+
@sudo = UNSET_VALUE
|
40
|
+
@sudo_user = UNSET_VALUE
|
41
|
+
@tags = UNSET_VALUE
|
42
|
+
@vault_password_file = UNSET_VALUE
|
43
|
+
@verbose = UNSET_VALUE
|
44
|
+
end
|
45
|
+
|
46
|
+
def finalize!
|
47
|
+
@extra_vars = nil if @extra_vars == UNSET_VALUE
|
48
|
+
@galaxy_role_file = nil if @galaxy_role_file == UNSET_VALUE
|
49
|
+
@galaxy_roles_path = nil if @galaxy_roles_path == UNSET_VALUE
|
50
|
+
@galaxy_command = GALAXY_COMMAND_DEFAULT if @galaxy_command == UNSET_VALUE
|
51
|
+
@host_vars = {} if @host_vars == UNSET_VALUE
|
52
|
+
@groups = {} if @groups == UNSET_VALUE
|
53
|
+
@inventory_path = nil if @inventory_path == UNSET_VALUE
|
54
|
+
@limit = nil if @limit == UNSET_VALUE
|
55
|
+
@playbook = nil if @playbook == UNSET_VALUE
|
56
|
+
@raw_arguments = nil if @raw_arguments == UNSET_VALUE
|
57
|
+
@skip_tags = nil if @skip_tags == UNSET_VALUE
|
58
|
+
@start_at_task = nil if @start_at_task == UNSET_VALUE
|
59
|
+
@sudo = false if @sudo != true
|
60
|
+
@sudo_user = nil if @sudo_user == UNSET_VALUE
|
61
|
+
@tags = nil if @tags == UNSET_VALUE
|
62
|
+
@vault_password_file = nil if @vault_password_file == UNSET_VALUE
|
63
|
+
@verbose = false if @verbose == UNSET_VALUE
|
64
|
+
end
|
65
|
+
|
66
|
+
# Just like the normal configuration "validate" method except that
|
67
|
+
# it returns an array of errors that should be merged into some
|
68
|
+
# other error accumulator.
|
69
|
+
def validate(machine)
|
70
|
+
@errors = _detected_errors
|
71
|
+
|
72
|
+
# Validate that a playbook path was provided
|
73
|
+
if !playbook
|
74
|
+
@errors << I18n.t("vagrant.provisioners.ansible.errors.no_playbook")
|
75
|
+
end
|
76
|
+
|
77
|
+
if playbook
|
78
|
+
check_path_is_a_file(machine, playbook, "vagrant.provisioners.ansible.errors.playbook_path_invalid")
|
79
|
+
end
|
80
|
+
|
81
|
+
if inventory_path
|
82
|
+
check_path_exists(machine, inventory_path, "vagrant.provisioners.ansible.errors.inventory_path_invalid")
|
83
|
+
end
|
84
|
+
|
85
|
+
if galaxy_role_file
|
86
|
+
check_path_is_a_file(machine, galaxy_role_file, "vagrant.provisioners.ansible.errors.galaxy_role_file_invalid")
|
87
|
+
end
|
88
|
+
|
89
|
+
if vault_password_file
|
90
|
+
check_path_is_a_file(machine, vault_password_file, "vagrant.provisioners.ansible.errors.vault_password_file_invalid")
|
91
|
+
end
|
92
|
+
|
93
|
+
# Validate that extra_vars is either a hash, or a path to an existing file
|
94
|
+
if extra_vars
|
95
|
+
extra_vars_is_valid = extra_vars.kind_of?(Hash) || extra_vars.kind_of?(String)
|
96
|
+
if extra_vars.kind_of?(String)
|
97
|
+
# Accept the usage of '@' prefix in Vagrantfile (e.g. '@vars.yml'
|
98
|
+
# and 'vars.yml' are both supported)
|
99
|
+
match_data = /^@?(.+)$/.match(extra_vars)
|
100
|
+
extra_vars_path = match_data[1].to_s
|
101
|
+
extra_vars_is_valid = check_path_is_a_file(machine, extra_vars_path)
|
102
|
+
if extra_vars_is_valid
|
103
|
+
@extra_vars = '@' + extra_vars_path
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
if !extra_vars_is_valid
|
108
|
+
@errors << I18n.t(
|
109
|
+
"vagrant.provisioners.ansible.errors.extra_vars_invalid",
|
110
|
+
type: extra_vars.class.to_s,
|
111
|
+
value: extra_vars.to_s)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
data/lib/config/guest.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require_relative "base"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Ansible_Fixed
|
5
|
+
module Config
|
6
|
+
class Guest < Base
|
7
|
+
|
8
|
+
attr_accessor :provisioning_path
|
9
|
+
attr_accessor :tmp_path
|
10
|
+
attr_accessor :install
|
11
|
+
attr_accessor :version
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super
|
15
|
+
|
16
|
+
@install = UNSET_VALUE
|
17
|
+
@provisioning_path = UNSET_VALUE
|
18
|
+
@tmp_path = UNSET_VALUE
|
19
|
+
@version = UNSET_VALUE
|
20
|
+
end
|
21
|
+
|
22
|
+
def finalize!
|
23
|
+
super
|
24
|
+
|
25
|
+
@install = true if @install == UNSET_VALUE
|
26
|
+
@provisioning_path = "/vagrant" if provisioning_path == UNSET_VALUE
|
27
|
+
@tmp_path = "/tmp/vagrant-ansible" if tmp_path == UNSET_VALUE
|
28
|
+
@version = "" if @version == UNSET_VALUE
|
29
|
+
end
|
30
|
+
|
31
|
+
def validate(machine)
|
32
|
+
super
|
33
|
+
|
34
|
+
{ "ansible local provisioner" => @errors }
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
def check_path(machine, path, test_args, error_message_key = nil)
|
40
|
+
remote_path - File.expand_path(path, @provisioning_path)
|
41
|
+
|
42
|
+
# Remove drive letter if running on a Windows host
|
43
|
+
remote_path = remote_path.gsub(/^[a-zA-Z]:/, "")
|
44
|
+
|
45
|
+
if machine.communicate.ready? && !machine.communicate.test("test #{test_args} #{remote_path}")
|
46
|
+
if error_message_key
|
47
|
+
# only show warnings, as raising an error would abort the request
|
48
|
+
# vagrant action (e.g. prevent `destroy` to be executed)
|
49
|
+
machine.ui.warn(I18n.t(error_message_key, path: remote_path, system: "guest"))
|
50
|
+
end
|
51
|
+
return false
|
52
|
+
end
|
53
|
+
# when the machine is not ready for SSH communication,
|
54
|
+
# the check is "optimistically" bypassed.
|
55
|
+
true
|
56
|
+
end
|
57
|
+
|
58
|
+
def check_path_is_a_file(machine, path, error_message_key = nil)
|
59
|
+
check_path(machine, path, "-f", error_message_key)
|
60
|
+
end
|
61
|
+
|
62
|
+
def check_path_exists(machine, path, error_message_key = nil)
|
63
|
+
check_path(machine, path, "-e", error_message_key)
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/config/host.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require_relative "base"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Ansible_Fixed
|
5
|
+
module Config
|
6
|
+
class Host < Base
|
7
|
+
|
8
|
+
attr_accessor :ask_sudo_pass
|
9
|
+
attr_accessor :ask_vault_pass
|
10
|
+
attr_accessor :force_remote_user
|
11
|
+
attr_accessor :host_key_checking
|
12
|
+
attr_accessor :raw_ssh_args
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
super
|
16
|
+
|
17
|
+
@ask_sudo_pass = false
|
18
|
+
@ask_vault_pass = false
|
19
|
+
@force_remote_user = true
|
20
|
+
@host_key_checking = false
|
21
|
+
@raw_ssh_args = UNSET_VALUE
|
22
|
+
end
|
23
|
+
|
24
|
+
def finalize!
|
25
|
+
super
|
26
|
+
|
27
|
+
@ask_sudo_pass = false if @ask_sudo_pass != true
|
28
|
+
@ask_vault_pass = false if @ask_vault_pass != true
|
29
|
+
@force_remote_user = true if @force_remote_user != false
|
30
|
+
@host_key_checking = false if @host_key_checking != true
|
31
|
+
@raw_ssh_args = nil if @raw_ssh_args == UNSET_VALUE
|
32
|
+
end
|
33
|
+
|
34
|
+
def validate(machine)
|
35
|
+
super
|
36
|
+
|
37
|
+
{ "ansible remote provisioner" => @errors }
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
|
42
|
+
def check_path(machine, path, path_test_method, error_message_key = nil)
|
43
|
+
expanded_path = Pathname.new(path).expand_path(machine.env.root_path)
|
44
|
+
if !expanded_path.public_send(path_test_method)
|
45
|
+
if error_message_key
|
46
|
+
@errors << I18n.t(error_message_key, path: expanded_path, system: "host")
|
47
|
+
end
|
48
|
+
return false
|
49
|
+
end
|
50
|
+
true
|
51
|
+
end
|
52
|
+
|
53
|
+
def check_path_is_a_file(machine, path, error_message_key = nil)
|
54
|
+
check_path(machine, path, "file?", error_message_key)
|
55
|
+
end
|
56
|
+
|
57
|
+
def check_path_exists(machine, path, error_message_key = nil)
|
58
|
+
check_path(machine, path, "exist?", error_message_key)
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/errors.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Ansible
|
5
|
+
module Errors
|
6
|
+
class AnsibleError < Vagrant::Errors::VagrantError
|
7
|
+
error_namespace("vagrant.provisioners.ansible.errors")
|
8
|
+
end
|
9
|
+
|
10
|
+
class AnsibleCommandFailed < AnsibleError
|
11
|
+
error_key(:ansible_command_failed)
|
12
|
+
end
|
13
|
+
|
14
|
+
class AnsibleNotFoundOnHost < AnsibleError
|
15
|
+
error_key(:ansible_not_found_on_host)
|
16
|
+
end
|
17
|
+
|
18
|
+
class AnsibleNotFoundOnGuest < AnsibleError
|
19
|
+
error_key(:ansible_not_found_on_guest)
|
20
|
+
end
|
21
|
+
|
22
|
+
class AnsibleVersionNotFoundOnGuest < AnsibleError
|
23
|
+
error_key(:ansible_version_not_found_on_guest)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/helpers.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Ansible
|
5
|
+
class Helpers
|
6
|
+
def self.stringify_ansible_playbook_command(env, command)
|
7
|
+
shell_command = ''
|
8
|
+
env.each_pair do |k, v|
|
9
|
+
if k == 'ANSIBLE_SSH_ARGS'
|
10
|
+
shell_command += "#{k}='#{v}' "
|
11
|
+
else
|
12
|
+
shell_command += "#{k}=#{v} "
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
shell_arg = []
|
17
|
+
command.each do |arg|
|
18
|
+
if arg =~ /(--start-at-task|--limit)=(.+)/
|
19
|
+
shell_arg << "#{$1}='#{$2}'"
|
20
|
+
else
|
21
|
+
shell_arg << arg
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
shell_command += shell_arg.join(' ')
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.expand_path_in_unix_style(path, base_dir)
|
29
|
+
# Remove the possible drive letter, which is added
|
30
|
+
# by `File.expand_path` when running on a Windows host
|
31
|
+
File.expand_path(path, base_dir).sub(/^[a-zA-Z]:/, "")
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.as_list_argument(v)
|
35
|
+
v.kind_of?(Array) ? v.join(',') : v
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.as_array(v)
|
39
|
+
v.kind_of?(Array) ? v : [v]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|