Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add require_verify option to install.pp #244

Merged
merged 1 commit into from
Jun 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,16 @@ yum::install { 'package-name':
}
```

Reinstall if rpm-verify fails:

```puppet
yum::install { 'package-name':
ensure => present,
source => 'file:///path/to/package/filename.rpm',
require_verify => true,
}
```

Please note that resource name must be same as installed package name.

### Puppet tasks
Expand Down
12 changes: 12 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# @param source file or URL where RPM is available
# @param ensure the desired state of the package
# @param timeout optional timeout for the installation
# @param require_verify optional argument, will reinstall if rpm verify fails
#
# @example Sample usage:
# yum::install { 'epel-release':
Expand All @@ -16,6 +17,7 @@
define yum::install (
String $source,
Enum['present', 'installed', 'absent', 'purged'] $ensure = 'present',
Boolean $require_verify = false,
Optional[Integer] $timeout = undef,
) {
Exec {
Expand All @@ -25,6 +27,16 @@

case $ensure {
'present', 'installed', default: {
if $require_verify {
exec { "yum-reinstall-${name}":
command => "yum -y reinstall '${source}'",
onlyif => "rpm -q '${name}'",
unless => "rpm -V '${name}'",
timeout => $timeout,
before => Exec["yum-install-${name}"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does that make sense? Do we want to run yum install after we did zum reinsstall?

Copy link
Author

@jcpunk jcpunk Apr 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, the yum install should detect the rpm is loaded (via the rpm -q check (https://github.com/voxpupuli/puppet-yum/blob/master/manifests/install.pp#L30) and just skip it. If these package isn't installed, the verify check will be skipped but the package will be loaded.

}
}

exec { "yum-install-${name}":
command => "yum -y install '${source}'",
unless => "rpm -q '${name}'",
Expand Down