Jump to content
Toggle menu
  • 51 articles
  • 24 files
  • 4 users
  • 750 edits
Tech-Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Puppet Manifest Samples

From Tech-Wiki


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

See also