Puppet: Apache module

create module structure
mkdir -p /etc/puppet/modules/apache/manifests
mkdir -p /etc/puppet/modules/apache/files

download module definiction
wget -q https://raw.githubusercontent.com/panticz/puppet/master/modules/apache/init.pp -O /etc/puppet/modules/apache/manifests/init.pp

class apache {
    case $::osfamily {
        'redhat': {
            $apache_name = 'httpd'
        }
        'debian': {
            $apache_name = 'apache2'
        }
        default: {
            $apache_name = 'apache2'
        }
    }

    # install apache
    package { "$apache_name":
        ensure => installed,
        #name => 'apache2-mpm-prefork', # httpd if CentOS
        alias  => "apache",
    }

    # enable apache service
    service { 'apache2':
        ensure => running,
        enable => true,
        require => Package['apache']
    }

    file { "/var/www/index.html":
        mode => 644,
        owner => www-data,
        group => www-data,
        source  => "puppet:///modules/apache/index.html",
        require => Package["apache"],
    }
}

add include to your client in /etc/puppet/manifests/site.pp
node "client1.local" inherits default {
...
include apache
...
}

Example: index.html
echo "Hello puppet" > /etc/puppet/modules/apache/files/index.html

Links
http://www.panticz.de/install_webserver
http://github.com/example42/puppet-apache