Re: How to get $title of type "file" inside of a class?

58 views
Skip to first unread message

Nick Fagerlund

unread,
Aug 1, 2012, 3:58:36 PM8/1/12
to puppe...@googlegroups.com
You can't do this with a normal resource type -- $title will always be the title of the surrounding container.

So the solution is to interpose another container. Make a defined type that just acts as a macro here.

# /etc/puppetlabs/puppet/modules/monit/manifests/rcfile.pp
define monit::rcfile {
        file { $title:
                path => "/opt/monit/etc/conf.d/$title.
rc",
                ensure => file,
                content => template("monit/$title.rc.erb"
),
                before => Service['monit'],
        }
}

# /etc/puppetlabs/puppet/modules/monit/manifests/monit.pp

...
...
monit::rcfile { $server_types: }


See?

Shoujin Wang

unread,
Aug 2, 2012, 12:24:30 PM8/2/12
to puppe...@googlegroups.com
Thanks very much Nick!
It works for me.

Regards,
Autumn Wang



--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/puppet-dev/-/2wtAsMdZzUcJ.

To post to this group, send email to puppe...@googlegroups.com.
To unsubscribe from this group, send email to puppet-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Reply all
Reply to author
Forward
0 new messages