Ask Your Question
0

how do i use archive module from forge within my class to unzip file

asked 2016-06-21 11:24:23 -0600

puppetamateur gravatar image

updated 2016-06-21 11:27:21 -0600

I have been trying for a while but am not able to figure out. how to use archive module within my class to extract my zip file.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-06-22 00:12:09 -0600

DarylW gravatar image

In the puppet module's tests folder, the tomcat example includes pulling down a remote zip file and extracting it. That example is using a large number of parameters.. you will probably only need some of them for your usecase

tomcat.pp

$dirname = 'apache-tomcat-9.0.0.M3'
$filename = "${dirname}.zip"
$install_path = "/opt/${dirname}"

user { 'tomcat':
  ensure => present,
  gid    => 'tomcat',
}

group { 'tomcat':
  ensure => present,
}

file { '/opt/tomcat':
  ensure => 'link',
  target => $install_path,
}

file { $install_path:
  ensure => directory,
  owner  => 'tomcat',
  group  => 'tomcat',
  mode   => '0755',
}

archive { $filename:
  path          => "/tmp/${filename}",
  source        => 'http://www-eu.apache.org/dist/tomcat/tomcat-9/v9.0.0.M3/bin/apache-tomcat-9.0.0.M3.zip',
  checksum      => 'f2aaf16f5e421b97513c502c03c117fab6569076',
  checksum_type => 'sha1',
  extract       => true,
  extract_path  => '/opt',
  creates       => "${install_path}/bin",
  cleanup       => true,
  user          => 'tomcat',
  group         => 'tomcat',
  require       => File[$install_path],
}
edit flag offensive delete link more

Comments

can i use local path for source instead of the url?

puppetamateur gravatar imagepuppetamateur ( 2016-07-03 18:41:53 -0600 )edit

I believe that it takes a path in the format of file://path/to/local/archive.tar.gz

DarylW gravatar imageDarylW ( 2016-07-05 06:36:28 -0600 )edit

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-06-21 11:24:23 -0600

Seen: 47 times

Last updated: Jun 22 '16