Task Puppet Manage Archives - Failed

Thanks a ton for your help!

Though I tried that too in my lab exactly before but it game error, “unable to extract”. Now that I understand that you need unzip package too on the app server to make it work.

One more thing, I still noticed that with this code too cleaup => true the zip file does not delete after extract. Is it the correct behaviour ?

Document states as below:
``cleanup : whether archive file will be removed after extraction (true|false). (default: true)

No, you don’t need you require install unzip package. Main reason is it’s not applicable to file source path. I explained a bit in above post.

@kleansoul need a little modification in it as we talked above and your work is done.

Thanks @Tej-Singh-Rana for your help.

Few things just to brief it down so others can also get help –

  1. source => does not require file:/// and it works with direct absolute path too. Maybe in some other custom archive module, this might be mandatory but not in this one.
    For example: source => ‘/usr/src/games/games.zip’

  2. cleanup => by default the value is true but somehow I failed to get it to delete the archive zip file after extract

  3. it is required to install the archive module with the following command. But in KKE labs these are already installed so no need to worry.
    puppet module install puppet-archive --version 4.5.0

  4. dependant packages are required incase you are testing this in a fresh lab setup. But in KKE labs these are already installed so no need to worry. For archive module the dependent package is wget & bunzip/unzip

The below link has more details with examples:

Hi @Tej-Singh-Rana & @kleansoul,
I am having the same issue do not know why , it runs but it does not extract.
This is my manifest.
node ‘stapp01.stratos.xfusioncorp.com’ {
archive { ‘/usr/src/cluster/cluster.zip’:
source => ‘/usr/src/cluster/cluster.zip’,
extract => true,
extract_path => ‘/opt/cluster’,
ensure => present,
cleanup => false,
}
}

@ASAAC

Following is only one thing which I feel you are failing to understand:

path should be the location where you want to copy the zip file. In your manifest you have set this same as source.

1 Like

My puppet manifest wasn’t extracting the content of the zip file into the destination folder.
With the help of this post and some googling I modified it and it finally worked as expected.
I suspect the issue was because the order of operations of the parameters in the ‘archive’ module.

This finally made the trick.

node 'stapp01.stratos.xfusioncorp.com','stapp02.stratos.xfusioncorp.com','stapp03.stratos.xfusioncorp.com' {
  archive { '/opt/cluster/cluster.zip':
    ensure        => present,
    extract       => true,
    extract_path  => '/opt/cluster',
    source        => '/usr/src/cluster/cluster.zip',
    cleanup       => true,
  }
}

node default{
}

However, ‘cleanup’ didn’t work.

[root@stapp01 tony]# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for stapp01.stratos.xfusioncorp.com
Info: Applying configuration version '1599570561'
Notice: /Stage[main]/Main/Node[stapp01.stratos.xfusioncorp.com]/Archive[/opt/cluster/cluster.zip]/ensure: download archive from /usr/src/cluster/cluster.zip to /opt/cluster/cluster.zip and extracted in /opt/cluster with cleanup      <<<<<<<<<<<<<
Notice: Applied catalog in 0.15 seconds
[root@stapp01 tony]# ls -l /opt/cluster
total 12
-rw-r--r-- 1 root root  33 Sep  8 13:07 cluster2.txt
-rw-r--r-- 1 root root  54 Sep  8 13:07 cluster.txt
-rw-r--r-- 1 root root 411 Sep  8 13:09 cluster.zip     <<<<<<<<<<<<<
[root@stapp01 tony]#
1 Like

i tried with below pp., but its not extracted anything

@rahul456 @Tej-Singh-Rana

node “stapp01.stratos.xfusioncorp.com”,“stapp02.stratos.xfusioncorp.com”,“stapp03.stratos.xfusioncorp.com” {

archive { ‘/usr/src/cluster/cluster.zip’:

ensure        => present,

extract       => true,    

extract_path  => '/opt/cluster',

source        => '/usr/src/cluster/cluster.zip',   

cleanup       => true,

}

}

node default{

}

Getting below error in app servers:

Hello, @selvag
Please try with sudo or switch into the root user.

@player001 Tried with sudo in app server and no luck.

Yes, I viewed your review. But you didn’t use correctly source field.
You directly used source = <path>.

source: archive file source, supports http|https|ftp|file|s3 uri.

Hope it will help.

again tried with below. no luck…

node ‘stapp01.stratos.xfusioncorp.com’,‘stapp02.stratos.xfusioncorp.com’,‘stapp03.stratos.xfusioncorp.com’ {

archive { ‘/usr/src/demo/demo.zip’:

ensure        => present,

extract       => true,    

extract_path  => '/opt/demo',

source        => 'file:///usr/src/demo/demo.zip',   

cleanup       => true,

}

}

node default{

}

node ‘stapp01.stratos.xfusioncorp.com’,‘stapp02.stratos.xfusioncorp.com’,‘stapp03.stratos.xfusioncorp.com’ {

archive { ‘/opt/demo/demo.zip’:

ensure        => present,

extract       => true,    

extract_path  => '/opt/demo',

source        => 'file:///usr/src/demo/demo.zip',   

cleanup       => true,
   }
}

node default{}
1 Like

@rahul456 @Inderpreet
i have done all review comments, still its gets failed. not suew where its going wrong.

[KodeKloud Engineer | Real Project Tasks on Real Systems]

ran in app servers and then applied pp file .

puppet agent -tv
puppet agent -t

But this will create a zipped file in the desired path and not unzip the files within the folder?
Am I right?

I understand my mistake. Now its worked.

node ‘stapp01.stratos.xfusioncorp.com’,‘stapp02.stratos.xfusioncorp.com’,‘stapp03.stratos.xfusioncorp.com’ {
archive { ‘/tmp/ecommerce.zip’: ← this is should be some temp location
ensure => present,
extract => true,
extract_path => ‘/opt/ecommerce’,
source => ‘file:///usr/src/ecommerce/ecommerce.zip’,
cleanup => true,
}
}
node default{
}

puppet apply ecommerce.pp

Then run below commend in app servers, it should work

sudo puppet agent -tv
ll /opt/ecommerce # to verify

2 Likes

No, just provided a fancy title. It will unzip.

why should we run from app servers? puppet doesn’t do that?

I believe something is wrong with the task/lab

I have put the file in the desired directory but nothing happened.

node 'stapp01.stratos.xfusioncorp.com','stapp02.stratos.xfusioncorp.com','stapp03.stratos.xfusioncorp.com' {
  archive { '/usr/src/blog/blog.zip':    
    ensure        => present,
    extract       => true,    
    extract_path  => '/opt/blog',
    source        => '/usr/src/blog/blog.zip',
    cleanup       => true,
  }}

node default{
}

Puppet does do that. But it does not do it immediately. To test the the code you can trigger a run with puppet agent -t on node and puppet will apply the config for this node.

1 Like