Previous post: How to Install Puppet Agent in Windows
In this post we will create a simple class. We will also make the necessary configuration so that the classes can be seen in Foreman. At the moment there is no class defined.
Open a terminal window in your Puppet server and go to folder “/etc/puppet/modules”. This is the place for your definitions. As a starting example we will only create a simple class which installs vim text editor.
Here are the steps:
– First create a folder with the name of your class.
– Go into the folder and create a “manifests” folder.
– Go into manifests folder and create a file named “init.pp”
Here is the contents of init.pp
After saving the file. We will continue with foreman. Go to foreman web user interface and
"Configure -> Puppet Classes“. And click on “
Import from yourserver”
After that you will see environments “
common, development, production, example_env“. You can import and activate your class for different environments. In this example I will do it only for production. After clicking “
Update” you will see that the class is imported.
Now the last step is to assign it to hosts. Select “
Hosts -> All hosts” from the menu. You will see the list of hosts. Select “
Edit” one of them.
Go to Puppet Classes tab and select the class as seen in the screenshot below:
After that submit the changes. Now you can go to the host and run “
puppet agent -t” to see what happens.
As you can see it installed the vim package successfully.