ilanco
ilanco

Reputation: 9957

Install Ansible on Vagrant guest from local machine

I'm using Vagrant and the ansible_local provisioner. Is there a way to specify where Ansible will be downloaded from? install_mode only selects how to install Ansible, not from where.

*EDIT With "where" I mean specify the download location.

Upvotes: 0

Views: 606

Answers (1)

techraf
techraf

Reputation: 68459

It doesn't look like you could specify the download source location. Either APT, RPM, or pip installation commands are hardcoded in Vagrant. For example:

  • ansible_install.rb (for Debian):

        def self.ansible_apt_install(machine)
    
        // skipped
    
          machine.communicate.sudo install_backports_if_wheezy_release
          machine.communicate.sudo "apt-get update -y -qq"
          machine.communicate.sudo "apt-get install -y -qq ansible"
        end
    
        def self.pip_setup(machine)
          machine.communicate.sudo "apt-get update -y -qq"
          machine.communicate.sudo "apt-get install -y -qq build-essential curl git libssl-dev libffi-dev python-dev"
          Pip::get_pip machine
        end
    
  • pip.rb (when using :pip):

        machine.communicate.sudo "pip install #{upgrade_arg}#{package}#{version_arg}"
    

That said, if you want to avoid downloading on each vagrant up, you could:

  • use a proxy for APT or yum. For example Apt-Cacher (you'd need to modify the configuration with shell provisioning to point to the proxy);
  • use a Vagrant plugin like vagrant-cachier (doesn't work for pip and generally is unreliable and not maintained);
  • use the shell provisioner to download and install Ansible using the command you want;
  • probably the best: use Vagrant Packer to create your customised box image with the required packages (i.e. Ansible) already installed.

Upvotes: 2

Related Questions