Ask Your Question

Make a different exec for diferents Windows O.S. [closed]

asked 2017-11-29 05:50:52 -0600

alejandrol gravatar image

I want to execute a command if the OS is Windows 7 and another command if is another Windows OS. How can i make this on a single init.pp? I just started with puppet some days ago and i don't know how to do complex puppets.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by alejandrol
close date 2017-12-05 15:00:30.107965

1 Answer

Sort by ยป oldest newest most voted

answered 2017-11-29 07:52:51 -0600

stivesso gravatar image

Hi alejandrol,

The way to achieve this is quite simple, you just have to set some condition (a classic if/else) on Puppet Facts (Click here to get more details on what facts are). See an example of such condition below (in init.pp)...

class test {

  # You can use the command facter os to check all facts related to os
  if $::facts['os']['release']['major'] == '7' {
    exec { "/bin/ls":} # The command you want to run on 7
  else {
    exec { "/bin/ls":} # The command you want to run on other windows release

edit flag offensive delete link more


It worked thx a lot!

alejandrol gravatar imagealejandrol ( 2017-11-30 02:31:41 -0600 )edit

Hi Alejandrol, It would be great if you mark this as solved then (and possibly upvote the answer...)

stivesso gravatar imagestivesso ( 2017-12-05 13:23:32 -0600 )edit

I forgot to do that sorry my bad! Thx a lot!

alejandrol gravatar imagealejandrol ( 2017-12-05 15:01:00 -0600 )edit

Question Tools

1 follower


Asked: 2017-11-29 05:33:01 -0600

Seen: 16 times

Last updated: Nov 29 '17