Simplest Enterprise Continuous Integration Solutions

Sunday, April 29, 2012

Puppet Deployment: modules

# Custom Classes on puppet master

find /etc/puppet/modules
/etc/puppet/modules
/etc/puppet/modules/pptdeploy_install
/etc/puppet/modules/pptdeploy_install/manifests
/etc/puppet/modules/pptdeploy_install/manifests/init.pp
/etc/puppet/modules/pptdeploy_uninstall
/etc/puppet/modules/pptdeploy_uninstall/manifests
/etc/puppet/modules/pptdeploy_uninstall/manifests/init.pp
/etc/puppet/modules/pptdeploy_lockforinstall
/etc/puppet/modules/pptdeploy_lockforinstall/manifests
/etc/puppet/modules/pptdeploy_lockforinstall/manifests/init.pp
/etc/puppet/modules/pptdeploy_unlockforinstall
/etc/puppet/modules/pptdeploy_unlockforinstall/manifests
/etc/puppet/modules/pptdeploy_unlockforinstall/manifests/init.pp

cat /etc/puppet/modules/pptdeploy_install/manifests/init.pp

class pptdeploy_install {

 notify{ ">>> Starting to install ${pptdeploy_release} ${pptdeploy_product_name} ...":
         before => File [ installer ] }

 file { "installer":
        path => "${pptdeploy_install_dir}/${pptdeploy_product_shortname}/${pptdeploy_product_name}.bin",
        mode => '0755', }

 Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }

 exec { "install ${pptdeploy_release} ${pptdeploy_product_name} ...":
        command => "${pptdeploy_install_dir}/${pptdeploy_product_shortname}/${pptdeploy_product_name}.bin -i silent -DMY_RESPONSE_FILE=${pptdeploy_install_dir}/${pptdeploy_product_shortname}/${pptdeploy_response_file}",
        timeout => 0,
        creates => "/etc/install_registry/${pptdeploy_release}_${pptdeploy_product_shortname}_installed",
        require => File [ installer ] }

 exec { "<<< verify ${pptdeploy_release} ${pptdeploy_product_name} installation ...":
        command => "cat /etc/install_registry/${pptdeploy_product_name}.properties",
        logoutput => true,
        creates => "/etc/install_registry/${pptdeploy_release}_${pptdeploy_product_shortname}_installed",
        require => Exec [ "install ${pptdeploy_release} ${pptdeploy_product_name} ..." ] }

 exec { "Lock installation for ${pptdeploy_product_name} ...":
        command => "/bin/touch /etc/install_registry/${pptdeploy_release}_${pptdeploy_product_shortname}_installed",
        creates => "/etc/install_registry/${pptdeploy_release}_${pptdeploy_product_shortname}_installed",
        require => Exec [ "<<< verify pptdeploy ${pptdeploy_release} ${pptdeploy_product_name} installation ..." ] }
}

cat /etc/puppet/modules/pptdeploy_uninstall/manifests/init.pp

class pptdeploy_uninstall {

 notify{ ">>> Starting to uninstall ${pptdeploy_product_name} ...": }

 Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }

 exec { "uninstall ${pptdeploy_product_name} ...":
        command => "/opt/Uninstall_${pptdeploy_product_name} -i silent -uninstall",
        timeout => 0,
        require => Exec [ "Unlock installation for ${pptdeploy_product_name} ..." ] }

 exec { "Unlock installation for ${pptdeploy_product_name} ...":
        command => "rm -f /etc/install_registry/*_${pptdeploy_product_shortname}_installed",
        timeout => 0, }
}

cat /etc/puppet/modules/pptdeploy_lockforinstall/manifests/init.pp

class pptdeploy_lockforinstall {
 Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }
 exec { "Lock installation for ${pptdeploy_product_name} ...":
         command => "/bin/touch /etc/install_registry/${pptdeploy_release}_${pptdeploy_product_shortname}_installed",}
}

cat /etc/puppet/modules/pptdeploy_unlockforinstall/manifests/init.pp

class pptdeploy_unlockforinstall {
 Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }
 exec { "Unlock installation for ${pptdeploy_product_name} ...":
         command => "rm -f /etc/install_registry/*_${pptdeploy_product_shortname}_installed",}
}

cat /etc/puppet/manifests/site.pp

node default {
}

################################################
$pptdeploy_release = "3.0"
$pptdeploy_install_dir = "/mnt/work/COTS_install_sources"
$pptdeploy_product_shortname = "COTS"
$pptdeploy_product_name = "deploy_COTS"
$pptdeploy_response_file = "cots.response"

#-----------------------
# deployment installation
#-----------------------
node /linux64-puppet.*\.domain\.com/ {
  include pptdeploy_install
}

#-----------------------
# deployment uninstallation
#-----------------------
# node /linux64-puppet.*\.domain\.com/ {
#   include pptdeploy_uninstall
# }
################################################

# deploy on puppet agent

puppet agent -t --noop
warning: peer certificate won't be verified in this SSL session
info: Caching certificate for linux64-puppet-agent
info: Caching certificate_revocation_list for ca
info: Caching catalog for linux64-puppet-agent
info: Applying configuration version '1334886903'
...
notice: Finished catalog run in 0.08 seconds


puppet agent -t
info: Caching catalog for linux64-puppet-agent
info: Applying configuration version '1334886903'
...
notice: Finished catalog run in 328.60 seconds

No comments:

Post a Comment