Using existing resource type via hiera without a class/module manifest.

16 views
Skip to first unread message

Kashyap Bhatt

unread,
May 19, 2014, 5:34:26 PM5/19/14
to puppet...@googlegroups.com
Hi,

I was wondering if it's possible to use an existing resource type say file, e.g. lets say following is all I need to do:

    file {'testfile':
      path    => '/tmp/testfile',
      ensure  => present,
      mode    => 0640,
      content => "I'm a test file.",
    }

Normally,
OPTION1
  • Put the resource declaration above in my site.pp. Inside a node definition like:
node my_host {
    file {'testfile':
      path    => '/tmp/testfile',
      ensure  => present,
      mode    => 0640,
      content => "I'm a test file.",
    }
}

or OPTION2
  • I would create .../my_module/manifests/init.pp and put the resource declaration in it.
  • Create my_host.yaml in appropriate directory with:
    classes:
      my_module
  • In my site.pp I will put:
    hiera_include('classes')
  • Assuming standard hiera.yaml hierarchy.
I'm wondering if there is a third option that allows me to get the best of both options:
  • No hardcoding in site.pp for my node name, catalog is decided via hiera yaml config files.
  • No separate module/class manifest containing just a 'single liner' resource declaration.

Thanks..

David Schmitt

unread,
May 20, 2014, 11:28:44 AM5/20/14
to puppet...@googlegroups.com
Hi,

On 19.05.2014 23:34, Kashyap Bhatt wrote:
> I'm wondering if there is a third option that allows me to get the best
> of both options:
>
> * No hardcoding in site.pp for my node name, catalog is decided via
> hiera yaml config files.
> * No separate module/class manifest containing just a 'single liner'
> resource declaration.

You might want to look into Crag Dunn's roles and profiles post at

> http://www.craigdunn.org/2012/05/239/

for a very reasonable take on how to structure puppet manifests beyond
the basic tactical modules.

A different take is my own repo at

> https://github.com/DavidS/dasz-configuration/tree/master/manifests/nodes

where I do not shy away from putting one-off resources directly into the
host's node file.


Regards, David
Reply all
Reply to author
Forward
0 new messages