Sunday, July 8, 2018

Vagrant Rails Puppet. Organizing Manifests with Modules

Built Puppet Manifests using modules allow us to organize our manifests into logical pieces, much as we do with modules in Ruby or packages in Java. We’ve already gotten started on a module structure for our Apache-related Puppet configuration by creating a modules/apache2/files directory holding our customized apache2.conf


Configurations

in your puppet folder create this filer manifests/site.pp

apply your puppet and check it's working: sudo puppet apply --verbose manifests/site.pp

 Exec {
  path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
 }
 include apache2


create your virtual host in here: modules/apache2/files/massiveapp.conf


  ServerName myapp
  DocumentRoot "/var/myapp/current/public/"
  CustomLog /var/log/apache2/myapp-access_log combined
  ErrorLog /var/log/apache2/myapp-error_log

In your puppet folder built this directory files: modules/apache2/manifests/init.pp
in init.pp create this config:

package {
  "apache2":
  ensure => present,
  before => File["/etc/apache2/apache2.conf"]
}

service {
  "apache2":
  ensure => true,
  enable => true,
  subscribe => File["/etc/apache2/apache2.conf"]
}

file {
"/etc/apache2/apache2.conf":
  owner => root,
  group => root,
  mode => 644,
  source => "puppet:///modules/apache2/apache2.conf";

"/etc/apache2/sites-enabled/massiveapp.conf":
  source => "puppet:///modules/apache2/massiveapp.conf",
  owner => root,
  group => root,
  notify => Service["apache2"],
  require => Package["apache2"];
}

file {
"/etc/apache2/apache2.conf":
  owner => root,
  group => root,
  mode => 644,
  source => "puppet:///modules/apache2/apache2.conf";
"/etc/apache2/sites-enabled/massiveapp.conf":
  source => "puppet:///modules/apache2/massiveapp.conf",
  owner => root,
  group => root,
  notify => Service["apache2"],
  require => Package["apache2"];
}








Share: