voxpupuli / puppet-archive

Compressed archive file download and extraction with native types/providers for Windows and Unix
https://forge.puppet.com/puppet/archive
Apache License 2.0
59 stars 176 forks source link

archive has stopped working for us #505

Open djmills64 opened 10 months ago

djmills64 commented 10 months ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

node default {
  archive { '/hdd/Backup/pylon_7.1.0.25066_x86_64.tar.gz':
    extract      => true,
    extract_path => '/tmp/pylon7',
    cleanup      => false,
    require      => File['/tmp/pylon7'],
  }

  file { '/tmp/pylon7':
    ensure => directory,
    owner  => 'root',
    mode   => '0755',
  }
}

What are you seeing

Creates the folder /tmp/pylon7, but fails to "tar zxf" into it

What behaviour did you expect instead

We should see /tmp/pylon7 with foles/folders in it.

Output log

Notice: Compiled catalog for acusensus-davidmills in environment production in 0.02 seconds
Notice: /Stage[main]/Main/Node[default]/File[/tmp/pylon7]/ensure: created
Notice: Applied catalog in 0.74 seconds

No mention of the archive resource.

Any additional information you'd like to impart

This was working for us fairly recently.

djmills64 commented 10 months ago

I might have just figured it out. It seems that you need a "source" parameter and that it has to differ from the "path" parameter. Given the file already exists in the "path" location, can it not simply be extracted from there? Why do we need to make a copy elsewhere first? e.g. changing to

  archive { '/hdd/Backup/pylon_7.1.0.25066_x86_64.tar.gz':
    path         => "/hdd/Backup/pylon_7.1.0.25066_x86_64.tar.gz",
    source       => '/tmp/pylon_7.1.0.25066_x86_64.tar.gz',
    extract      => true,
    extract_path => '/tmp/pylon7',
    cleanup      => false,
    require      => File['/tmp/pylon7'],
  }

works but having source as "/hdd/Backup/pylon_7.1.0.25066_x86_64.tar.gz" does not. Why not?

djmills64 commented 10 months ago

I ran the above code once and it worked. But then when I remove the extract_path folder and contents and run again, it creates the folder but doesn't populate. Why would that be?

djmills64 commented 10 months ago

If I turn on debug I don't get much information in relation to the archive resource. Just

...
Debug: Loaded state in 0.45 seconds
Info: Applying configuration version '1694058315'
Debug: /Stage[main]/Main/Node[default]/Archive[pylon_7.1.0.25066_x86_64.tar.gz]/require: require to File[/opt/pylon7]
Debug: Finishing transaction 12600
Debug: Storing state
...

The one time it worked the output showed:

root@acusensus-davidmills:~# /opt/puppetlabs/bin/puppet apply     --hiera_config=/work/code/puppet-runtime/hiera.yaml     --modulepath=/etc/puppetlabs/code/environments/production/modules:/work/code/puppet-runtime     /work/code/puppet-runtime/manifests/site-test.pp --detailed-exitcodes
Notice: Compiled catalog for acusensus-davidmills in environment production in 0.02 seconds
Notice: /Stage[main]/Main/Node[default]/Archive[/hdd/Backup/pylon_7.1.0.25066_x86_64.tar.gz]/ensure: download archive from /hdd/Backup/pylon_7.1.0.25066_x86_64.tar.gz to /tmp/pylon_7.1.0.25066_x86_64.tar.gz and extracted in /tmp/pylon7 without cleanup
Notice: Applied catalog in 5.22 seconds

after which /tmp/pylon7 had the files/folders it is meant to.

djmills64 commented 10 months ago

Actually having a creates parameter seems to force the issue and remove the need for a source parameter.

node default {
  $archive = 'pylon_7.1.0.25066.tar.gz'
  $software_install_path = '/opt/pylon7'
  archive { "/hdd/Backup/${archive}":
    path         => "/hdd/Backup/${archive}",
    extract      => true,
    extract_path => $software_install_path,
    cleanup      => false,
    require      => File[$software_install_path],
    creates      => "${software_install_path}/bin/pylonviewer",
  }

 file { $software_install_path:
    ensure => directory,
    owner  => 'root',
    mode   => '0755',
  }
}

works.