vagrant-persistent-storage 0.0.27 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -15
- data/lib/vagrant-persistent-storage/config.rb +20 -27
- data/lib/vagrant-persistent-storage/manage_storage.rb +3 -9
- data/lib/vagrant-persistent-storage/version.rb +1 -1
- data/locales/en.yml +1 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 89484b1d3b1d0cde5c9319e9568fc11896e66447
|
|
4
|
+
data.tar.gz: 7885463a19746bed8a3099c3e02cce77504d73e0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 065bf8c177fe0f7d9c60491eed349bbd3b8d9b7d01f91d738be5e9c47d938ad4371fe50cbb83b702da87dec1fcc25f84e6da9d359047dd023b200a194ef1fa03
|
|
7
|
+
data.tar.gz: 6f3b881af71d080f1565c30e66687b6ddede068648643396baed7f611a11062cba36662a467204a7b2ee7293a8d4ff6407e1e8ab14f86595375655731ab86e75
|
data/README.md
CHANGED
|
@@ -34,40 +34,29 @@ config.persistent_storage.mountoptions = ['defaults', 'prjquota']
|
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
Device defaults to `/dev/sdb`. For boxes with multiple disks, make sure you increment the drive:
|
|
37
|
-
```ruby
|
|
38
|
-
config.persistent_storage.diskdevice = '/dev/sdc'
|
|
39
37
|
```
|
|
40
|
-
|
|
41
|
-
If you are using LVM and you would prefer to use the disk rather than a partition, you can set the following configuration:
|
|
42
|
-
```ruby
|
|
43
|
-
config.persistent_storage.partition = false
|
|
38
|
+
config.persistent_storage.diskdevice = '/dev/sdc'
|
|
44
39
|
```
|
|
45
40
|
|
|
46
41
|
Every `vagrant up` will attach this file as hard disk to the guest machine.
|
|
47
|
-
|
|
42
|
+
An `vagrant destroy` will detach the storage to avoid deletion of the storage by vagrant.
|
|
48
43
|
A `vagrant destroy` generally destroys all attached drives. See [VBoxMange unregistervm --delete option][vboxmanage_delete].
|
|
49
44
|
|
|
50
45
|
The disk is initialized and added to it's own volume group as specfied in the config;
|
|
51
46
|
this defaults to 'vagrant'. An ext4 filesystem is created and the disk mounted appropriately,
|
|
52
|
-
with entries added to fstab ... subsequent runs will mount this disk with the options specified
|
|
47
|
+
with entries added to fstab ... subsequent runs will mount this disk with the options specified
|
|
53
48
|
|
|
54
49
|
## Windows Guests
|
|
55
50
|
|
|
56
51
|
Windows Guests must use the WinRM communicator by setting `vm.communicator = 'winrm'`. An additional option is provided to
|
|
57
52
|
allow you to set the drive letter using:
|
|
58
53
|
|
|
59
|
-
```
|
|
54
|
+
```
|
|
60
55
|
config.persistent_storage.drive_letter = 'Z'
|
|
61
56
|
```
|
|
62
57
|
|
|
63
58
|
Options that are irrelevent to Windows are ignored, such as `mountname`, `filesystem`, `mountpoint` and `volgroupname`.
|
|
64
59
|
|
|
65
|
-
## How Is The Storage Created?
|
|
66
|
-
|
|
67
|
-
Based on the configuration provided, during a `vagrant up` a bash script is generated and uploaded to `/tmp/disk_operations_#{mnt_name}.sh` (Linux) or `disk_operations_#{mnt_name}.ps1` (Windows). If the box has not been previously provisioned the script is executed on a `vagrant up`. To force the scrip to be executed again you can run `vagrant provision` or if you have halted the box, `vagrant up --provision`.
|
|
68
|
-
|
|
69
|
-
The outcome of the script being run is placed in the home drive of the vagrant user in a file called `disk_operation_log.txt`.
|
|
70
|
-
|
|
71
60
|
## Optional settings
|
|
72
61
|
|
|
73
62
|
```ruby
|
|
@@ -15,7 +15,6 @@ module VagrantPlugins
|
|
|
15
15
|
attr_accessor :mountname
|
|
16
16
|
attr_accessor :mountpoint
|
|
17
17
|
attr_accessor :mountoptions
|
|
18
|
-
attr_accessor :partition
|
|
19
18
|
attr_accessor :diskdevice
|
|
20
19
|
attr_accessor :filesystem
|
|
21
20
|
attr_accessor :volgroupname
|
|
@@ -27,7 +26,6 @@ module VagrantPlugins
|
|
|
27
26
|
alias_method :manage?, :manage
|
|
28
27
|
alias_method :format?, :format
|
|
29
28
|
alias_method :use_lvm?, :use_lvm
|
|
30
|
-
alias_method :partition?, :partition
|
|
31
29
|
alias_method :enabled?, :enabled
|
|
32
30
|
|
|
33
31
|
def initialize
|
|
@@ -38,7 +36,6 @@ module VagrantPlugins
|
|
|
38
36
|
@format = true
|
|
39
37
|
@use_lvm = true
|
|
40
38
|
@enabled = false
|
|
41
|
-
@partition = true
|
|
42
39
|
@location = UNSET_VALUE
|
|
43
40
|
@mountname = UNSET_VALUE
|
|
44
41
|
@mountpoint = UNSET_VALUE
|
|
@@ -57,33 +54,31 @@ module VagrantPlugins
|
|
|
57
54
|
@manage = true if @manage == UNSET_VALUE
|
|
58
55
|
@format = true if @format == UNSET_VALUE
|
|
59
56
|
@use_lvm = true if @use_lvm == UNSET_VALUE
|
|
60
|
-
@partition = true if @partition == UNSET_VALUE
|
|
61
57
|
@enabled = false if @enabled == UNSET_VALUE
|
|
62
|
-
@location =
|
|
63
|
-
@mountname =
|
|
64
|
-
@mountpoint =
|
|
65
|
-
@mountoptions =
|
|
66
|
-
@diskdevice =
|
|
67
|
-
@filesystem =
|
|
68
|
-
@volgroupname =
|
|
69
|
-
|
|
58
|
+
@location = 0 if @location == UNSET_VALUE
|
|
59
|
+
@mountname = 0 if @mountname == UNSET_VALUE
|
|
60
|
+
@mountpoint = 0 if @mountpoint == UNSET_VALUE
|
|
61
|
+
@mountoptions = 0 if @mountoptions == UNSET_VALUE
|
|
62
|
+
@diskdevice = 0 if @diskdevice == UNSET_VALUE
|
|
63
|
+
@filesystem = 0 if @filesystem == UNSET_VALUE
|
|
64
|
+
@volgroupname = 0 if @volgroupname == UNSET_VALUE
|
|
65
|
+
@drive_letter = 0 if @drive_letter == UNSET_VALUE
|
|
70
66
|
@part_type_code = "8e" if @part_type_code == UNSET_VALUE
|
|
71
67
|
end
|
|
72
68
|
|
|
73
69
|
def validate(machine)
|
|
74
|
-
errors =
|
|
70
|
+
errors = []
|
|
75
71
|
|
|
76
72
|
errors << validate_bool('persistent_storage.create', @create)
|
|
77
73
|
errors << validate_bool('persistent_storage.mount', @mount)
|
|
78
|
-
errors << validate_bool('persistent_storage.
|
|
79
|
-
errors << validate_bool('persistent_storage.
|
|
80
|
-
errors << validate_bool('persistent_storage.
|
|
81
|
-
errors << validate_bool('persistent_storage.
|
|
82
|
-
errors << validate_bool('persistent_storage.partition', @partition)
|
|
74
|
+
errors << validate_bool('persistent_storage.mount', @manage)
|
|
75
|
+
errors << validate_bool('persistent_storage.mount', @format)
|
|
76
|
+
errors << validate_bool('persistent_storage.mount', @use_lvm)
|
|
77
|
+
errors << validate_bool('persistent_storage.mount', @enabled)
|
|
83
78
|
errors.compact!
|
|
84
79
|
|
|
85
|
-
if !machine.config.persistent_storage.size.kind_of?(
|
|
86
|
-
errors << I18n.t('vagrant_persistent_storage.config.
|
|
80
|
+
if !machine.config.persistent_storage.size.kind_of?(String)
|
|
81
|
+
errors << I18n.t('vagrant_persistent_storage.config.not_a_string', {
|
|
87
82
|
:config_key => 'persistent_storage.size',
|
|
88
83
|
:is_class => size.class.to_s,
|
|
89
84
|
})
|
|
@@ -132,21 +127,19 @@ module VagrantPlugins
|
|
|
132
127
|
end
|
|
133
128
|
|
|
134
129
|
mount_point_path = Pathname.new("#{machine.config.persistent_storage.location}")
|
|
135
|
-
if !
|
|
130
|
+
if ! mount_point_path.absolute?
|
|
136
131
|
errors << I18n.t('vagrant_persistent_storage.config.not_a_path', {
|
|
137
132
|
:config_key => 'persistent_storage.location',
|
|
138
133
|
:is_path => location.class.to_s,
|
|
139
134
|
})
|
|
140
135
|
end
|
|
141
136
|
|
|
137
|
+
{ 'Persistent Storage configuration' => errors }
|
|
138
|
+
|
|
142
139
|
if ! File.exists?@location.to_s and ! @create == "true"
|
|
143
|
-
|
|
144
|
-
:config_key => 'persistent_storage.create',
|
|
145
|
-
:is_path => location.class.to_s,
|
|
146
|
-
})
|
|
140
|
+
return { "location" => ["file doesn't exist, and create set to false"] }
|
|
147
141
|
end
|
|
148
|
-
|
|
149
|
-
{ 'Persistent Storage configuration' => errors }
|
|
142
|
+
{}
|
|
150
143
|
end
|
|
151
144
|
|
|
152
145
|
private
|
|
@@ -14,7 +14,6 @@ module VagrantPlugins
|
|
|
14
14
|
fs_type = m.config.persistent_storage.filesystem
|
|
15
15
|
manage = m.config.persistent_storage.manage
|
|
16
16
|
use_lvm = m.config.persistent_storage.use_lvm
|
|
17
|
-
partition = m.config.persistent_storage.partition
|
|
18
17
|
mount = m.config.persistent_storage.mount
|
|
19
18
|
format = m.config.persistent_storage.format
|
|
20
19
|
part_type_code = m.config.persistent_storage.part_type_code
|
|
@@ -47,7 +46,6 @@ module VagrantPlugins
|
|
|
47
46
|
if os == "windows"
|
|
48
47
|
## shell script for windows to create NTFS partition and assign drive letter
|
|
49
48
|
disk_operations_template = ERB.new <<-EOF
|
|
50
|
-
<% if partition == true %>
|
|
51
49
|
<% if format == true %>
|
|
52
50
|
foreach ($disk in get-wmiobject Win32_DiskDrive -Filter "Partitions = 0"){
|
|
53
51
|
$disk.DeviceID
|
|
@@ -55,13 +53,11 @@ module VagrantPlugins
|
|
|
55
53
|
"select disk "+$disk.Index+"`r clean`r create partition primary`r format fs=ntfs unit=65536 quick`r active`r assign #{drive_letter}" | diskpart >> disk_operation_log.txt
|
|
56
54
|
}
|
|
57
55
|
<% end %>
|
|
58
|
-
<% end %>
|
|
59
56
|
EOF
|
|
60
57
|
else
|
|
61
58
|
## shell script to format disk, create/manage LVM, mount disk
|
|
62
59
|
disk_operations_template = ERB.new <<-EOF
|
|
63
60
|
#!/bin/bash
|
|
64
|
-
<% if partition == true %>
|
|
65
61
|
# fdisk the disk if it's not a block device already:
|
|
66
62
|
re='[0-9][.][0-9.]*[0-9.]*'; [[ $(sfdisk --version) =~ $re ]] && version="${BASH_REMATCH}"
|
|
67
63
|
if ! awk -v ver="$version" 'BEGIN { if (ver < 2.26 ) exit 1; }'; then
|
|
@@ -70,15 +66,13 @@ else
|
|
|
70
66
|
[ -b #{disk_dev}1 ] || echo ,,#{part_type_code} | sfdisk #{disk_dev}
|
|
71
67
|
fi
|
|
72
68
|
echo "fdisk returned: $?" >> disk_operation_log.txt
|
|
73
|
-
disk_dev=#{disk_dev}1
|
|
74
|
-
<% end %>
|
|
75
69
|
|
|
76
70
|
<% if use_lvm == true %>
|
|
77
71
|
# Create the physical volume if it doesn't already exist:
|
|
78
|
-
[[ `pvs #{disk_dev}` ]] || pvcreate #{disk_dev}
|
|
72
|
+
[[ `pvs #{disk_dev}1` ]] || pvcreate #{disk_dev}1
|
|
79
73
|
echo "pvcreate returned: $?" >> disk_operation_log.txt
|
|
80
74
|
# Create the volume group if it doesn't already exist:
|
|
81
|
-
[[ `vgs #{vg_name}` ]] || vgcreate #{vg_name} #{disk_dev}
|
|
75
|
+
[[ `vgs #{vg_name}` ]] || vgcreate #{vg_name} #{disk_dev}1
|
|
82
76
|
echo "vgcreate returned: $?" >> disk_operation_log.txt
|
|
83
77
|
# Create the logical volume if it doesn't already exist:
|
|
84
78
|
[[ `lvs #{vg_name} | grep #{mnt_name}` ]] || lvcreate -l 100%FREE -n #{mnt_name} #{vg_name}
|
|
@@ -90,7 +84,7 @@ echo "vg activation returned: $?" >> disk_operation_log.txt
|
|
|
90
84
|
|
|
91
85
|
<% if format == true %>
|
|
92
86
|
# Create the filesytem if it doesn't already exist
|
|
93
|
-
MNT_NAME=#{
|
|
87
|
+
MNT_NAME=#{mnt_name}
|
|
94
88
|
[[ `blkid | grep ${MNT_NAME:0:16} | grep #{fs_type}` ]] || mkfs.#{fs_type} -L #{mnt_name} #{device}
|
|
95
89
|
echo "#{fs_type} creation return: $?" >> disk_operation_log.txt
|
|
96
90
|
<% if mount == true %>
|
data/locales/en.yml
CHANGED
|
@@ -9,7 +9,4 @@ en:
|
|
|
9
9
|
manage_storage: "** Managing persistent storage **"
|
|
10
10
|
config:
|
|
11
11
|
not_a_bool: "A value for %{config_key} can only be true or false, not type '%{value}'"
|
|
12
|
-
not_an_array_or_string: "A value for %{config_key} must be an Array or String, not type '%{
|
|
13
|
-
not_a_string: "A value for %{config_key} must be a String, not type '%{value}'"
|
|
14
|
-
not_a_path: "A value for %{config_key} must be resolveable as a path"
|
|
15
|
-
not_a_number: "A value for %{config_key} must be a number, not type '%{value}'"
|
|
12
|
+
not_an_array_or_string: "A value for %{config_key} must be an Array or String, not type '%{is_class}'"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vagrant-persistent-storage
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.28
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sebastian Kusnier
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-06-
|
|
11
|
+
date: 2017-06-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|