Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/vagrant-guest_ansible/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module GuestAnsible
class Config < Vagrant.plugin("2", :config)
attr_accessor :playbook
attr_accessor :extra_vars
attr_accessor :ansible_git_url
attr_accessor :inventory_path
attr_accessor :ask_sudo_pass
attr_accessor :limit
Expand All @@ -23,6 +24,7 @@ class Config < Vagrant.plugin("2", :config)
def initialize
@playbook = UNSET_VALUE
@extra_vars = UNSET_VALUE
@ansible_git_url = UNSET_VALUE
@inventory_path = UNSET_VALUE
@ask_sudo_pass = UNSET_VALUE
@limit = UNSET_VALUE
Expand Down Expand Up @@ -56,6 +58,7 @@ def binary
def finalize!
@playbook = nil if @playbook == UNSET_VALUE
@extra_vars = nil if @extra_vars == UNSET_VALUE
@ansible_git_url = nil if @ansible_git_url == UNSET_VALUE
@inventory_path = nil if @inventory_path == UNSET_VALUE
@ask_sudo_pass = nil if @ask_sudo_pass == UNSET_VALUE
@limit = nil if @limit == UNSET_VALUE
Expand Down Expand Up @@ -124,4 +127,4 @@ def validate(machine)
end
end
end
end
end
9 changes: 8 additions & 1 deletion lib/vagrant-guest_ansible/guest_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
ANSIBLE_PLAYBOOK=$1
ANSIBLE_HOSTS=$2
ANSIBLE_EXTRA_VARS="$3"
ANSIBLE_GIT_URL="$4"
TEMP_HOSTS="/tmp/ansible_hosts"

if [ ! -f /vagrant/$ANSIBLE_PLAYBOOK ]; then
Expand Down Expand Up @@ -35,7 +36,13 @@ if ! command -v ansible >/dev/null; then
sudo pip install setuptools --no-use-wheel --upgrade
echo "Installing required python modules."
sudo pip install paramiko pyyaml jinja2 markupsafe
sudo pip install ansible

echo "Installing Ansible."
if [ ! -z "$ANSIBLE_GIT_URL" ]; then
sudo pip install -U -e git+${ANSIBLE_GIT_URL}#egg=ansible
else
sudo pip install ansible
fi
fi

if [ ! -z "$ANSIBLE_EXTRA_VARS" -a "$ANSIBLE_EXTRA_VARS" != " " ]; then
Expand Down
8 changes: 6 additions & 2 deletions lib/vagrant-guest_ansible/provisioner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ def provision
config.playbook,
File.basename(self.setup_inventory_file),
format_extra_vars(config.extra_vars)
].join(' ')
]

command = "chmod +x #{config.upload_path} && #{config.upload_path} #{args}"
if !config.ansible_git_url.nil?
args << config.ansible_git_url
end

command = "chmod +x #{config.upload_path} && #{config.upload_path} #{args.join(' ')}"

with_script_file do |path|

Expand Down