Managing Apache servers
Apache is the world's favorite web server, so it's highly likely that part of your Puppetly duties will include installing and managing Apache.
How to do it...
Here's some working code to get you started:
Run the following command:
ubuntu@cookbook:~/puppet$ mkdir -p modules/apache/manifests
Create the file
modules/apache/manifests/init.pp
with the following contents:# Manage Apache class apache { package { 'apache2-mpm-prefork': ensure => installed } service { 'apache2': ensure => running, enable => true, require => Package['apache2-mpm-prefork'], } }
Modify your
manifests/nodes.pp
file as follows:node 'cookbook' { include apache }
Apache and Nginx both want to listen on the same port, so make sure Nginx is stopped if it happens to be installed:
ubuntu@cookbook:~/puppet$ sudo service nginx stop Stopping nginx: nginx.
Run Puppet:
ubuntu@cookbook:~/puppet$ papply Notice: /Stage[main]/Apache/Package[apache2-mpm-prefork]/ensure: ensure changed...