Ask Your Question
0

How to avoid an error when an exec command return 1

asked 2016-07-13 06:12:53 -0600

Imagin0s gravatar image

updated 2016-07-13 08:15:50 -0600

Hello,

I have a manifest which try to update a Redhat package but when there is nothing to update, the "yum install" command returns 1 and the catalog execution finish in error.

Here is the manifest :

class repos::epel (   $activation = $repos::epel_activation,   $brsnoop = $repos::brsnoop, ) {
   validate_bool($activation)
     if $activation == true {
       exec { 'EPEL installation':
        command => "yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-${operatingsystemmajrelease}.noarch.rpm",
        unless  => 'ls /etc/yum.repos.d/epel.repo',
        path    => ['/bin', '/usr/bin', '/usr/sbin'],
        noop    => $brsnoop,
     }   } }

Here is an example of catalog execution on a client :

> ducsxcp003 ~ :) #  puppet agent -t
> Info: Retrieving pluginfacts Info:
> Retrieving plugin Info: Loading facts
> Info: Caching catalog for
> ducsxcp003.boulogne.boursorama.fr
> Info: Applying configuration version
> '1468406826' Notice:
> /Stage[main]/Repos::Epel/Exec[EPEL
> installation]/returns: Loaded plugins:
> product-id, rhnplugin, security,
> subscription-manager Notice:
> /Stage[main]/Repos::Epel/Exec[EPEL
> installation]/returns: This system is
> receiving updates from RHN Classic or
> RHN Satellite. Notice:
> /Stage[main]/Repos::Epel/Exec[EPEL
> installation]/returns: Setting up
> Install Process Notice:
> /Stage[main]/Repos::Epel/Exec[EPEL
> installation]/returns: Examining
> /var/tmp/yum-root-LrTVT_/epel-release-latest-6.noarch.rpm:
> epel-release-6-8.noarch Notice:
> /Stage[main]/Repos::Epel/Exec[EPEL
> installation]/returns:
> /var/tmp/yum-root-LrTVT_/epel-release-latest-6.noarch.rpm:
> does not update installed package.
> Notice:
> /Stage[main]/Repos::Epel/Exec[EPEL
> installation]/returns: Error: Nothing
> to do Error: yum -y install
> https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
> returned 1 instead of one of [0]
> Error:
> /Stage[main]/Repos::Epel/Exec[EPEL
> installation]/returns: change from
> notrun to 0 failed: yum -y install
> https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
> returned 1 instead of one of [0]
> Notice: Finished catalog run in 11.94
> seconds

Does someone got an idea of what can I do to avoid an error in puppet just because the package is not updated ?

Thanks. Regards,

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-07-14 11:30:03 -0600

puppetamateur gravatar image

maybe try adding returns => [0,1]

edit flag offensive delete link more

Comments

Sorry for the late answer. Your solution works well.

Imagin0s gravatar imageImagin0s ( 2016-08-08 02:36:00 -0600 )edit
0

answered 2016-07-13 06:54:13 -0600

FranzCC gravatar image

updated 2016-07-13 06:54:33 -0600

Hi, why not using the package resource type ?
Package Resource

Rgds. Franz

edit flag offensive delete link more

Comments

Hello, because of what has already been setup

Imagin0s gravatar imageImagin0s ( 2016-08-08 02:36:52 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-07-13 06:12:53 -0600

Seen: 314 times

Last updated: Jul 14 '16