Thank you for your reply :)
The head of the code would need something like this:
$server = "nfs-server.domain.com"
$prefix = "/our/prefix"
# Arrays to iterate over, which would be a little longer than this
$proddirs = [ "201201", "201202", "201203" ]
$testdirs = [ "201201", "201202", "201203" ]
$devdirs = [ "201201", "201202", "201203" ]
$nfsopts = "tcp,hard,intr,rw,bg"
By "iterate" I meant to work through a specific array, such as above.
Reading through the Mount part of the docs, I don't believe that "absent"
will remove the actual directory point, it says:
"Set it to absent to unmount (if necessary) and remove the filesystem from
the fstab"
So I would handle that by running another iteration over an array for each
section that would have a routine to make sure it's "absent" and then also
rmdir the entry in the filesystem.
I'm not understanding where the below is iterating or over where... as
$name would need to be defined somehow.
Thanks!
On Tuesday, September 25, 2012 5:09:15 AM UTC-4, Luke Bigum wrote:
>
> Hi Forrie,
>
> With regards to your iteration question, you would need to use a defined
> type, something like this (untested):
>
> define nfs_mount ( $server, $prefix, $state = "mounted" ) {
> $mount_point = "${prefix}/${name}"
>
> #If the state is "unmounted" the mount point 'File' is removed
> file { $mount_point:
> ensure => $state ? {
> "unmounted" => absent,
> "absent" => absent,
> default => present,
> }
> }
>
> mount { $mount_point:
> ensure => $state,
> device => "{$server}:${mount_point}",
> }
> }
>
> nfs_mount { $production: server => $server, prefix => $prefix}
>
> See the documentation for the Mount type in Puppet and it's ensure
> parameter for possible values for $state in the define above - it's
> possible to have entries in /etc/fstab but not actually mounted, which
> should satisfy your two stage cleanup, or you can just set $state to
> 'absent' straight away and clean up the both NFS mount and mount point.
> This means you need to maintain two arrays: one of active mount points
> and one of decomissioned mounts, however you probably don't need to keep
> the decomissioned mounts around for ever, once every server has cleaned
> themselves up they can be removed from the manifest.
>
> http://docs.puppetlabs.com/references/latest/type.html#mount
>
> Hope that helps,
>
> -Luke
>
> On 24/09/12 23:43, Forrie wrote:
> > I have many systems that require NFS mounts for production. Rather
> > than have one entry of file{} and mount{} per NFS import, in a *.pp
> > file, I'd rather set up and iterate over an array. Looking at the
> > docs, I'm not quite sure how to do this properly. We have three
> > groups for which I would need this (production, development, test)
> > that each have their own NFS mounts.
> >
> > here's what I would use:
> >
> > $server = "server.name.com"
> > $prefix = "/some/nfs/root"
> >
> > # array
> > production = [
> > "dir1",
> > "dir2",
> > "dir3",
> > "dir4",
> > ] # etc etc
> >
> > Then issue a command to iterate and manage those NFS mounts.
> >
> > Since these change from time-to-time, and require some pruning... I
> > will be left with "unmanaged" resources (ie: directory mount points)
> > scattered around that I will need to clean up. I read through some
> > tickets for feature requests and got lost in where this is going --
> > however, to keep the place neat and clean, I'd like to unmanage the
> > mount points and the fstab entries after. The idea of manually doing
> > this from system to system isn't good.
> >
> > I'm still new-ish to puppet, so any pointers would be appreciated.
> >
> >
> > Thanks.
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Puppet Users" group.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msg/puppet-users/-/MQ9gniWF4gUJ.
> > To post to this group, send email to
> > [email protected]<javascript:>.
>
> > To unsubscribe from this group, send email to
> > [email protected] <javascript:>.
> > For more options, visit this group at
> > http://groups.google.com/group/puppet-users?hl=en.
>
>
> --
> Luke Bigum
> Senior Systems Engineer
>
> Information Systems
> Ph: +44 (0) 20 3192 2520
> [email protected] <javascript:> | http://www.lmax.com
> LMAX, Yellow Building, 1A Nicholas Road, London W11 4AN
>
>
> FX and CFDs are leveraged products that can result in losses exceeding
> your deposit. They are not suitable for everyone so please ensure you
> fully understand the risks involved. The information in this email is not
> directed at residents of the United States of America or any other
> jurisdiction where trading in CFDs and/or FX is restricted or prohibited
> by local laws or regulations.
>
> The information in this email and any attachment is confidential and is
> intended only for the named recipient(s). The email may not be disclosed
> or used by any person other than the addressee, nor may it be copied in
> any way. If you are not the intended recipient please notify the sender
> immediately and delete any copies of this message. Any unauthorised
> copying, disclosure or distribution of the material in this e-mail is
> strictly forbidden.
>
> LMAX operates a multilateral trading facility. Authorised and regulated
> by the Financial Services Authority (firm registration number 509778) and
> is registered in England and Wales (number 06505809).
> Our registered address is Yellow Building, 1A Nicholas Road, London, W11
> 4AN.
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/wCGS0RWvZFwJ.
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-users?hl=en.