Please review pull request #3: Potentially helpful define, specifically for #4815 opened by (ahpook)
Description:
Since you'd pretty much never use these two types apart from one another, it'd be helpful to provide an example definition that uses both of them at once.
- Opened: Sat Jan 21 19:53:56 UTC 2012
- Based on: puppetlabs:master (e370ffb4295bda937894a1df203c73233481bbba)
- Requested merge: ahpook:master (31dc733331af32bb586dbd755b978b2bd074d9cf)
Diff follows:
diff --git a/examples/mounts.pp b/examples/mounts.pp
new file mode 100644
index 0000000..45d0aa4
--- /dev/null
+++ b/examples/mounts.pp
@@ -0,0 +1,53 @@
+# definition that uses the puppetlabs mounttab/mountpoint providers
+# if 'options' are specified, they need to come in as an ARRAY
+# not a quoted string, i.e
+# mounts::do { "/mnt":
+# device => "filer:/export", options => ["ro","hard","proto=tcp"] }
+
+define mounts::do($device, $options="DEFAULT") {
+ # this define wraps the 'mount' type with reasonable defaults
+
+ # make sure the parent of the mountpoint exists - there's no 'mkdir -p' equivalent in puppet
+ # note this only makes two levels of directories deep - mount point and its immediate parent
+
+ $parentpath = inline_template("<%= arry = name.split('/'); if arry.length > 2; arry.slice(0..-2).join('/'); else name end %>")
+ if ! defined(File["$parentpath"]) {
+ file { "$parentpath": ensure => directory }
+ }
+
+ # make sure the mountpoint exists, create it as a directory if not
+ if ! defined(File[$name]) {
+ file { $name: ensure => directory }
+ }
+
+ # handle mount options
+ if $options != "DEFAULT" {
+ $mountopts = $options
+ }
+ else {
+ $mountopts = $operatingsystem ? {
+ solaris => [ "rw","hard","proto=tcp","vers=3" ],
+ linux => [ "rw","hard","proto=tcp" ],
+ }
+ }
+
+ mountpoint { $name:
+ require => [ Mounttab[$name], File[$name] ],
+ device => $device,
+ options => $mountopts,
+ remounts => false,
+ ensure => present,
+ }
+
+ mounttab { $name:
+ device => $device,
+ options => $mountopts,
+ ensure => present,
+ blockdevice => "-",
+ fstype => nfs,
+ pass => 0,
+ dump => 0,
+ atboot => "yes",
+ }
+
+}
-- You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
