My Profile Photo

Personal Webpage of David Duggins


Well, I was born on a normal day in July, 1981 and have been creating chaos ever since. Born in North Carolina, but raised in the aftermath of the Soviet Union, Kazakhstan, I have been messing around with computers nearly my entire life. I wrote my first program in assembly when I was 11. In my early teens I ran a BBS connected to Fidonet and started building a website for my band. In 1999 I was introduced to Linux, and it was love at first compile. I started my career in IT in the early 2000's doing IT for a Car Dealership in Charlotte NC. I wrote my first major web app in Cold Fusion (an ecom app) at that time. In 2006 I left Charlotte and moved down to Columbia where starting working as a developer, freelancer and consultant. Currently I am working as a freelance developer and DevOps consultant!!


Preparing a Dev Environment with Puppet

For starts, I now have markup installed in my blog, so no more typing html!! Yea!\n

Today we are going to talk about Puppet. No, not Pinochio, or those Punch and Judy dolls. This is Puppet as in the server provisioning tool.

At work I am setting up a development environment for our dev team. Since most of them are just learning php, and for over all consistency I am using Vagrant to build a standard dev vm for everyone to work off of.

The general requirements are simple:

  1. We must run Zend Server
  2. We must load the php drivers MS Sql
  3. We must install subversion

With these requirements in mind, I set out to build my first puppet script.

The first class that we define is our services class. I need to make sure that Apache is running. Also, I found out that Cent Os turns iptables on by default. That interferes with the dev box, as well as being unnecessary! So we make sure that iptables is off.

class services {  
  #we want apache
  service {
    'httpd':
      ensure => running,
      enable => true
  }

service {  
  'iptables':
    ensure => stopped,
    enable => false
 }
}

The next two classes work in tandem. The repos class defines our Zend Server repo and packages install the required packages.

class packages {  
  package {
    "httpd":                      ensure => "present"; # Apache
    "subversion":                 ensure => "present"; # Subversion
    "zend-server-ce-php-5.3":     ensure => "present"; # Zend Server (CE)
    "php-5.3-mssql-zend-server":  ensure => "present"; # MSSQL Extenstion - provided by Zend
  }
}


class repos {  
  #lets install some repos
  file { "/etc/yum.repos.d/zend.repo":
    content => "[Zend]
    name=Zend Server
    baseurl=http://repos.zend.com/zend-server/rpm/x86_64
    enabled=1
    gpgcheck=1
    gpgkey=http://repos.zend.com/zend.key

    [Zend_noarch]
    name=Zend Server - noarch
    baseurl=http://repos.zend.com/zend-server/rpm/noarch
    enabled=1
    gpgcheck=1
    gpgkey=http://repos.zend.com/zend.key
    "
  }

}

If anyone wants to see the entire file, here it is:

stage {

  'users':      before => Stage['repos'];
  'repos':      before => Stage['packages'];
  'packages':   before => Stage['configure'];
  'configure':  before => Stage['services'];
  'services':   before => Stage['main'];

}

class services {  
  #we want apache
  service {
    'httpd':
      ensure => running,
      enable => true
  }

  service {
    'iptables':
      ensure => stopped,
      enable => false
  }
}

class configure {

  # symlinking the code from /home/vagrant/public to var/www/public
  exec { "public simlink":
    command => "/bin/ln -s /home/vagrant/public /var/www/",
    unless  => "/usr/bin/test -L /var/www/",
  }
  file {"/var/www/index.html":
    ensure => "absent"

  }
}

class packages {  
  package {
    "httpd":                      ensure => "present"; # Apache
    "subversion":                 ensure => "present"; # Subversion
    "zend-server-ce-php-5.3":     ensure => "present"; # Zend Server (CE)
    "php-5.3-mssql-zend-server":  ensure => "present"; # MSSQL Extenstion - provided by Zend
  }
}

class repos {

  file { "/etc/yum.repos.d/zend.repo":
    content => "[Zend]
name=Zend Server  
baseurl=http://repos.zend.com/zend-server/rpm/x86_64  
enabled=1  
gpgcheck=1  
gpgkey=http://repos.zend.com/zend.key

[Zend_noarch]
name=Zend Server - noarch  
baseurl=http://repos.zend.com/zend-server/rpm/noarch  
enabled=1  
gpgcheck=1  
gpgkey=http://repos.zend.com/zend.key  
    "
  }

}

class users  
{
  group { "puppet":
    ensure => "present",
  }
  user { "vagrant":
    ensure => "present",

  }
}

class {  
  users:      stage => "users";
  repos:      stage => "repos";
  packages:   stage => "packages";
  configure:  stage => "configure";
  services:   stage => "services";

  }
© 2024 David Duggins. All rights reserved.