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

versionlock.list updated after package {} install #43

Closed
fpeterschmitt opened this issue Mar 14, 2017 · 1 comment · Fixed by #65 or #154
Closed

versionlock.list updated after package {} install #43

fpeterschmitt opened this issue Mar 14, 2017 · 1 comment · Fixed by #65 or #154

Comments

@fpeterschmitt
Copy link

fpeterschmitt commented Mar 14, 2017

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4.9
  • Ruby: bundeled
  • Distribution: CentOS 7
  • Module version: 1.0.0

How to reproduce (e.g Puppet code you use)

Hieradata (working):

mymod::myclass::pkglist: ['git', 'which', 'puppetserver']
mymod::myclass::pkg_locks: ['0:puppetserver-2.7.2-1.el7.noarch']

Extract from real class (only the non-working part):

class mymod::myclass (Array[String] $pkglist, Array[String] $pkg_locks) {   
    exec {'somecmd':
        ....
        require => Package[$pkglist],
    }

    package {$pkglist:
        ensure => installed,
    }

    yum::versionlock {$pkg_locks:
        ensure => present,
        before => Package[$pkglist],
    }
}

What are you seeing

The versionlock.list file is updated after package installation.

What behaviour did you expect instead

versionlock.list to be updated before package installation.

Output log

Warning: /opt/rob-bootstrap/puppet/hieradata/common.yaml: file does not contain a valid yaml hash
Debug: Scope(Class[Rob_bspuppetmaster::Bspuppetmaster]): Retrieving epp template rob_bspuppetmaster/hiera.yaml.epp
Debug: Scope(Class[Rob_bspuppetmaster::Bspuppetmaster]): Retrieving epp template rob_bspuppetmaster/rob_mastersync.sh.epp
Debug: Scope(Class[Rob_bspuppetmaster::Bspuppetmaster]): Retrieving epp template rob_bspuppetmaster/r10k.yaml.epp
Debug: importing '/opt/rob-bootstrap/puppet/modules/yum/manifests/init.pp' in environment devel
Debug: importing '/opt/rob-bootstrap/puppet/modules/yum/manifests/versionlock.pp' in environment devel
Debug: Automatically imported yum::versionlock from yum/versionlock into devel
Debug: importing '/opt/rob-bootstrap/puppet/modules/yum/manifests/plugin/versionlock.pp' in environment devel
Debug: Automatically imported yum::plugin::versionlock from yum/plugin/versionlock into devel
Warning: /opt/rob-bootstrap/puppet/modules/yum/hiera.yaml: Use of 'hiera.yaml' version 4 is deprecated. It should be converted to version 5
   (in /opt/rob-bootstrap/puppet/modules/yum/hiera.yaml)
