Puppet manifests for DTAP environments

Here is how I implement a manifest to install an application on different environment.

1. I package the application into an RPM.

2. I build a manifest (init.pp) that hold the shared properties:

# mkdir -p /etc/puppet/modules/APPLICATION/{manifest,file,template}s

# cat /etc/puppet/modules/APPLICATION/manifests/init.pp
class APPLICATION {
package { APPLICATION:
ensure => present,
}

file { "/opt/apache-tomcat/conf/Catalina/localhost/APPLICATION.xml":
content => template("/etc/puppet/modules/APPLICATION/templates/APPLICATION.xml.erb"),
notify => Service["apache-tomcat"],
require => Package["APPLICATION"],
}
}

Add the template to the module:

# cat /etc/puppet/modules/APPLICATION/templates/APPLICATION.conf.erb
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Context>
<Context>
<Resource name="jdbc/APPLICATION"
auth="Container"
type="javax.sql.DataSource"
testWhileIdle="true"
testOnBorrow="true"
testOnReturn="false"
validationQuery="select sysdate from dual"
validationInterval="30000"
timeBetweenEvictionRunsMillis="30000"
maxActive="100"
minIdle="10"
maxWait="10000"
initialSize="10"
removeAbandonedTimeout="60"
removeAbandoned="true"
logAbandoned="true"
minEvictableIdleTimeMillis="30000"
jmxEnabled="true"
username="<%= APPLICATIONUSERNAME %>"
password="<%= APPLICATIONPASSWORD %>"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="<%= APPLICATIONDBURL %>"/>
</Context>

Now I make a manifest for each environment:

# cat /etc/puppet/modules/APPLICATION/manifests/development.pp
class APPLICATION::development {
$APPLICATIONDBURL = "jdbc:oracle:thin:@HOSTNAME:1521/SID"
$APPLICATIONUSERNAME = "USERNAME"
$APPLICATIONPASSWORD = "PASSWORD"

include APPLICATION
}

# cat /etc/puppet/modules/APPLICATION/manifests/test.pp
class APPLICATION::test {
$APPLICATIONDBURL = "jdbc:oracle:thin:@HOSTNAME:1521/SID"
$APPLICATIONUSERNAME = "USERNAME"
$APPLICATIONPASSWORD = "PASSWORD"

include APPLICATION
}

# cat /etc/puppet/modules/APPLICATION/manifests/acceptance.pp
class APPLICATION::acceptance {
$APPLICATIONDBURL = "jdbc:oracle:thin:@HOSTNAME:1521/SID"
$APPLICATIONUSERNAME = "USERNAME"
$APPLICATIONPASSWORD = "PASSWORD"

include APPLICATION
}

# cat /etc/puppet/modules/APPLICATION/manifests/production.pp
class APPLICATION::production {
$APPLICATIONDBURL = "jdbc:oracle:thin:@HOSTNAME:1521/SID"
$APPLICATIONUSERNAME = "USERNAME"
$APPLICATIONPASSWORD = "PASSWORD"

include APPLICATION
}

On a machine simple include:

include APPLICATION::development

About Consultancy Articles Contact




References Red Hat Certified Architect By Robert de Bock Robert de Bock
Curriculum Vitae By Fred Clausen +31 6 14 39 58 72
By Nelson Manning [email protected]