Puppet Manifest Samples

From Tech-Wiki
Revision as of 18:38, 1 May 2018 by Fabricio.Lima (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


First start creating your manifest

sudo vi /etc/puppet/manifests/lamp.pp
# 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
} 


Now validate and apply

sudo puppet apply --test