Accessing the list of classes assigned to a node from within puppet

29 views
Skip to first unread message

John Warburton

unread,
Aug 7, 2019, 9:48:24 PM8/7/19
to Puppet Users
Hi Everyone

Back in the day of 2.x/3.x, I used to access the "classes" top scope variable and dump into templates - like this.

I can't see to find the equivalent in puppet 6.x. Nothing in the built in variables doc

Am I looking in the wrong place or do I have to try and access through the internal API?

Thanks

John

Dan White

unread,
Aug 7, 2019, 11:11:28 PM8/7/19
to puppet...@googlegroups.com
How about a variation on this :
# In site.pp, outside of any node definitions and below any top-scope variables: lookup('classes', Array[String], 'unique').include

Lose the “include” and you have :
$class_list = lookup('classes', Array[String], 'unique')

—————————————————————————————————-

"Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."

Bill Waterson (Calvin & Hobbes)

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/230b487d-b9ae-42c3-a686-826a5c8caa89%40googlegroups.com.

John Warburton

unread,
Aug 7, 2019, 11:39:41 PM8/7/19
to puppet...@googlegroups.com
Thanks Dan

But we are not using an ENC, so "classes" is not set. The lookup in site.pp yields:
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Function lookup() did not find a value for the name 'classes'

I am programatically looking for the content of /opt/puppetlabs/puppet/cache/state/classes.txt

Thanks for looking

Regards

John



--
John Warburton
Ph: 0417 299 600
Email: jwarb...@gmail.com
Reply all
Reply to author
Forward
0 new messages