Sean

Here's a little something I finally got working at 2am last night. It
ensures an slist of specific mount points always have the noatime flag
(purely data folders in my case). If changes are made to the /etc/fstab
file, a remount of the affected partitions is performed.

Hopefully this can provide you with a basis to implement your specific
requirements :)

Steve

PS, I'm new to CFEngine; feedback is always appreciated!

---

bundle agent fb_fstab
{
        vars:

                # our list of partitions to add the noatime flag to.
                "noatime_partitions" slist => {"/data1","/data2"};

        classes:

                # only for specific hosts that match this regex pattern.
                "do_it" or => { classmatch("qp.*"), classmatch("cr.*") };

        files:

                do_it::

                        "/etc/fstab"

                                edit_line => 
add_noatime_flag("noatime","4","$(noatime_partitions)"),
                                classes => if_repaired("fstab_updated");

        commands:

                # if fstab was updated, we need to perform a remount of the 
affected
partitions.
                fstab_updated::

                        "/bin/mount -oremount" args => "$(noatime_partitions)";
}

bundle edit_line add_noatime_flag(flag,field_num,partition)
{
        field_edits:

                "LABEL=$(partition).*"

                        edit_field => 
col("[\s]+","$(field_num)","$(flag)","append");
}

---

> In the cfengine v2 reference the mountall directive is defined thus:
>
> mountall
> mounts all filesystems defined in the hosts filesystem table. This
> causes new NFS filesystems added by addmounts and mailcheck to be
> actually mounted. This should probably be called both before mountinfo
> and after addmounts etc. A short timeout is placed on this operation
> to avoid hanging RPC connections when parsing NFS mounted file
> systems.
>
> Is it possible to simply make sure that what is in /etc/fstab stays
> mounted properly?  I don't want to use addmounts to manage /etc/fstab.
>  We prefer to keep this file updated by hand.
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine
>


_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to