Book Image

Learning Puppet for Windows Server

By : Fuat Ulugay
Book Image

Learning Puppet for Windows Server

By: Fuat Ulugay

Overview of this book

Table of Contents (15 chapters)
Learning Puppet for Windows Server
About the Author
About the Reviewers

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 definition requires only one attribute, which is command. This command will execute every time Puppet runs. The default running interval for Puppet is 30 minutes. So, if the default interval is not changed, it will be executed every 30 minutes...