Write a simple manifest

Puppet manifest files are lists of resources that have a unique title and a set of named attributes that describe the desired state.

Before you begin:
You need a text editor, such as Visual Studio Code (VSCode), to create manifest files. Puppet has a VSCode extension that supports syntax highlighting of the Puppet language. Editors like Notepad++ or Notepad don't highlight Puppet syntax, but you can use them to create manifests.

Manifest files are written in Puppet code, a domain specific language (DSL), and define the desired state of system resources, such as file, users, and packages. Puppet compiles these text-based manifests into catalogs, and uses those catalogs to apply configuration changes.

  1. Create a file named file.pp and save it in c:\myfiles\
  2. With your text editor of choice, add the following code to the file:
    file { 'c:\\Temp\\foo.txt':
      ensure   => file,
      content  => 'This is some text in my file'
    }

    Note the following details in this file resource example:

    • Puppet uses a basic syntax of type { title: }, where type is the resource type. In this case, the resource type is file.
    • The vvalue before the : is the resource title. In this example, the title is C:\\Temp\\foo.txt. The file resource uses the title to determine where to create the file on disk. Resource titles must always be unique within a given manifest.
    • The ensure parameter is set to present to make sure the file exists on disk and create the file if it doesn't already exist. For file type resources, you can also use the value absent, which removes the file from disk if it exists.
    • The content parameter is set to This is some text in my file, which writes that value to the file.