Ask Your Question
0

How to access application level variables in Puppet

asked 2016-09-27 13:34:02 -0500

puser gravatar image

I know this question can be open to interpretation so I will ask for specifics.

I am leveraging Puppet to keep some application level variables and settings in check. The problem I am having is a lot of these variables are not set in facts like things like operatingsystem, hostname, ipaddress, etc. I am then having trouble trying to figure out how to leverage puppet to create variables to act on.

For example, I have some servers that are running different versions of an application and so I need to be able to figure out what version is running on the server. How can I do this?

My first thoughts are that since these facts are not provided in the standard facts list that I should create facts of my own that I can leverage and so I am doing something like the following:

module_name
|
|---manifests
|---files
|---examples
|---facts.d
   |---script.sh

In my script.sh I am executing linux commands to get variables from the application. and then echoing them out in the format

key=value

So where the application version is stored I would find that location and then echo out the version. Then at runtime I can use a variable like $app_ver to make specific configuration changes. Such as

app_ver=1.0.8
java_ver=1.7
  1. Is this the correct way of defining external facts?
  2. Are there standard ways of getting Application-Level details?
  3. When puppet applies on a given app server, will the script.sh run, provide facts and then make those variables available to the puppet master to determine config changes?
  4. Will the computation in the script.sh file have to run on every server that matches this class?
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
2

answered 2016-09-30 15:25:01 -0500

lavaman gravatar image

You're coming at things the wrong way. Puppet should not determine which version of an app is running on a machine. Puppet should be used to ensure a particular version of an app is running.

What I mean is, you should have puppet installing a particular version of an app, not trying to figure out which version is running. That way, you pass the version you want into puppet as a parameter value that you can use for whatever you need in your puppet code.

edit flag offensive delete link more

Comments

1

This would be my suggestion as well.

DarylW gravatar imageDarylW ( 2016-10-03 12:29:00 -0500 )edit
2

answered 2016-09-27 21:20:31 -0500

lupin gravatar image

updated 2016-09-27 21:27:28 -0500

Is this the correct way of defining external facts?

Yes - that's one way .

Are there standard ways of getting Application-Level details?

Through facts or using pre-defined variable value.

When puppet applies on a given app server, will the script.sh run, provide facts and then make those variables available to the puppet master to determine config changes?

Yes, given that the script is executable and will output a key=value pair. You can verify the customs facts from one of your node and then do a facter -p key - where key is the key in key=value pair., ie. app_ver.

Will the computation in the script.sh file have to run on every server that matches this class?

The script will run on every node but facts will only come up if your script have an output.

Hth, Lupin

edit flag offensive delete link more
0

answered 2016-10-03 12:36:47 -0500

@lavaman Though wouldn't it be correct, that if the OP is using puppet to ensure that app is installed and at least version XX.x. Then using facts he/she would be able to determine what systems are running what version and output it to a management viewable chart. I know I use the ability to say "at least version XX.x" when dealing with security issues. That way when I do do an update puppet doesn't block the update at some point in the future when XX.y is released. Or, did I misunderstand your point?

edit flag offensive delete link more

Comments

I have seen such facts used for update paths for modules, but you usually are still supplying what version you want it to be. https://github.com/voxpupuli/puppet-jira/blob/master/manifests/init.pp#L193:L200

DarylW gravatar imageDarylW ( 2016-10-04 14:38:38 -0500 )edit

And for completeness here is the fact they have for populating that information https://github.com/voxpupuli/puppet-jira/blob/master/templates/facts.rb.erb

DarylW gravatar imageDarylW ( 2016-10-04 14:40:40 -0500 )edit

That's dependent on how your package manager works. Many of them let you use that sort of construct for specifying dependencies, but don't allow you to install a package that way, so it's probably best to specify a particular version to be installed.

lavaman gravatar imagelavaman ( 2016-10-04 16:30:30 -0500 )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

Stats

Asked: 2016-09-27 13:34:02 -0500

Seen: 88 times

Last updated: Oct 03 '16