Task Puppet Manage Archives - Failed

Hello, kleansoul
You don’t need to define path field if you are defining source. extract_path field path put it in the archive module line. Should be like “/opt/games/games.zip”

Hello, kleansoul
I think you have to read my comment again. You did half work.

Sorry, but I am unable to understand the other half part which you are trying to address.

I understood you mean that the extract_path field should be full so that too changed , but the result is same.

Can you please highlight what is wrong in my code. I am trying to learn puppet and did several combinations on archive module in my lab setup but none worked for me yet. Maybe with your help I can learn something new.

Thank you in advance! :slight_smile:

node ‘stapp01.stratos.xfusioncorp.com’ {

archive { ‘/opt/games/games.zip’:
ensure => present,
extract => true,
extract_path => ‘/opt/games/games.zip’,
source => ‘/usr/src/games/games.zip’,
cleanup => true,
}
}
Hope it will help you.

I noticed that you defined source path as it as. You have to define source in the supported uri https|http|file.
For example : source => ‘file:///usr/src/games/games.zip’ from there it will pick your zip file.

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?