Skip to content

Instantly share code, notes, and snippets.

@reidmv
Created November 11, 2014 21:51
Show Gist options
  • Save reidmv/0625c591ab2e79385696 to your computer and use it in GitHub Desktop.
Save reidmv/0625c591ab2e79385696 to your computer and use it in GitHub Desktop.
Transition example
class profile::app::delicapp (
$ref = 'master',
$version = '1.2',
) {
include ::tomcat
include ::java
tomcat::instance { 'tomcat8':
catalina_base => '/opt/apache-tomcat/tomcat8',
source_url => 'http://mirror.nexcess.net/apache/tomcat/tomcat-8/v8.0.15/bin/apache-tomcat-8.0.15.tar.gz'
} ->
tomcat::service { 'tomcat8':
catalina_base => '/opt/apache-tomcat/tomcat8',
}
remote_file { 'plsample.war':
ensure => present,
path => "/opt/staging/plsample-${version}.war",
source => "http://master/tomcat/plsample-${version}.war",
} ->
file { 'plsample.war':
ensure => symlink,
target => "/opt/staging/plsample-${version}.war",
path => '/opt/apache-tomcat/tomcat8/webapps/plsample.war',
notify => Tomcat::Service['tomcat8'],
}
exec { 'arbitrarily complex upgrade procedure':
path => '/usr/bin:/bin',
command => 'rm -rf /opt/apache-tomcat/tomcat8/webapps/plsample && sleep 20',
refreshonly => true,
subscribe => File['plsample.war'],
notify => Tomcat::Service['tomcat8'],
}
transition { 'ensure service stopped for app update':
resource => Service['tomcat-tomcat8'],
attributes => { 'ensure' => 'stopped' },
prior_to => File['plsample.war'],
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment