author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Sun, 09 Dec 2018 11:56:59 +0200 | |
changeset 2290 | 3b2866390fb7 |
parent 2272 | 46e6d01a6e3f |
child 2291 | a49f3423eb55 |
permissions | -rw-r--r-- |
2197
5ee52f8d25b5
Changing Vagrant home directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
1 |
|
5ee52f8d25b5
Changing Vagrant home directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
2 |
========= |
5ee52f8d25b5
Changing Vagrant home directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
3 |
Vagrant |
5ee52f8d25b5
Changing Vagrant home directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
4 |
========= |
5ee52f8d25b5
Changing Vagrant home directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
5 |
|
5ee52f8d25b5
Changing Vagrant home directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
6 |
Changing Vagrant home directory |
5ee52f8d25b5
Changing Vagrant home directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
7 |
=============================== |
5ee52f8d25b5
Changing Vagrant home directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
8 |
|
5ee52f8d25b5
Changing Vagrant home directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
9 |
Set ``VAGRANT_HOME`` env var, like:: |
5ee52f8d25b5
Changing Vagrant home directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
10 |
|
5ee52f8d25b5
Changing Vagrant home directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
11 |
VAGRANT_HOME=d:\srv\vagrant |
5ee52f8d25b5
Changing Vagrant home directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
12 |
|
5ee52f8d25b5
Changing Vagrant home directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
13 |
Default is ``~/.vagrant.d`` for Linux and ``%USERPROFILE%\.vagrant.d`` for Windows. |
5ee52f8d25b5
Changing Vagrant home directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
14 |
|
5ee52f8d25b5
Changing Vagrant home directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
15 |
https://www.vagrantup.com/docs/other/environmental-variables.html |
2271 | 16 |
Environmental Variables. ``VAGRANT_HOME``. |
17 |
https://www.vagrantup.com/docs/vagrantfile/ |
|
18 |
Load Order and Merging. |
|
2197
5ee52f8d25b5
Changing Vagrant home directory.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
19 |
|
2272 | 20 |
Managing names |
21 |
============== |
|
22 |
||
23 |
Vagrant VM name:: |
|
24 |
||
25 |
config.vm.define "NAME" |
|
26 |
||
27 |
VirtualBox name:: |
|
28 |
||
29 |
config.vm.provider :virtualbox do |vb| |
|
30 |
vb.name = "NAME" |
|
31 |
end |
|
32 |
||
33 |
Host name:: |
|
34 |
||
35 |
config.vm.hostname = "NAME" |
|
36 |
||
2237 | 37 |
Managing boxes |
38 |
============== |
|
39 |
||
40 |
Adding new box from catalog:: |
|
41 |
||
42 |
$ vagrant box add ubuntu/trusty64 |
|
43 |
||
44 |
Checking for box updates:: |
|
45 |
||
46 |
$ cd $BOXDIR |
|
47 |
$ vagrant box outdated |
|
48 |
||
2238 | 49 |
or:: |
50 |
||
51 |
$ vagrant box outdated --global |
|
52 |
||
2237 | 53 |
Disable checking for update each time you call ``vagrant`` command:: |
54 |
||
55 |
Vagrant.configure("2") do |config| |
|
56 |
config.vm.box_check_update = false |
|
57 |
end |
|
58 |
||
59 |
Download box update:: |
|
60 |
||
61 |
$ vagrant box update |
|
62 |
||
63 |
.. note:: |
|
64 |
``vagrant box update`` does not magicall updates your existing boxes. In just download |
|
65 |
updated versions. To install new versio you need to destroy and install new boxes:: |
|
66 |
||
67 |
$ vagrant destroy |
|
68 |
$ vagrant up |
|
69 |
||
70 |
To remove box at specific version:: |
|
71 |
||
72 |
$ vagrant box remove laravel/homestead --box-version 1.1.0 |
|
73 |
||
2259 | 74 |
To get list of boxes with corresponding versions:: |
75 |
||
76 |
$ vagrant box list |
|
77 |
$ vagrant global-status |
|
78 |
||
2237 | 79 |
https://www.vagrantup.com/docs/cli/box.html |
80 |
Command: ``vagrant box``. |
|
81 |
https://www.vagrantup.com/docs/boxes/versioning.html |
|
82 |
Box Versioning. |
|
83 |
||
2238 | 84 |
Managing plugins |
85 |
================ |
|
86 |
||
87 |
https://www.vagrantup.com/docs/cli/plugin.html |
|
88 |
Command: ``vagrant plugin``. |
|
89 |
https://github.com/hashicorp/vagrant/wiki/Available-Vagrant-Plugins |
|
90 |
List of vagrant plugins. |
|
91 |
||
2259 | 92 |
Debugging Vagrant |
93 |
================= |
|
94 |
||
95 |
Add environment variavle:: |
|
96 |
||
97 |
VAGRANT_LOG=warn vagrant ssh |
|
98 |
VAGRANT_LOG=info vagrant ssh |
|
99 |
VAGRANT_LOG=debug vagrant ssh |
|
100 |
||
2271 | 101 |
https://www.vagrantup.com/docs/other/environmental-variables.html |
102 |
Environmental Variables. ``VAGRANT_LOG``. |
|
103 |
||
2201
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
104 |
Running individual provisioning scripts |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
105 |
======================================= |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
106 |
|
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
107 |
You may give name to provisioning script:: |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
108 |
|
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
109 |
Vagrant.configure("2") do |config| |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
110 |
config.vm.provision 'user_ssh', type: :shell, privileged: false do |s| |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
111 |
ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
112 |
s.inline = "echo #{ssh_pub_key} >> /home/$USER/.ssh/authorized_keys" |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
113 |
end |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
114 |
config.vm.provision 'root_ssh', type: :shell, privileged: true do |s| |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
115 |
ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
116 |
s.inline = "mkdir /root/.ssh/; echo #{ssh_pub_key} >> /root/.ssh/authorized_keys" |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
117 |
end |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
118 |
... |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
119 |
end |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
120 |
|
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
121 |
and apply them individually:: |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
122 |
|
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
123 |
vagrant provision --provision-with user_ssh |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
124 |
vagrant provision --provision-with root_ssh |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
125 |
vagrant provision --provision-with user_ssh,root_ssh |
af2d2e117b4e
Running individual provisioning scripts.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2197
diff
changeset
|
126 |
|
2236
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
127 |
Working with Alpine Linux |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
128 |
========================= |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
129 |
|
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
130 |
Install plugin:: |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
131 |
|
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
132 |
$ vagrant plugin install vagrant-alpine |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
133 |
Installing the 'vagrant-alpine' plugin. This can take a few minutes... |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
134 |
Installed the plugin 'vagrant-alpine (0.3.0)'! |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
135 |
|
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
136 |
Create Vagrantfile:: |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
137 |
|
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
138 |
$ vagrant init maier/alpine-3.6-x86_64 |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
139 |
|
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
140 |
https://app.vagrantup.com/maier/boxes/alpine-3.6-x86_64 |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
141 |
AlpineLinux v3.6.2 with VirtualBoxGuestAdditions |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
142 |
https://app.vagrantup.com/maier |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
143 |
maier boxes. |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
144 |
https://github.com/maier/vagrant-alpine |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
145 |
Home page of ``vagrant-alpine`` plugin. |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
146 |
https://app.vagrantup.com/generic/boxes/alpine36 |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
147 |
Generic box. |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
148 |
https://app.vagrantup.com/generic/boxes |
15e9cc9e054f
Working with Alpine Linux.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2201
diff
changeset
|
149 |
Generic boxes. |