Thanks to both posters, but I decided against using the native mount type.
In part I wanted a bit of practice with Augeas and as Christopher wrote,
remounting is not safe.
Well, I stuck with my module and ended up with something that is not the
prettiest piece of code, but does the trick. No auto-remounts though!
define glusterfs::mount (
$server = "",
$volume = "",
$peers = "",
$mountpoint = "/mnt/gluster",
$dump = "0",
$pass = "0",
$description = "GlusterFS mount",
)
{
###############################################################################
# native augeas nodes for fstab + input variables
# spec = $server:/$volume
# file = $mountpoint
# vmfstype = glusterfs
# opt = defaults,transport=tcp,backup-volfile-servers=$peers
# dump = 0
# passno = 0
###############################################################################
# install augeas package as dependency for everything
package { 'augeas':
ensure => present,
provider => yum
}
# create mountpoint
file { "$mountpoint":
ensure => "directory",
owner => root,
group => root,
mode => '0755',
}
# fstab
augeas { "gluster-fstab-add":
context => "/files/etc/fstab",
changes => [
"set #comment[last()+1] '$description'",
"set 01/spec '$server:/$volume'",
"set 01/file '$mountpoint'",
"set 01/vfstype 'glusterfs'",
"set 01/opt[1] 'defaults'",
"set 01/opt[2] 'transport'",
"set 01/opt[2]/value 'tcp'",
"set 01/opt[3] '_netdev'",
"set 01/opt[4] 'backup-volfile-servers'",
"set 01/opt[4]/value '$peers'",
"set 01/dump '$dump'",
"set 01/passno '$pass'",
],
onlyif => [
"match *[file = '$mountpoint'] size == 0",
]
}
augeas { "gluster-fstab-set-peers":
context => "/files/etc/fstab",
changes => [
"set *[spec = '$server:/$volume'][file = '$mountpoint'][vfstype =
'glusterfs']/opt[. = 'backup-volfile-servers']/value '$peers'",
],
}
augeas { "gluster-fstab-add-peers":
context => "/files/etc/fstab",
changes => [
"ins opt after *[spec = '$server:/$volume'][file = '$mountpoint'][vfstype =
'glusterfs'][count(opt[. = 'backup-volfile-servers']) = 0]/opt[last()]",
"set *[spec = '$server:/$volume'][file = '$mountpoint'][vfstype =
'glusterfs'][count(opt[. = 'backup-volfile-servers']) = 0]/opt[last()]
backup-volfile-servers",
"set *[spec = '$server:/$volume'][file = '$mountpoint'][vfstype =
'glusterfs'][count(opt[. = 'backup-volfile-servers']) =
1]/opt[last()]/value '$peers'",
],
onlyif => [
"match *[spec = '$server:/$volume'][file = '$mountpoint'][vfstype =
'glusterfs'][opt = 'backup-volfile-servers'] size == 0",
]
}
augeas { "gluster-fstab-set-transport":
context => "/files/etc/fstab",
changes => [
"set *[spec = '$server:/$volume'][file = '$mountpoint'][vfstype =
'glusterfs']/opt[. = 'transport']/value 'tcp'",
],
}
augeas { "gluster-fstab-add-transport":
context => "/files/etc/fstab",
changes => [
"ins opt after *[spec = '$server:/$volume'][file = '$mountpoint'][vfstype =
'glusterfs'][count(opt[. = 'transport']) = 0]/opt[last()]",
"set *[spec = '$server:/$volume'][file = '$mountpoint'][vfstype =
'glusterfs'][count(opt[. = 'transport']) = 0]/opt[last()] transport",
"set *[spec = '$server:/$volume'][file = '$mountpoint'][vfstype =
'glusterfs'][count(opt[. = 'transport']) = 1]/opt[last()]/value 'tcp'",
],
onlyif => [
"match *[spec = '$server:/$volume'][file = '$mountpoint'][vfstype =
'glusterfs'][opt = 'transport'] size == 0",
]
}
}
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/04255de6-2dd4-4ac3-9ee8-9b4f46c9879c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.