Elegant way to supply facts to `puppet apply`

42 views
Skip to first unread message

Abhijeet Rastogi

unread,
Nov 26, 2018, 1:51:57 PM11/26/18
to Puppet Users
Hi everyone,


puppet lookup command has a nice --facts option which accepts a structured json/yaml file to upload files.

Why does that option not exist for puppet apply? Is the environment variable the only option?

Puppet version: 6.0.4

Thanks,
Abhijeet

Henrik Lindberg

unread,
Nov 26, 2018, 2:14:27 PM11/26/18
to puppet...@googlegroups.com
On 2018-11-23 03:27, Abhijeet Rastogi wrote:
> Hi everyone,
>
>
> puppet lookup command has a nice --facts option which accepts a
> structured json/yaml file to upload files.
>
> Why does that option not exist for puppet apply? Is the environment
> variable the only option?
>

There is a way to make it read other facts than the default getting the
facts for the node apply is running on. To use that you need to change
the facts terminus setting
https://puppet.com/docs/puppet/5.3/indirection.html#yaml-terminus-1

Warning: That is not easy to use.

For puppet lookup we wanted something simpler and choose to expose the
option directly as it is a common use case to experiment with lookup CLI
and different facts.

Suggest you file a ticket with a feature request for puppet apply.

Best,
- henrik

> Puppet version: 6.0.4
>
> Thanks,
> Abhijeet
>
> --
> 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/c9c7ea63-cd97-4dbc-9c45-ee78e5cb9d4b%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/c9c7ea63-cd97-4dbc-9c45-ee78e5cb9d4b%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/

Eric Sorenson

unread,
Nov 27, 2018, 8:15:10 AM11/27/18
to Puppet Users
You could put that same yaml or json in /etc/puppetlabs/facter/facts.d and the whole data structure will be available under $facts ...

--eric0

jcbollinger

unread,
Nov 27, 2018, 9:16:08 AM11/27/18
to Puppet Users

On Monday, November 26, 2018 at 12:51:57 PM UTC-6, Abhijeet Rastogi wrote:

puppet lookup command has a nice --facts option which accepts a structured json/yaml file to upload files.

Why does that option not exist for puppet apply? Is the environment variable the only option?



puppet apply presumes that you want to use the facts for the local node, since that's the node to which the generated catalog will be applied.  It therefore uses the same mechanism to determine the appropriate facts as the agent does, which, by default, is by running facter.

puppet lookup has a different orientation.  It is an alternative to a server-side mechanism, rather than a client-side one.  Therefore, it does not assume that you want to use the facts for the current node.  The --facts option provides a convenient mechanism for communicating multiple facts and structured facts to it, since it cannot rely on being fed the facts internally by the catalog builder.

Other responses have already pointed out that puppet apply does afford you other alternatives, which you can access by manipulating the facts_terminus setting. You should be able to do that either in the config file or on the command line.  In particular, there is a "yaml" facts terminus, though it's unclear to me how it chooses the file from which to read facts.


John

Reply all
Reply to author
Forward
0 new messages