diff --git a/plugins/provisioners/ansible/cap/guest/ubuntu/ansible_install.rb b/plugins/provisioners/ansible/cap/guest/ubuntu/ansible_install.rb index 3629239d9..d319ac071 100644 --- a/plugins/provisioners/ansible/cap/guest/ubuntu/ansible_install.rb +++ b/plugins/provisioners/ansible/cap/guest/ubuntu/ansible_install.rb @@ -18,11 +18,17 @@ module VagrantPlugins private def self.ansible_apt_install(machine) - machine.communicate.sudo "apt-get update -y -qq" - machine.communicate.sudo "apt-get install -y -qq software-properties-common python-software-properties" - machine.communicate.sudo "add-apt-repository ppa:ansible/ansible -y" - machine.communicate.sudo "apt-get update -y -qq" - machine.communicate.sudo "apt-get install -y -qq ansible" + unless machine.communicate.test("test -x \"$(which add-apt-repository)\"") + machine.communicate.sudo """ + apt-get update -y -qq && \ + apt-get install -y -qq software-properties-common + """ + end + machine.communicate.sudo """ + add-apt-repository ppa:ansible/ansible -y && \ + apt-get update -y -qq && \ + apt-get install -y -qq ansible + """ end end diff --git a/website/source/docs/provisioning/ansible_local.html.md b/website/source/docs/provisioning/ansible_local.html.md index d25318b93..14df9d53f 100644 --- a/website/source/docs/provisioning/ansible_local.html.md +++ b/website/source/docs/provisioning/ansible_local.html.md @@ -73,7 +73,7 @@ This section lists the _specific_ options for the Ansible Local provisioner. In - `install_mode` (`:default`, `:pip`, or `:pip_args_only`) - Select the way to automatically install Ansible on the guest system. - `:default`: Ansible is installed from the operating system package manager. This mode doesn't support `version` selection. For many platforms (e.g Debian, FreeBSD, OpenSUSE) the official package repository is used, except for the following Linux distributions: - - On Ubuntu-like systems, the latest Ansible release is installed from the `ppa:ansible/ansible` repository. + - On Ubuntu-like systems, the latest Ansible release is installed from the `ppa:ansible/ansible` repository. The compatibility is maintained only for active long-term support (LTS) versions. - On RedHat-like systems, the latest Ansible release is installed from the [EPEL](http://fedoraproject.org/wiki/EPEL) repository. - `:pip`: Ansible is installed from [PyPI](https://pypi.python.org/pypi) with [pip](https://pip.pypa.io) package installer. With this mode, Vagrant will systematically try to [install the latest pip version](https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py). With the `:pip` mode you can optionally install a specific Ansible release by setting the [`version`](/docs/provisioning/ansible_common.html#version) option.