Jira (PUP-8373) Lookup CLI should use RBAC token if available for PuppetDB

3 views
Skip to first unread message

Sean Millichamp (JIRA)

unread,
Jan 19, 2018, 3:02:03 PM1/19/18
to puppe...@googlegroups.com
Sean Millichamp created an issue
 
Puppet / Bug PUP-8373
Lookup CLI should use RBAC token if available for PuppetDB
Issue Type: Bug Bug
Assignee: Thomas Hallgren
Components: Hiera & Lookup, PuppetDB
Created: 2018/01/19 12:01 PM
Priority: Normal Normal
Reporter: Sean Millichamp

In order to facilitate use of the CLI puppet lookup by non-root users who want to perform a lookup in terms of a particular node without having to have a fully-trusted and PuppetDB-whitelisted certificate, it would be great if lookup would look for and use any PE RBAC tokens to obtain access when getting the facts from PuppetDB.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db)
Atlassian logo

Eric Sorenson (JIRA)

unread,
Jan 19, 2018, 4:59:03 PM1/19/18
to puppe...@googlegroups.com
Eric Sorenson commented on Bug PUP-8373
 
Re: Lookup CLI should use RBAC token if available for PuppetDB

Michael Smith Are there any other Ruby cli tools that use the token auth system? (I don't think there are, which would complicate this a lot because without existing language bindings we'd have to write that first to implement this)

Michael Smith (JIRA)

unread,
Jan 19, 2018, 5:05:02 PM1/19/18
to puppe...@googlegroups.com

Michael Smith (JIRA)

unread,
Jan 19, 2018, 5:08:03 PM1/19/18
to puppe...@googlegroups.com
Michael Smith commented on Bug PUP-8373

It doesn't appear to be complicated. Load the token file from disk, pass it as part of an X-Authentication header. It could be pulled into a library that would be 10-20 lines of Ruby code.

Sean Millichamp (JIRA)

unread,
Jan 19, 2018, 5:10:02 PM1/19/18
to puppe...@googlegroups.com

It would be super great if the location of the token file could be specified. I looked for a puppet.conf option for it, but of course there wasn't one.

Thomas Hallgren (JIRA)

unread,
Jan 22, 2018, 7:37:04 AM1/22/18
to puppe...@googlegroups.com

Thomas Hallgren (JIRA)

unread,
Jan 22, 2018, 7:41:02 AM1/22/18
to puppe...@googlegroups.com
Thomas Hallgren commented on Improvement PUP-8373
 
Re: Lookup CLI should use RBAC token if available for PuppetDB

Given that this is new design and might add options to the CLI which might be of interest for other commands as well, I'd like to see a more concrete spec of what the implementation should entail. UX might have opinions on this. Should this be consistently implemented and affect other commands than lookup?

Thomas Hallgren (JIRA)

unread,
Jan 22, 2018, 7:42:01 AM1/22/18
to puppe...@googlegroups.com
Thomas Hallgren assigned an issue to Unassigned
 
Change By: Thomas Hallgren
Assignee: Thomas Hallgren

Michael Smith (JIRA)

unread,
Jan 22, 2018, 12:25:02 PM1/22/18
to puppe...@googlegroups.com

Sean Millichamp (JIRA)

unread,
Jun 28, 2018, 9:52:04 AM6/28/18
to puppe...@googlegroups.com

I am in the process of implementing a custom internal facts indirector for PuppetDB with RBAC along with a custom version of "lookup" to basically solve this for our site and as part of this there are a couple of more aspects to it that I hadn't considered originally.

My overarching outcome from getting this ticket implemented as I originally outlined was so that any non-root user could invoke "puppet lookup" with a RBAC token granting them access to PuppetDB (which as a non-root user they of course otherwise wouldn't have even on a Puppetmaster due to lack of permissions on the node's private key), pointed to an environment with a hiera configuration they could read so that the values would be correctly interpolated and resolved as they would during a root-based "puppet lookup".

However, in addition to the token I found that I needed a PuppetDB configuration as well. As a non-root user it was trying to read my configurations from ~/.puppetlabs/etc/puppet. In my setup I have ended up looking for and reading the same configuration files that the pe-client-tools uses. Setting configuration per-user in ~/.puppetlabs/etc/puppet and leveraging the normal Puppet PuppetDB indirector configuration was a non-starter, the command needed to just work for an arbitrary user on the system with a token.

While just implementing support for the PE RBAC token would be a step in the right direction, I'm not sure how it would be useful without also providing support for more of the whole end-to-end I've described.

 

This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Michael Smith (JIRA)

unread,
Jun 28, 2018, 12:17:05 PM6/28/18
to puppe...@googlegroups.com
Michael Smith commented on Improvement PUP-8373

On a PE master, the puppet-query configuration (pe-client-tools) lives at /etc/puppetlabs/client-tools/puppetdb.conf. Is there a problem with using that location for each user?

If you want the login token to be shared by all users on the system (potentially a larger security concern, as that token may have more than just PuppetDB permissions) you would need to set the token-file location and make that file readable by all users.

Otherwise, each user can use the shared config but will need to separately login via puppet-access, and their token file will be stored in a user directory.

Sean Millichamp (JIRA)

unread,
Jun 28, 2018, 12:25:04 PM6/28/18
to puppe...@googlegroups.com

In my implementation I'm reading the global puppet-query configuration file as well as the per-user configuration file (/.puppetlabs/client-tools/puppetdb.conf) and I'm currently only using the per-user token file in /.puppetlabs/token, though I can't rule out that I might want to use something in, say, a CI job where I'd want to pass a token path somehow. But I'm not tackling that for this first version I'm working on.

 

Michael Smith (JIRA)

unread,
Jun 28, 2018, 12:27:04 PM6/28/18
to puppe...@googlegroups.com
Michael Smith commented on Improvement PUP-8373

Also, Bolt has implemented the PuppetDB client at https://github.com/puppetlabs/bolt/tree/master/lib/bolt/puppetdb. Seems like an opportunity for a new gem.

Josh Cooper (JIRA)

unread,
Apr 5, 2019, 1:28:03 AM4/5/19
to puppe...@googlegroups.com

Sean Millichamp (Jira)

unread,
Apr 17, 2020, 8:16:03 AM4/17/20
to puppe...@googlegroups.com
Sean Millichamp commented on Improvement PUP-8373
 
Re: Lookup CLI should use RBAC token if available for PuppetDB

I saw a flurry of `puppet lookup` related ticket updates and went to look to see if there was an issue in for this, only to find out that I had put one in!

To Michael Smith's suggestion for a new gem opportunity, Voxpupuli has puppetdb gem (to which I added token support quite a which back). It consults `/etc/puppetlabs/client-tools/puppetdb.conf` and `/.puppetlabs/client-tools/puppetdb.conf` to find the path to the CA cert and `/.puppetlabs/token` for the PE RBAC token.

This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Josh Cooper (Jira)

unread,
Aug 18, 2021, 6:11:02 PM8/18/21
to puppe...@googlegroups.com
Josh Cooper commented on Improvement PUP-8373

The difficulty is lookup uses the indirector to retrieve the node. In PE this calls the classifier terminus, which also uses the indirector to retrieve facts using the terminus provided by puppetdb. So we would need to provide REST specific options in the indirector request (and try to thread the credentials through) or have the puppetdb terminus load the credentials itself. The latter seems doable to me.

This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages