service subscription to a concat managed file

362 views
Skip to first unread message

opticpow

unread,
Aug 25, 2013, 9:56:55 PM8/25/13
to puppet...@googlegroups.com
Hi All,

I'm using the ripienaar/concat module to manage a number of configuration files. Is it possible for a service to subscribe to the managed file so that when another module inserts a fragment, the service is restarted?

Below is an example of what I'm trying to do. This fails with the  /etc/sysctl.conf not being a valid resource reference for the subscription.

Thanks, Wayne.

# Class to manage /etc/sysctl.conf file
# Wayne Ingram
# 26/08/2013
#
class sysctl {
   $config = "/etc/sysctl.conf"

    service {
        'boot.sysctl':
            enable     => true,
            subscribe  => $config;
    }

    concat{
        $config:
            owner => root,
            group => root,
            mode  => '0444';
    }

    concat::fragment{
       "sysctl_header":
           target  => $config,
           source  => 'puppet:///modules/sysctl/header',
           order   => 01;

        "sysctl_body":
            target  => $config,
            source  => 'puppet:///modules/sysctl/standard',
            order   => 02;

        "sysctl_seperator":
            target  => $config,
            content => "#\n#\n#Below are managed by the sysctl puppet class\n#\n",
            order   => 03;

        "sysctl_footer":
            target  => $config,
            content => "#\n# End of puppet managed config\n#\n",
            order   => 99
   }

    define register($value,$comment="",$order=50) {

        concat::fragment{
            "services_fragment_${name}":
                target  => $sysctl::config,
                content => "${name} = ${value} \t\t# ${comment} [${order}]\n",
                order   => $order;
        }
    }
}



Dan White

unread,
Aug 26, 2013, 5:24:29 PM8/26/13
to puppet...@googlegroups.com
It should be (I think)

subscribe => File[$config]

But then I use this for my sysctl: https://forge.puppetlabs.com/fiddyspence/sysctl

--
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 puppet-users...@googlegroups.com.
To post to this group, send email to puppet...@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

opticpow

unread,
Aug 26, 2013, 7:19:03 PM8/26/13
to puppet...@googlegroups.com
Hi Ygor, of course a silly miss by me. Thanks for the heads up on the module, I'll check it out.

Cheers,

Wayne.

Gavin Williams

unread,
Aug 27, 2013, 12:15:01 PM8/27/13
to puppet...@googlegroups.com
opticpow

An alternative may be to use 'notify' rather than 'subscribe'.
Would require your service to become 'refreshonly => true'...

Cheers
Gavin

jcbollinger

unread,
Aug 27, 2013, 2:27:57 PM8/27/13
to puppet...@googlegroups.com


On Monday, August 26, 2013 4:24:29 PM UTC-5, Ygor wrote:
It should be (I think)

subscribe => File[$config]



Were it me, I would at least attempt to use

subscribe => Concat[$config]

instead, since that refers to the resource you're actually declaring.  IIRC, the existence of a resource File[$config] is an implementation detail of the Concat module, and it is poor practice to depend on implementation details.


John

Reply all
Reply to author
Forward
0 new messages