Puppet works by allowing users to define their desired system configuration in a declarative language called Puppet DSL (Domain Specific Language). This language is used to create Puppet manifests, which are files with instructions for Puppet to follow.
For example, if you wanted to install the Apache web server on a server, you could create a Puppet manifest that contains the following code:
package { ‘apache2’:
ensure => installed
}
This code tells Puppet to install the Apache2 package if it is not already installed.
Once the manifest is written, the user can then run Puppet on the server to execute the instructions in the manifest. Puppet will then check the server to see if Apache is installed, and if not, it will install it.
In addition to installing packages, Puppet can also be used to manage services, files, users, and many other aspects of system configuration.