vagrant.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sun, 04 Mar 2018 12:16:23 +0200
changeset 2236 15e9cc9e054f
parent 2201 af2d2e117b4e
child 2237 1223e5073007
permissions -rw-r--r--
Working with Alpine Linux.


=========
 Vagrant
=========

Changing Vagrant home directory
===============================

Set ``VAGRANT_HOME`` env var, like::

  VAGRANT_HOME=d:\srv\vagrant

Default is ``~/.vagrant.d`` for Linux and ``%USERPROFILE%\.vagrant.d`` for Windows.

https://www.vagrantup.com/docs/other/environmental-variables.html

Running individual provisioning scripts
=======================================

You may give name to provisioning script::

  Vagrant.configure("2") do |config|
    config.vm.provision 'user_ssh', type: :shell, privileged: false do |s|
      ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip
      s.inline = "echo #{ssh_pub_key} >> /home/$USER/.ssh/authorized_keys"
    end
    config.vm.provision 'root_ssh', type: :shell, privileged: true do |s|
      ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip
      s.inline = "mkdir /root/.ssh/; echo #{ssh_pub_key} >> /root/.ssh/authorized_keys"
    end
    ...
  end

and apply them individually::

  vagrant provision --provision-with user_ssh
  vagrant provision --provision-with root_ssh
  vagrant provision --provision-with user_ssh,root_ssh

Working with Alpine Linux
=========================

Install plugin::

  $ vagrant plugin install vagrant-alpine
  Installing the 'vagrant-alpine' plugin. This can take a few minutes...
  Installed the plugin 'vagrant-alpine (0.3.0)'!

Create Vagrantfile::

  $ vagrant init maier/alpine-3.6-x86_64

https://app.vagrantup.com/maier/boxes/alpine-3.6-x86_64
  AlpineLinux v3.6.2 with VirtualBoxGuestAdditions
https://app.vagrantup.com/maier
  maier boxes.
https://github.com/maier/vagrant-alpine
  Home page of ``vagrant-alpine`` plugin.
https://app.vagrantup.com/generic/boxes/alpine36
  Generic box.
https://app.vagrantup.com/generic/boxes
  Generic boxes.