Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to avoid an error when an exec command return 1

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,

How to avoid an error when an exec command return 1

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
  > /Stage[main]/Repos::Epel/Exec[EPEL
> installation]/returns: Loaded plugins:
 > product-id, rhnplugin, security,
 > subscription-manager Notice:
  /Stage[main]/Repos::Epel/Exec[EPEL
  > /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
  > /Stage[main]/Repos::Epel/Exec[EPEL
> installation]/returns: Setting up
 > Install Process Notice:
  /Stage[main]/Repos::Epel/Exec[EPEL
  > /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
  > /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
  > 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
  > /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

> 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,