Skip to content

Commit

Permalink
provisioners/ansible_local: Run galaxy from provisioning_path direc…
Browse files Browse the repository at this point in the history
…tory

Since it is now possible to specify some Galaxy settings in an
`ansible.cfg` file, it makes sense to run `ansible-galaxy` from the
same working directory as `ansible-playbook` execution does.

See http://docs.ansible.com/ansible/intro_configuration.html#galaxy-settings
  • Loading branch information
gildegoma committed Apr 23, 2016
1 parent df231f2 commit cf908d3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ IMPROVEMENTS:
- commands/login: Print a warning with both the environment variable and
local login token are present [GH-7206, GH-7219]
- communicators/winrm: Upgrade to latest WinRM gems [GH-6922]
- provisioners/ansible(both provisioners): add basic config validators/converters
- provisioners/ansible_local: Use `provisioning_path` as working directory
for `ansible-galaxy` execution
- provisioners/ansible(both provisioners): Add basic config validators/converters
on `raw_arguments` and `raw_ssh_args` options [GH-7103]
- provisioners/chef: Add the ability to install on SUSE [GH-6806]
- hosts/darwin: Add `extra_args` support for RDP [GH-5523, GH-6602]
Expand Down
11 changes: 6 additions & 5 deletions plugins/provisioners/ansible/provisioner/guest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def execute_ansible_galaxy_on_guest
:role_file => get_galaxy_role_file(config.provisioning_path),
:roles_path => get_galaxy_roles_path(config.provisioning_path)
}

remote_command = config.galaxy_command % command_values

execute_ansible_command_on_guest "galaxy", remote_command
Expand All @@ -78,15 +79,15 @@ def execute_ansible_playbook_on_guest
prepare_common_command_arguments
prepare_common_environment_variables

remote_command = "cd #{config.provisioning_path} && #{ansible_playbook_command_for_shell_execution}"

execute_ansible_command_on_guest "playbook", remote_command
execute_ansible_command_on_guest "playbook", ansible_playbook_command_for_shell_execution
end

def execute_ansible_command_on_guest(name, command)
ui_running_ansible_command name, command
remote_command = "cd #{config.provisioning_path} && #{command}"

ui_running_ansible_command name, remote_command

result = execute_on_guest(command)
result = execute_on_guest(remote_command)
raise Ansible::Errors::AnsibleCommandFailed if result != 0
end

Expand Down
2 changes: 1 addition & 1 deletion website/source/docs/provisioning/ansible_local.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ This section lists the specific options for the Ansible Local provisioner. In ad

**Attention:** There is no guarantee that this automated installation will replace a custom Ansible setup, that might be already present on the Vagrant box.

- `provisioning_path` (string) - An absolute path on the guest machine where the Ansible files are stored. The `ansible-playbook` command is executed from this directory.
- `provisioning_path` (string) - An absolute path on the guest machine where the Ansible files are stored. The `ansible-galaxy` and `ansible-playbook` commands are executed from this directory. This is the location to place an [ansible.cfg](http://docs.ansible.com/ansible/intro_configuration.html) file, in case you need it.

The default value is `/vagrant`.

Expand Down

0 comments on commit cf908d3

Please sign in to comment.