FAQ
Hi All,

I'm using the ripienaar/concat<https://forge.puppetlabs.com/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;
         }
     }
}



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

Search Discussions

  • Dan White at Aug 26, 2013 at 9:24 pm
    It should be (I think)

      subscribe => File[$config]

    But then I use this for my sysctl: https://forge.puppetlabs.com/fiddyspence/sysctl
    On Aug 25, 2013, at 9:56 PM, opticpow wrote:

    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;
    }
    }
    }




    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@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 at Aug 26, 2013 at 11:19 pm
    Hi Ygor, of course a silly miss by me. Thanks for the heads up on the
    module, I'll check it out.

    Cheers,

    Wayne.
    On Tuesday, August 27, 2013 7:24:29 AM UTC+10, Ygor wrote:

    It should be (I think)

    subscribe => File[$config]

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

    On Aug 25, 2013, at 9:56 PM, opticpow wrote:

    Hi All,

    I'm using the ripienaar/concat<https://forge.puppetlabs.com/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;
    }
    }
    }




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

    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Gavin Williams at Aug 27, 2013 at 4:15 pm
    opticpow

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

    Cheers
    Gavin
    On Tuesday, 27 August 2013 00:19:03 UTC+1, opticpow wrote:

    Hi Ygor, of course a silly miss by me. Thanks for the heads up on the
    module, I'll check it out.

    Cheers,

    Wayne.
    On Tuesday, August 27, 2013 7:24:29 AM UTC+10, Ygor wrote:

    It should be (I think)

    subscribe => File[$config]

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

    On Aug 25, 2013, at 9:56 PM, opticpow wrote:

    Hi All,

    I'm using the ripienaar/concat<https://forge.puppetlabs.com/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;
    }
    }
    }




    --
    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.

    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jcbollinger at Aug 27, 2013 at 6:27 pm

    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

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedAug 26, '13 at 3:37a
activeAug 27, '13 at 6:27p
posts5
users4
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase