Confine a custom fact by file existence

1,265 views
Skip to first unread message

Thomas Müller

unread,
Oct 22, 2015, 4:00:55 AM10/22/15
to Puppet Users
Hi

I know it's possible to confine a fact by other facts like "confine :operatingsystem => :Fedora". 

But i have a fact which requires a binary from a rpm package which is only installed by puppet. For the first puppet run tries to execute the not-yet installed binary and fails.

is it possible to use something like this to confine based on existing files?

confine File.exists?(/path/to/binary)


Or what is the best practice for such facts which rely on things installed by puppet manifests?

- Thomas

jcbollinger

unread,
Oct 22, 2015, 8:38:37 AM10/22/15
to Puppet Users


On Thursday, October 22, 2015 at 3:00:55 AM UTC-5, Thomas Müller wrote:
Hi

I know it's possible to confine a fact by other facts like "confine :operatingsystem => :Fedora". 

But i have a fact which requires a binary from a rpm package which is only installed by puppet. For the first puppet run tries to execute the not-yet installed binary and fails.

is it possible to use something like this to confine based on existing files?

confine File.exists?(/path/to/binary)




Why, yes, but the syntax is:

confine :exists => "/path/to/binary"

, as documented among the provider development documentation.


John

David Schmitt

unread,
Oct 22, 2015, 9:18:18 AM10/22/15
to puppet...@googlegroups.com
Facter, not providers, John. Those are, sadly, different beasts.


Cheers, David

Peter Huene

unread,
Oct 22, 2015, 11:41:24 AM10/22/15
to puppet...@googlegroups.com
Hi Thomas,

On Thu, Oct 22, 2015 at 1:00 AM, Thomas Müller <tho...@chaschperli.ch> wrote:
Hi

I know it's possible to confine a fact by other facts like "confine :operatingsystem => :Fedora". 

But i have a fact which requires a binary from a rpm package which is only installed by puppet. For the first puppet run tries to execute the not-yet installed binary and fails.

is it possible to use something like this to confine based on existing files?

It is possible, as the `confine` method also takes a block:

```
Facter.add(:foo) do
  confine do
    File.exist? '/path/to/binary'
  end

  setcode do
    'bar'
  end
end
```
 

confine File.exists?(/path/to/binary)


Or what is the best practice for such facts which rely on things installed by puppet manifests?

- Thomas

--
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/3cc22965-5c92-49da-a370-36589d6c0dc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages