Hot answers tagged

6 votes

Access arrays/hashes in facter 2 facts

For example like this: notify { $::os[release][major] : } Note that you need to set the option stringify_facts to false for this to work (default as of writing with Puppet 3.7.1: true).
user avatar
  • 17.3k
5 votes
Accepted

Puppet: Pass facter value to class (sensu puppet module)

Single quotes prevent variables from getting expanded, so it should be like this: subscriptions => [ 'sensu-default', 'centosJenkinsMaster', $::fqdn, ], I'd recommend you to use ...
user avatar
  • 17.3k
5 votes
Accepted

Trouble using hiera in masterless setup and getting values set for classes

Try this: hiera cluster '::nodetype=diskless' See fact-sources documentation
user avatar
  • 366
4 votes
Accepted

Puppet directory environments and the $environment variable

The $environment variable isn't technically a fact - it is set by the agent from its puppet.conf, instead of a fact. You'll need to edit it in the agent's puppet.conf instead of facts.d. An ENC can ...
user avatar
4 votes

"Unsupported osfamily: Linux" when trying to install Apache using Puppet

Don't use Amazon Linux. The Puppet Labs Apache module is not compatible with Amazon Linux. You will need to use one of the distributions which it is compatible with, or create your own Puppet module.
user avatar
3 votes

how i do use puppet variable in facter custom facts

If you want to use a manifest variable in a custom fact, you can't. This is because facts are evaluated on the client before the catalog (collection of manifests) is compiled. So at the point that ...
user avatar
  • 4,611
3 votes

Extract nested hash facts from puppet's facter command-line tool. How?

Nested fact values can be viewed in the CLI by using a dot between variables e.g. to retrieve os['release']['minor'] in the CLI type: facter os.release.minor EDIT: Apperently this only works with ...
user avatar
  • 169
3 votes

"Unsupported osfamily: Linux" when trying to install Apache using Puppet

After looking at it with a fresh pair of eyes today, I've found that Facter v1.7.0 includes a fix that classifies Amazon Linux as "RedHat" correctly: https://github.com/puppetlabs/facter/commit/...
user avatar
  • 225
3 votes
Accepted

Facter - custom fact, returns empty data set when invoked by Puppet agent

This is actually a bug in Puppet 3.6, apparently. As an aside, note that using agents that are newer than the master is not generally supported.
user avatar
  • 3,053
2 votes
Accepted

Why aren't my puppet variables getting assigned by Vagrant's puppet.facter options?

Thanks to @SebastianWeigand, a coworker of mine, I've found that the use of cammel-case in the variable names was causing the problem. Switching to "variableone" and "variabletwo" in both sides fixed ...
user avatar
2 votes

Access arrays/hashes in facter 2 facts

You can access facts from manifests by using hashes, like this: notify { $::os['release']['major']: } Example: # puppet apply -e 'notify { $::os['release']['major']: }' Notice: Compiled catalog for ...
user avatar
  • 5,127
2 votes

Access arrays/hashes in facter 2 facts

Should be possible access it as usual hash datatype. Example: $myhash = {os => { "name"=>"CentOS", "family"=>"RedHat", "release"=>{ ...
user avatar
  • 349
2 votes
Accepted

Puppet - determine if another host is reachable?

So this is for swapping something in via a config variable in a template? I think the best way to do this would be to write a custom fact in Ruby that does the speed and reachability testing, then ...
user avatar
2 votes
Accepted

Filter puppet pluginsync

There is no way to filter plugins. But as you say in your comment, you need to write the facts/types to handle the OS they're running on. For types and providers you exit early. For facts you can use ...
user avatar
  • 2,979
2 votes
Accepted

Can't install Facter 1.7.0 on Amazon Linux using PuppetLabs Yum repositories

The packages are not showing up as updates very probably because of priority settings. You could fix that by: echo -e "[main]\nenabled = 0" > /etc/yum/pluginconf.d/priorities.conf However, ...
user avatar
  • 17.3k
2 votes

Blank value in custom puppet fact

For the record! Facter.add(:myhost) do confine :kernel => "Linux" fh = File.open('/etc/enc_params.conf') fh.each_line do |line| if line =~ /\Amyhost.*\s(\w+)\Z/ r = $1 setcode ...
user avatar
  • 318
2 votes
Accepted

Facter (2.4.4) sets ipaddress to docker0 and not the ethernet interface (CentOS7)

This is a problem with the default ipaddress fact, it's a bit dumb. We use a custom one called default_if which is based on the default route (works on Debian, may need adapting to CentOS): Facter....
user avatar
  • 2,392
2 votes

Modify puppet nodes.pp with regex based on network (facter) subnet coverage - needs peer review

This will not work as shown. First, the regex is no good, but also node matchers are based on certname, which is the FQDN of the host. That's not to say you can't do it, but it would require some more ...
user avatar
  • 12.3k
2 votes
Accepted

Facter does not show custom Puppet facts

Quoting from facter --help: -p, --puppet (Deprecated: use puppet facts instead) Load the Puppet libraries, thus allowing Facter to load Puppet-specific facts. With current ...
user avatar
  • 166
1 vote
Accepted

How to use custom facts with rspec Puppet

In your spec/spec_helper.rb file you can add the following: RSpec.configure do |c| c.default_facts = { :pskkey_generate => '...' } end See https://github.com/rodjek/rspec-puppet#default_facts
user avatar
  • 4,611
1 vote

puppet: fact in manifest with dot

Accessing facts has changed in version 4. Try accessing the fact via the $facts hash, $facts['ipaddress_enp0s8.25'], instead of using a top scope variable. You can still use top scope variables to ...
user avatar
  • 11
1 vote
Accepted

Use Puppetdb for ENC variable?

Can I do this, Yes that is possible. One could create a custom fact in a puppet module, e.g. run some ruby code in order to get the version of installed software: module_name/lib/facter/customfact....
user avatar
  • 5,691
1 vote

Use Puppetdb for ENC variable?

puppet facts are always informations sent by the agent to the master. Thus you can't set a fact on the puppetmaster side. But, you have the option to configure the agent environment with puppet ...
user avatar
  • 255
1 vote
Accepted

How to access facter GCE metadata

The error gce is not a hash or array suggests you're on Puppet 3.x (rather than 4.x) which treats all facts as strings, so to access the value inside the hash you will need to turn off the ...
user avatar
1 vote

Extract nested hash facts from puppet's facter command-line tool. How?

That's not what facter is supposed to do. If you use it within puppet as expected, you can access every fact separately. To a certain degree, you can work around this if you use JSON output: ...
user avatar
  • 96.6k
1 vote

Facter: Custom-fact-script "was parsed but returned an empty data set"

The official documentation helped me realize the script must produce output in the form of key=value. Thus, a single script can generate many different sets of information. (Now I realize why facter ...
user avatar
  • 432
1 vote

"Unsupported osfamily: Linux" when trying to install Apache using Puppet

The problem seems to be in the file /usr/lib/ruby/site_ruby/1.8/facter/osfamily.rb which ends up using the osoperatingsystem as osfamily in the case of Amazon Linux. Line 19 is: when "RedHat", "...
user avatar
1 vote

Filter puppet pluginsync

Puppet itself does not support filtering the lists of plugins to be synced. However, you can patch puppet to support this using the pluginsync_filter patch from CERN. Afterwards you can whitelist ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible