Ask Your Question

How can I deploy stringify_facts with arrays in my modules?

asked 2016-12-20 05:29:42 -0600

updated 2016-12-20 05:29:58 -0600

I have some modules that want to use facts like $facts['os']['family'], but my clients are Puppet 3 and don't have stringify_facts turned off. I created an inifile setting to do the job, but it won't apply, because the reference to the $facts hash is causing the whole catalog compilation to give a 400 error about it not being a hash. I seem to be in a chicken and egg problem here.

Is the only way to solve this to go outside Puppet and run some scripts on my clients? How can I get them out if Puppet won't work? At present, I can't guarantee that if I remove the offending module, all clients will have applied any stringify changes before I reinstate it.

edit retag flag offensive close merge delete


I think the $facts[] hash is only available with the future_parser enabled for puppet 3 (puppet 4 is stringify_facts = false and the future is 'now' ;) )

DarylW gravatar imageDarylW ( 2016-12-20 09:55:41 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2016-12-20 09:12:52 -0600

Do a facter --version on your client.

The $facts variable came with facter major version 3.x. You have to upgrade your facter, too.

However, do turn off stringify_facts, since statements like $some_integer_fact < 42 don't cause headache anymore.

about “upgrade agent” in PP 4.0 documentation (and servers)

edit flag offensive delete link more


All my clients are capable of the setting, but I can't be sure they'll all implement it before I enable a module that requires it. Once there's a module using it in the catalogue, those clients won't be able to run Puppet at all, because their compilation will fail. My question is how to avoid this.

iainhallam gravatar imageiainhallam ( 2016-12-21 04:13:30 -0600 )edit

The only 'way to avoid it' is to migrate all of your modules to complie with stringify facts set to false (and/or future parser set to true). There are some catalog comparison tools out there that aid you in making that transition, as well as puppetmaster warnings with the latest 3.8.x

DarylW gravatar imageDarylW ( 2016-12-21 07:08:55 -0600 )edit

There was a whole track of talks on puppet4, including tips for migrating to puppet4 this year at puppetconf. I recommend

DarylW gravatar imageDarylW ( 2016-12-21 07:11:17 -0600 )edit

Well, then only include modules, which require facter v3.x on nodes, where it is installed: `if $facts != undef { include module_using_modern_facts }`

Kai Burghardt gravatar imageKai Burghardt ( 2016-12-21 08:26:09 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-12-20 05:29:42 -0600

Seen: 54 times

Last updated: Dec 20 '16