Tuesday, June 9, 2015

Do it again

How about a super simple apache install?
This is just a really simple installation of apache, and it can be done with any application. I might even have a short cut in my text expander.

this is the modules/apache/manifests/init.pp

class apache { 
# Install package 
    package {'apache2':
        ensure  => installed,

# set the configure for debian 
  file { '/etc/apache2/sites-available/velcrohurts.conf':
    ensure => file,
    mode   => '0644',
    owner  => 'root',
    group  => 'root',
    source => 'puppet:///modules/apache/velcrohurts.conf',
    require => Package['apache2'],
    notify => Exec ["reload-apache2"],

# Reload apache with the config 
# And remove the default-000 config 
    exec {'/usr/sbin/a2dissite 000-default':
    require => Package['apache2'],
    notify => Exec ["reload-apache2"],

# Now add your config 
    exec {'/usr/sbin/a2ensite ajplus':
      notify => Exec ["reload-apache2"],
      require => Package['apache2'],

# the apache reloader 
    exec { 'reload-apache2':
      command => '/etc/init.d/apache2 reload',
      refreshonly => true,

That just keeps it nice and simple. It installs the apache app, sets the config, and restarts apache.
My config is simple because I only have 1 site per server, so my modules/apache/files/velcrohurts.conf looks a lot like this.

# Managed by Puppet 
# All changes will be overwriten 

<VirtualHost *:80>
  ServerName internal.velcrohurts.net 
  DocumentRoot  /var/www/html/
  LogLevel info 
  LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" combined
  ErrorLog ${APACHE_LOG_DIR}/velcrohurts-error.log
  CustomLog ${APACHE_LOG_DIR}/velcrohurts-access.log combined
  RedirectMatch ^/$ http://velcrohurts.net/
  <Directory /var/www/html/> 
     AllowOverride all
     Order allow,deny 
     allow from all

Then finally, your module should look like this under your manifests/site.pp

node default { 
   include accounts 

# web servers 
node web1 { 
    include apache 
node web2 { 
    include apache 

node web3 { 
    include apache 

No comments:

Post a Comment