Skip to content

Commit

Permalink
ansible_local: Improve installation from PPA
Browse files Browse the repository at this point in the history
- Fix hashicorp#9796: Failing installation on bionic (18.04 LTS)
- Remove support for precise (12.04 LTS), which is out of public support
  (On this version, the package python-software-properties contained
  the add-apt-repository tool)
- Reduce the number of SSH calls, and avoid unnecessary apt-get calls.
  • Loading branch information
cornugi authored and gildegoma committed May 31, 2018
1 parent 708dedc commit d5b5e9e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions plugins/provisioners/ansible/cap/guest/ubuntu/ansible_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@ def self.ansible_install(machine, install_mode, ansible_version, pip_args)
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
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 @@ -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.
Expand Down

0 comments on commit d5b5e9e

Please sign in to comment.