Task Puppet Manage Archives - Failed

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

I see, I did that but it did not extract the file and task failed.

The code seems right to me. Did you run the sudo puppet agent -t command on an application node? On jump hosts this command does nothing, as the modifications for jump_host are the modifications of node default

try to change

archive { ‘/usr/src/blog/blog.zip’: this to different location like /tmp/blog.zip . It will work.

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{
}

thank you so much I though it had to be an arbitary location.

1 Like