How to differ OS Versions in Modules?

20 views
Skip to first unread message

Akai

unread,
Nov 19, 2016, 3:56:38 PM11/19/16
to Puppet Users
Hello together,

in one of my modules i want to do different variable initialization depends by the version of the used operating system.
I found examples who show of to differ between Debian and OpenBSD for example, but in my case, i want to differ between Windows Server 2012R2 and Windows Server 2016 - so they are both Windows operating Systems. Is it possible to differ by the version number or sth. ? If yes, how i do that?

thanks for any help

best regards

Akai

Rob Nelson

unread,
Nov 19, 2016, 5:23:06 PM11/19/16
to puppet...@googlegroups.com
You can use facts and 'if' conditionals or 'case' selectors and test the OS facts. IIRC that would be kernel (windows or Linux) and operatingsystemmajrelease (2008, 2008R2, etc.) in puppet 3 and deeper within the $facts['os'] on puppet 4 or 3 with future parser and structured facts - but double check that. You can run `facter -p` on a sample node to see what facts exist that contain what you are looking for.

You might also review a module like puppetlabs/ntp to see some examples of using conditionals to set defaults, in the params class. The latest version is puppet 4 only but the v4.x train of the module supports puppet 3.

Please note, puppet 3 support ends on 12/31/2016 so please start targeting puppet 4 only or ensure you are future proofing so you can transition from 3 to 4 quickly.

--
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/9079a58c-b9bf-476e-b7e1-c43f45a50442%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Rob Nelson
Reply all
Reply to author
Forward
0 new messages