Puppet Manifest Samples
From Tech-Wiki
More actions
Sample Puppet manifest demonstrating users, packages, Apache virtual hosts, services, exec resources and managed files.
Sample manifest
Package names, module names and resource relationships depend on the target operating system and Puppet modules. The example below is retained from the original Tech-Wiki article as a structural reference.
Create the manifest
Open a manifest file
sudo vi /etc/puppet/manifests/lamp.pp
Example resources
# add user
user { 'mitchell':
ensure => present,
uid => '1000',
gid => '1000',
shell => '/bin/bash',
home => '/home/mitchell'
}
# install package
package { 'apache2', 'mysql-server', 'php5':
require => Exec['apt-update'], # require 'apt-update' before installing
ensure => installed,
}
# new virtual host in apache
node 'host2' {
class { 'apache': } # use apache module
apache::vhost { 'example.com': # define vhost resource
port => '80',
docroot => '/var/www/html'
}
}
# ensure service is running
service { 'mysql','httpd':
ensure => running,
}
# execute 'apt-get update'
exec { 'apt-update': # exec resource named 'apt-update'
command => '/usr/bin/apt-get update' # command this resource will run
}
# ensure info.php file exists
file { '/var/www/html/info.php':
ensure => file,
content => '<?php phpinfo(); ?>', # phpinfo code
require => Package['apache2'], # require 'apache2' package before creating
}Validate and apply
Apply the manifest in test mode
sudo puppet apply --test