Ask Your Question
0

How do I check for the version of Windows?

asked 2016-06-30 19:39:30 -0500

Conventional gravatar image

I have a class of Windows machines that includes Windows 10 desktops, Windows Server 2008 and WIndows Server 2012 machines. I'd like my multi-part manifests to run against every Windows machines. I would like subparts to include modules that should be ran against certain versions of Windows but not other versions of Windows. That is, I want a given module in a manifest to run against Windows 10 desktops, a different portion of the manifest to run against Windows Server 2012 machines exclusive of Windows other servers/desktops. How do I do this without changing the class of servers? I'd like to keep one long manifest.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-07-01 02:26:01 -0500

rajeevsharma gravatar image

So you are looking for if-else or switch case statement to define your version specific code. This is something can be done using facters. For every windows node your puppet master is aware of there platform, os, version etc. and they can be access in the code using pre-defined facter variable. E.g.

if ($operatingsystemrelease == "2008 R2")
{
 <Your code for 2008 version>
}
else
{
<Your code for other versions>
}

I hope this might help. Reference: https://docs.puppet.com/puppet/latest...factsandbuiltinvars.html

edit flag offensive delete link more

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-06-30 19:39:30 -0500

Seen: 81 times

Last updated: Jul 01 '16