Ask Your Question
0

How do I do continuous deployment of WAR files using puppet

asked 2016-01-12 14:51:29 -0500

updated 2016-01-21 15:04:19 -0500

I would like to know how to do continuous deployment using puppet - the steps that i am looking forward is:

1) what code should be written to trigger puppet to do the deployment whenever code is committed in the CI server (like Jenkins).

2) what should i do to facilitate interaction between puppet and vRealize in order to create VMs in vRealize and what code do I use puppet to do the deployment of WAR/JAR files on the VM created at the vRealize end?

3) How do I pull the code from the Artifactory in the new VM created by vRealize and how do i use puppet to make sure that the deployment was all perfect.

Many thanks in advance. I'm really struck and It'd be great to have a response.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-01-22 12:31:00 -0500

DarylW gravatar image

updated 2016-01-22 12:31:51 -0500

1) There are several ways this can be approached. If you have some sort of tool in place to run remote commands (plain old remote ssh commands, fabric, MCollective, exec calls in Consul), you could tell the instance(s) in question to rerun the puppet agent. I'm not sure if there is any easier way to trigger a remote puppet run.

2) Not familiar with vRealize, but we partially have a solution in place, for deploying our war files.

If your war files properly extract their configuration and don't need a hard coded value updated inside of them, Something like the following may be useful. (Note, it is not my code, just something that I had in my notes from when I was looking into the problem). We have seen this in use so that puppet would remove the cached version of the wars, because simply plopping it down inside of the ./webapps/ directory didn't always deploy our most recent changes.

https://github.com/mrzarquon/mrzarquo...

define tomcat::war(
$war_source        = 'http://master/tomcat',
$tomcat_stage_dir  = '/opt/tomcat/active',
$tomcat_target_dir = '/opt/tomcat/active',
$filename
) {

staging::file { "${tomcat_stage_dir}/war/${filename}":
  source  => "${war_source}/${filename}",
}

exec { "extract_${name}":
  command     => "unzip ${tomcat_stage_dir}/war/${filename} -d ${tomcat_target_dir}/apps/${filename}",
  path        => '/bin:/usr/bin',
  refresh     => "rm -Rf ${tomcat_target_dir}/apps/${filename} && unzip ${tomcat_stage_dir}/war/${filename} -d ${tomcat_target_dir}/apps/${filename}",
  require     => [File["${tomcat_target_dir}/apps"], Package['unzip']],
  subscribe   => [
    Staging::File["${tomcat_stage_dir}/war/${filename}"],
    File[$tomcat_stage_dir],
    File["${tomcat_target_dir}/webapps/${name}"],
  ], 
  refreshonly => true,
  notify      => Service['tomcat'],
}

file { "${tomcat_target_dir}/apps/${filename}":
  ensure => directory,
}

file { "${tomcat_target_dir}/webapps/${name}":  
  ensure  => symlink,
  target  => "${tomcat_target_dir}/apps/${filename}",
  require => File["${tomcat_target_dir}/apps/${filename}"],
  notify  => Service['tomcat'],
}
}

3) We store our files in an s3 bucket and use the staging module to pull them down, but there are some modules available for Nexus and Artifactory... https://github.com/superwilly/puppet_...

You would just need to update your puppet configuration (though hiera, querying your CI server in a custom fact, or something) to set the version specific information, but the module looks like it has most of the logic you would need.

# Initialize the Puppet Artifactory module
class {'artifactory':
  url => 'http://artifactory.domain.com',
}

artifactory::artifact {'commons-io':
  gav        => 'commons-io:commons-io:2.1',
  repository => 'public',
  output     => '/tmp/commons-io-2.1.jar',
}

artifactory::artifact {'/tmp/ipojo.jar':
  gav => 'org.apache.felix:org.apache.felix.ipojo:1.8.0',
}

artifactory::artifact {'/tmp/parser-0.3.0-SNAPSHOT.jar':
  gav         => 'com.company.project:parser:0.3.0-SNAPSHOT',
  timestamped => true,
}

artifactory::artifact {'chameleon web distribution':
  gav => 'org.ow2.chameleon:distribution-web:0.3.0-SNAPSHOT',
  classifier => 'distribution',
  packaging  => 'zip',
  repository => 'public-snapshots',
  output     => '/tmp/distribution-web-0.3.0-SNAPSHOT.zip'
}

Good luck!

edit flag offensive delete link more

Comments

1

Thanks a lot! I will try the suggested methods.

Redsmile gravatar imageRedsmile ( 2016-01-22 13:19:59 -0500 )edit
0

answered 2016-06-27 10:58:29 -0500

Finally, this is what worked for me:

1) what code should be written to trigger puppet to do the deployment whenever code is committed in the CI server (like Jenkins). - Jenkins gradle plugins to do the puppet agent invocation after the VM was created on demand.

2) what should i do to facilitate interaction between puppet and vRealize in order to create VMs in vRealize and what code do I use puppet to do the deployment of WAR/JAR files on the VM created at the vRealize end? - Jenkins gradle plugin took care of this.

3) How do I pull the code from the Artifactory in the new VM created by vRealize and how do i use puppet to make sure that the deployment was all perfect. - Again, Jenkins took care of this.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-01-12 14:51:29 -0500

Seen: 1,135 times

Last updated: Jun 27 '16