Running commands

The exec resource type is used to execute commands. The command in the exec resource must be able to run multiple times without any problems or harm. If it causes problems, it must be limited with conditions and run only when these conditions are met.

exec can directly execute .com, .bat, .exe, and so on. Also, it can log the output and the exit status. If you want to run the shell built-in commands in this case, Puppet does not support these commands directly. Assuming that you want to use the echo command, you need to use it with cmd and the command should look as follows: cmd.exe /c echo helloworld. Now let's check the most basic definition:

exec { 'execname':
command => 'command to execute',
}

As you can see, the simplest exec ...

Get Learning Puppet for Windows Server now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.