Skip to content

Commit e3e1df0

Browse files
authored
Merge pull request #147 from ricciocri/master
Added the createonly option for the volumegroup and the possibility t…
2 parents 2383d59 + 82ce0fc commit e3e1df0

File tree

3 files changed

+63
-5
lines changed

3 files changed

+63
-5
lines changed

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,33 @@ lvm::volume_groups:
104104
mountpath: /var/backups
105105
mountpath_require: true
106106
```
107-
108-
107+
or to just build the VG if it does not exists
108+
```yaml
109+
---
110+
lvm::volume_groups:
111+
myvg:
112+
createonly: true
113+
physical_volumes:
114+
/dev/sda2:
115+
unless_vg: 'myvg'
116+
/dev/sda3:
117+
unless_vg: 'myvg'
118+
logical_volumes:
119+
opt:
120+
size: 20G
121+
tmp:
122+
size: 1G
123+
usr:
124+
size: 3G
125+
var:
126+
size: 15G
127+
home:
128+
size: 5G
129+
backup:
130+
size: 5G
131+
mountpath: /var/backups
132+
mountpath_require: true
133+
```
109134
110135
Except that in the latter case you cannot specify create options.
111136
If you want to omit the file system type, but still specify the size of the

manifests/physical_volume.pp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# == Define: lvm::physical_volume
2+
#
3+
define lvm::physical_volume (
4+
$ensure = present,
5+
$force = false,
6+
$unless_vg = undef,
7+
) {
8+
9+
if ($name == undef) {
10+
fail("lvm::physical_volume \$name can't be undefined")
11+
}
12+
13+
physical_volume { $name:
14+
ensure => $ensure,
15+
force => $force,
16+
unless_vg => $unless_vg
17+
}
18+
19+
}

manifests/volume_group.pp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
define lvm::volume_group (
44
$physical_volumes,
5+
$createonly = false,
56
$ensure = present,
67
$logical_volumes = {},
78
) {
@@ -12,12 +13,25 @@
1213
fail("lvm::volume_group \$name can't be undefined")
1314
}
1415

15-
physical_volume { $physical_volumes:
16-
ensure => $ensure,
17-
} ->
16+
if is_hash($physical_volumes) {
17+
create_resources(
18+
'lvm::physical_volume',
19+
$physical_volumes,
20+
{
21+
ensure => $ensure,
22+
}
23+
)
24+
}
25+
else {
26+
physical_volume { $physical_volumes:
27+
ensure => $ensure,
28+
}
29+
}
30+
1831

1932
volume_group { $name:
2033
ensure => $ensure,
34+
createonly => $createonly,
2135
physical_volumes => $physical_volumes,
2236
}
2337

0 commit comments

Comments
 (0)