Ask Your Question
1

how do I unzip a file

asked 2015-04-20 05:55:47 -0500

eran gravatar image

updated 2015-04-20 11:33:42 -0500

ramindk gravatar image

Hello, I am trying to unzip a file from a mount point but sadly I am unsuccessful. thsi is what I do :

file { '/tmp/RRDI_INSTALLATION/':
  ensure => 'directory',
  mode   => '1777',
  owner  => 'user",
  group  => 'user',
}

exec { 'unzip':
  command     => 'sudo unzip /devops/RRDI-repo-Linux64-5.0.2GA.zip -d /tmp/RRDI_INSTALLATION/',
  cwd         => '/home/user/',
  path        => '/tmp/RRDI_INSTALLATION/',
  require     => File["/tmp/RRDI_INSTALLATION/"],
  creates     => '/tmp/RRDI_INSTALLATION/',     
  refreshonly => true,
}

if I run the unzip command manually it extracts the file. what am I doing wrong?

edit retag flag offensive close merge delete

Comments

Do not use sudo because you already running the puppet as root. So check this and tell me further problem. Or try this command if this in .tar.format tar xvf /path/

akshay gravatar imageakshay ( 2015-04-20 09:55:23 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-04-20 11:36:41 -0500

ramindk gravatar image

Your creates line isn't very useful. Because you're already creating that dir the exec will never run unless the Exec happens to run before the dir is created. Something like the following should work better.

file { '/devops/RRDI-repo-Linux64-5.0.2GA.zip':
  source => 'puppet:///somemodule//devops/RRDI-repo-Linux64-5.0.2GA.zip'
  notify => Exec['unzip'],
}
edit flag offensive delete link more
0

answered 2015-04-23 07:43:18 -0500

JohnsonEarls gravatar image

updated 2015-04-23 09:56:02 -0500

Adding to @ramindk 's answer, you also need to fix your Exec in several places:

  • As @ramindk mentioned, remove the creates parameter.

  • Also remove the path parameter, since that is setting the command path for the exec, and unzip is probably not found in the just-created empty directory.

  • Instead of using sudo, specify the user as whom the exec is supposed to run. I included 'root' in the example below, but since the directory you are creating is owned by 'user', you might want to specify that same user for the exec.

Try this instead:

file { '/devops/RRDI-repo-Linux64-5.0.2GA.zip':
  source => 'puppet:///somemodule//devops/RRDI-repo-Linux64-5.0.2GA.zip'
  notify => Exec['unzip'],
}

file { '/tmp/RRDI_INSTALLATION/':
  ensure => 'directory',
  mode   => '1777',
  owner  => 'user',
  group  => 'user',
}

exec { 'unzip':
  command     => 'unzip /devops/RRDI-repo-Linux64-5.0.2GA.zip -d /tmp/RRDI_INSTALLATION/',
  cwd         => '/home/user/',
  user        => 'root',
  require     => File["/tmp/RRDI_INSTALLATION/"],
  refreshonly => true,
}

Another option is to use one of the zip extraction modules from puppetforge: https://forge.puppetlabs.com/tags/zip

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

2 followers

Stats

Asked: 2015-04-20 05:55:47 -0500

Seen: 5,659 times

Last updated: Apr 23 '15