Warning: /opt/rob-bootstrap/puppet/modules/yum/data/os/RedHat.yaml: file does not contain a valid yaml hash
Debug: importing '/opt/rob-bootstrap/puppet/modules/yum/manifests/plugin.pp' in environment devel
Debug: Automatically imported yum::plugin from yum/plugin into devel
Debug: importing '/opt/rob-bootstrap/puppet/modules/concat/manifests/init.pp' in environment devel
Debug: Automatically imported concat from concat into devel
Debug: importing '/opt/rob-bootstrap/puppet/modules/concat/manifests/fragment.pp' in environment devel
Debug: Automatically imported concat::fragment from concat/fragment into devel
Debug: importing '/opt/rob-bootstrap/puppet/modules/yum/manifests/config.pp' in environment devel
Debug: Automatically imported yum::config from yum/config into devel
Warning: This method is deprecated, please use the stdlib validate_legacy function, with Pattern[]. There is further documentation for validate_legacy function in the README. at ["/opt/rob-bootstrap/puppet/modules/concat/manifests/init.pp", 69]:
   (at /opt/rob-bootstrap/puppet/modules/stdlib/lib/puppet/functions/deprecation.rb:25:in `deprecation')
Warning: This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_Path. There is further documentation for validate_legacy function in the README. at ["/opt/rob-bootstrap/puppet/modules/concat/manifests/init.pp", 70]:
   (at /opt/rob-bootstrap/puppet/modules/stdlib/lib/puppet/functions/deprecation.rb:25:in `deprecation')
Warning: This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README. at ["/opt/rob-bootstrap/puppet/modules/concat/manifests/init.pp", 71]:
   (at /opt/rob-bootstrap/puppet/modules/stdlib/lib/puppet/functions/deprecation.rb:25:in `deprecation')
Warning: This method is deprecated, please use match expressions with Stdlib::Compat::String instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions. at ["/opt/rob-bootstrap/puppet/modules/concat/manifests/init.pp", 72]:
   (at /opt/rob-bootstrap/puppet/modules/stdlib/lib/puppet/functions/deprecation.rb:25:in `deprecation')
Warning: This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README. at ["/opt/rob-bootstrap/puppet/modules/concat/manifests/init.pp", 81]:
   (at /opt/rob-bootstrap/puppet/modules/stdlib/lib/puppet/functions/deprecation.rb:25:in `deprecation')
Warning: This method is deprecated, please use match expressions with Stdlib::Compat::Bool instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions. at ["/opt/rob-bootstrap/puppet/modules/concat/manifests/init.pp", 82]:
   (at /opt/rob-bootstrap/puppet/modules/stdlib/lib/puppet/functions/deprecation.rb:25:in `deprecation')
Notice: Compiled catalog for vm-centos7 in environment devel in 0.60 seconds
Debug: Creating default schedules
Debug: Loaded state in 0.01 seconds
Debug: Loaded state in 0.01 seconds
Debug: Loaded transaction store file in 0.00 seconds
Info: Applying configuration version '1489509080'
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Exec[rob_mastersync]/require: subscribes to File[/etc/puppetlabs/code/rob_mastersync.sh]
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Exec[rob_mastersync]/require: subscribes to File[/etc/puppetlabs/puppet/hiera.yaml]
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Exec[rob_mastersync]/require: subscribes to File[/etc/puppetlabs/r10k/r10k.yaml]
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Exec[rob_mastersync]/require: subscribes to Exec[r10k-install]
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Exec[rob_mastersync]/require: subscribes to Exec[librarian-install]
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/File[/etc/puppetlabs/r10k/r10k.yaml]/require: subscribes to File[/etc/puppetlabs/r10k]
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/File[/etc/puppetlabs/r10k]/require: subscribes to Exec[r10k-install]
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Exec[librarian-install]/require: subscribes to Package[git]
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Exec[librarian-install]/require: subscribes to Package[which]
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Exec[librarian-install]/require: subscribes to Package[puppetserver]
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Exec[r10k-install]/require: subscribes to Package[git]
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Exec[r10k-install]/require: subscribes to Package[which]
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Exec[r10k-install]/require: subscribes to Package[puppetserver]
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Yum::Versionlock[0:puppetserver-2.7.2-1.el7.noarch]/before: subscribes to Package[git]
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Yum::Versionlock[0:puppetserver-2.7.2-1.el7.noarch]/before: subscribes to Package[which]
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Yum::Versionlock[0:puppetserver-2.7.2-1.el7.noarch]/before: subscribes to Package[puppetserver]
Debug: /Stage[main]/Yum::Plugin::Versionlock/Concat[/etc/yum/pluginconf.d/versionlock.list]/Concat_file[/etc/yum/pluginconf.d/versionlock.list]/before: subscribes to File[/etc/yum/pluginconf.d/versionlock.list]
Debug: /Stage[main]/Yum::Plugin::Versionlock/Concat[/etc/yum/pluginconf.d/versionlock.list]/Concat_file[/etc/yum/pluginconf.d/versionlock.list]: Adding autorequire relationship with Concat_fragment[yum-versionlock-0:puppetserver-2.7.2-1.el7.noarch]
Debug: /Stage[main]/Yum::Plugin::Versionlock/Concat[/etc/yum/pluginconf.d/versionlock.list]/Concat_file[/etc/yum/pluginconf.d/versionlock.list]: Skipping automatic relationship with File[/etc/yum/pluginconf.d/versionlock.list]
Debug: Prefetching yum resources for package
Debug: Executing: '/usr/bin/rpm --version'
Debug: Executing '/usr/bin/rpm -qa --nosignature --nodigest --qf '%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n''
Debug: Executing: '/usr/bin/rpm -q puppetserver --nosignature --nodigest --qf '%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n''
Debug: Executing: '/usr/bin/rpm -q puppetserver --nosignature --nodigest --qf '%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n' --whatprovides'
Debug: Package[puppetserver](provider=yum): Ensuring => present
Debug: Executing: '/usr/bin/yum -d 0 -e 0 -y install puppetserver'
Notice: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Package[puppetserver]/ensure: created
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Package[puppetserver]: The container Class[Rob_bspuppetmaster::Bspuppetmaster] will propagate my refresh event
Notice: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/File[/etc/puppetlabs/r10k]/ensure: created
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/File[/etc/puppetlabs/r10k]: The container Class[Rob_bspuppetmaster::Bspuppetmaster] will propagate my refresh event
Notice: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/File[/etc/puppetlabs/r10k/r10k.yaml]/ensure: defined content as '{md5}31a4551bc81c80f2b82300bc047f10c8'
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/File[/etc/puppetlabs/r10k/r10k.yaml]: The container Class[Rob_bspuppetmaster::Bspuppetmaster] will propagate my refresh event
Debug: Exec[rob_mastersync](provider=posix): Executing '/etc/puppetlabs/code/rob_mastersync.sh'
Debug: Executing: '/etc/puppetlabs/code/rob_mastersync.sh'
Notice: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Exec[rob_mastersync]/returns: executed successfully
Debug: /Stage[main]/Rob_bspuppetmaster::Bspuppetmaster/Exec[rob_mastersync]: The container Class[Rob_bspuppetmaster::Bspuppetmaster] will propagate my refresh event
Debug: Class[Rob_bspuppetmaster::Bspuppetmaster]: The container Stage[main] will propagate my refresh event
Info: Computing checksum on file /etc/yum/pluginconf.d/versionlock.list
Debug: Evicting cache entry for environment 'devel'
Debug: Caching environment 'devel' (ttl = 0 sec)
Info: FileBucket got a duplicate file {md5}d41d8cd98f00b204e9800998ecf8427e
Info: /Stage[main]/Yum::Plugin::Versionlock/Concat[/etc/yum/pluginconf.d/versionlock.list]/File[/etc/yum/pluginconf.d/versionlock.list]: Filebucketed /etc/yum/pluginconf.d/versionlock.list to puppet with sum d41d8cd98f00b204e9800998ecf8427e
Notice: /Stage[main]/Yum::Plugin::Versionlock/Concat[/etc/yum/pluginconf.d/versionlock.list]/File[/etc/yum/pluginconf.d/versionlock.list]/content: content changed '{md5}d41d8cd98f00b204e9800998ecf8427e' to '{md5}ab731e4e185b325d1d4bb8097c142f25'
Debug: /Stage[main]/Yum::Plugin::Versionlock/Concat[/etc/yum/pluginconf.d/versionlock.list]/File[/etc/yum/pluginconf.d/versionlock.list]: The container Concat[/etc/yum/pluginconf.d/versionlock.list] will propagate my refresh event
Debug: /Stage[main]/Yum::Plugin::Versionlock/Concat[/etc/yum/pluginconf.d/versionlock.list]/File[/etc/yum/pluginconf.d/versionlock.list]: The container /etc/yum/pluginconf.d/versionlock.list will propagate my refresh event
Debug: /etc/yum/pluginconf.d/versionlock.list: The container Concat[/etc/yum/pluginconf.d/versionlock.list] will propagate my refresh event
Debug: Concat[/etc/yum/pluginconf.d/versionlock.list]: The container Class[Yum::Plugin::Versionlock] will propagate my refresh event
Debug: Augeas[yum.conf_main_plugins](provider=augeas): Opening augeas with root /, lens path , flags 64
Debug: Augeas[yum.conf_main_plugins](provider=augeas): Augeas version 1.4.0 is installed
Debug: Augeas[yum.conf_main_plugins](provider=augeas): Will attempt to save and only run if files changed
Debug: Augeas[yum.conf_main_plugins](provider=augeas): sending command 'set' with params ["/files/etc/yum.conf/main/plugins", "1"]
Debug: Augeas[yum.conf_main_plugins](provider=augeas): Skipping because no files were changed
Debug: Augeas[yum.conf_main_plugins](provider=augeas): Closed the augeas connection
Debug: Class[Yum::Plugin::Versionlock]: The container Stage[main] will propagate my refresh event
Debug: Finishing transaction 20046600
Debug: Storing state
Debug: Stored state in 0.01 seconds
Notice: Applied catalog in 239.22 seconds
Debug: Applying settings catalog for sections reporting, metrics
Debug: Finishing transaction 20342480
Debug: Received report to process from vm-centos7
Debug: Evicting cache entry for environment 'devel'
Debug: Caching environment 'devel' (ttl = 0 sec)
Debug: Processing report from vm-centos7 with processor Puppet::Reports::Store

Workaround

Add require => Concat['/etc/yum/pluginconf.d/versionlock.list'] to package {$pkglist:`.

@BdeHeij
Copy link

BdeHeij commented Aug 1, 2017

I've actually ran into the exact same issue today, and have solved it kinda with the same workaround (except I've used the class and "strictly speaking" the concat path could have changed and didn't want to bother with the parameter messup);

But when I've started thinking "I should fix this and make a merge request" the only decent solution I could come up with is set an order statement to the Package resource (including provider=yum). But this could potentially harm other dependency cycles etc... In other words, introduce risk.

Love to hear anyone's thoughts on this and I'll be happy to prepare a merge request.

alexjfisher added a commit to alexjfisher/puppet-yum that referenced this issue Jan 8, 2020
The plugin class `yum::plugin::versionlock` should not be `contain`ed
from every instance of the `yum::versionlock` defined type. Doing so
makes it impossible to use the type in multiple dependent
classes/profiles. `contain` implies that the resource 'owns' the plugin.
Using `require` should be just as effective at solving voxpupuli#43 without
introducing dependency cycles.

With `contain`...

```puppet
class profile::foo {
  yum::versionlock { '0:bash-4.1.2-9.el6_2.*':}
}

class profile::bar {
  yum::versionlock { '2:vim-enhanced-7.4.629-6.el7.x86_64':}
}

include profile::foo
include profile::bar

Class['profile::foo'] -> Class['profile::bar']
```

fails with
```
Error: Found 1 dependency cycle:
(Augeas[yum.conf_plugins] => Yum::Config[plugins] => Yum::Plugin[versionlock] => Class[Yum::Plugin::Versionlock] => Yum::Versionlock[0:bash-4.1.2-9.el6_2.*] => Class[Profile::Foo] => Class[Profile::Bar] => Yum::Versionlock[2:vim-enhanced-7.4.629-6.el7.x86_64] => Class[Yum::Plugin::Versionlock] => Yum::Plugin[versionlock] => Package[yum-plugin-versionlock] => Yum::Plugin[versionlock])\nTry the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz
Error: Failed to apply catalog: One or more resource dependency cycles detected in graph
```

This commit also refactors the type with:
  * puppet-strings style docs.
  * A simple `unless` instead of a `case` for `ensure`.
  * `assert_type` instead of `is_a`.

Fixes voxpupuli#43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants