On Tue, Feb 5, 2013 at 2:56 AM, Reid Vandewiele <notifications@github.com>wrote:

> In manifests/access.pp:
>
> > @@ -15,7 +15,15 @@
> >      fail("Permission must be + or - ; recieved $permission")
> >    }
> >
> > -  realize Concat['/etc/security/access.
> conf']
> > +  $access_conf = "/etc/security/access.conf"
> > +
> > +  realize Concat[$accessr_.conf]
> > +
> > +  concat::fragment { "access_header":
> > +    target  => $access_conf,
> > +    order   => 01,
> > +    content => template("pam/header.erb"),
> > +  }
>
> The defined() means of solving this problem would be to:
>
> if ! defined(Concat::Fragment['access_header']) {
>   concat::fragment { 'access_header':
>     target  => $access_conf,
>     order   => 01,
>     content => template('pam/header.erb'),
>   }
> }
>
> This would then create the resource the first time an instance of the
> defined type was created, but on subsequent defined type resource instances
> the defined() function would return true and the concat::fragment would
> not be re-created.
>
> Alternatively, it could be turned into a virtual resource like the Concat
> resources themselves. I.e. in init.pp add
>
> @concat::fragment { 'access_header':
>   target  => $access_conf,
>   order   => 01,
>   content => template('pam/header.erb'),
> }
>
> And then here just use
>
> realize(Concat::Fragment['access_header'])
>
> I would suggest doing the latter for now for consistency sake but then
> turn around and convert all three virtual resources to use the defined()pattern for clarity' sake in a follow-up pull request and remove the
> init.pp file (since it would then be unnecessary).
>
>
I have the latter working and tested as virtual resources,I was about to
try that last night but didn't have a chance. I also didn't like having a
header for both access and limits so I've defined a single header and am
setting the target via a collection. I don't see how init.pp becomes
unnecessary since all the subclasses will pull those resources.

Thanks and expect some follow-up pull request shortly!

  @concat::fragment { "header":
    target  => undef,
    order   => 01,
    content => template("pam/header.erb"),
  }

 Concat::Fragment <| title == 'header' |> { target => $limits_conf }