Syntax of a class reference in Hiera

26 views
Skip to first unread message

Stephen Kenny

unread,
Mar 12, 2019, 1:46:41 PM3/12/19
to Puppet Users

I want to create a directory that will contain NFS mount points.  Therefore, it makes
sense to have it in place before any of the NFS-related Puppet stuff.  I can do it
in either of two ways.

1. In a manifest, with a regular file resource, which contains the line

          before => Class['nfs'],

No problem there.   

2. If I try to do this via a lookup of equivalent Hiera data, I see
    something unusual - or maybe just something I don't understand properly.

If my Hiera data looks like this:

 '/primary':
    ensure: 'directory'
    mode:   '0755'
    owner: 'root'
    group: 'root' 
    before: 'Class[nfs]'

 - I get an error when I run the agent on the node: "Server Error: Invalid relationship: 
File[/primary] { before => Class[nfs] }, because Class[nfs] doesn't seem to be in the catalog".

But if I change "nfs" to "Nfs" - i.e .capitalize the first letter of the class *name*,
it works.

I get that resource references should always be capitalized
(require => File['/etc/sysctl.d/recommended.conf']  and so on), but what is going on with
the necessity for capitalizing the resource _name_ - "Nfs" in my example - when
trying to accomplish the job via lookup and Hiera?

Thanks for any enlightenment,

Stephen Kenny
School of Computer Science
Trinity College
Dublin 
Ireland

Henrik Lindberg

unread,
Mar 12, 2019, 2:42:01 PM3/12/19
to puppet...@googlegroups.com
These two lines are very different:

before => Class['nfs']
before: 'Class[nfs]'

The first is a real data type - a reference to a Class with the title
(i.e. name of class) 'nfs'. The second is a String that is interpreted /
parsed by the processing for the "before" meta parameter. Apparently it
does not get it quite right. Please file a ticket in Puppet's JIRA for
the PUP project.

Before doing this though, if you are on an older version this may have
been fixed already as the problem sounds vaguely familiar, so please try
on at least a 5.x version of puppet.

best
- henrik

>
> Stephen Kenny
> School of Computer Science
> Trinity College
> Dublin
> Ireland
>
> --
> 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
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/2f41b686-c41c-470f-a8a4-be07d1f5f854%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/2f41b686-c41c-470f-a8a4-be07d1f5f854%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

Stephen Kenny

unread,
Mar 13, 2019, 6:16:39 AM3/13/19
to Puppet Users

We're running Puppet 6 (server and agents), so I will file that ticket today.
Many thanks for the clarification.

Stephen
Reply all
Reply to author
Forward
0 new messages