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 purge capability to resources #103

Open
thias opened this issue Oct 7, 2013 · 7 comments
Open

Add purge capability to resources #103

thias opened this issue Oct 7, 2013 · 7 comments

Comments

@thias
Copy link

thias commented Oct 7, 2013

I've just declared the following :

stage { 'first': before => Stage['main'] }
Package_use {
  target => '/etc/portage/package.use',
  stage  => 'first',
}
package_use { 'dev-vcs/git': use => [ '-gpg', '-perl' ] }
package_use { 'net-analyzer/nagios-plugins': use => [ '-ldap', '-suid' ] }
package_use { 'media-gfx/imagemagick': use => [ 'jpeg', 'lzma', 'png' ] }

My problem is that if I remove any of the 3 package_use lines, the content of the /etc/portage/package.use file isn't updated (the entry isn't removed). I would like that to be possible without having to use ensure => absent. Other types typically have it working when doing this (which I've tried, but didn't work) :

resources { 'package_use': purge => true }

I haven't used the other package_* types yet, but I expect that this might apply to them too.

The reason for this is that I want my systems 100% puppet-managed (hence the target I use), and it's much more convenient to just remove obsolete code from the manifests rather than having to always change to absent and keep forever just in case.

@tampakrap
Copy link

have a look at #12 and #17 please, I think your issue is duplicate of #17

@thias
Copy link
Author

thias commented Oct 7, 2013

Indeed, and I didn't find them because they're closed...

I'll have a look at switching to using the /etc/portage/package.*/default files, as that would work for me as long as I'm also able to purge the /etc/portage/package.*/ directories, to be 100% sure there are no entries which aren't managed by puppet.

Still, this is quite a big issue IMHO, since these types are typically ones that would benefit a lot from purging...

@tampakrap
Copy link

and what's wrong with the solution at #17 (comment) ?

@thias
Copy link
Author

thias commented Oct 7, 2013

The problem with that solution is that you could add this to the manifest, then remove it, but it would stay present on the node :

package_use { 'dev/example':
  use    => 'foo',
  target => 'example'
}

This is because the /etc/portage/package.*/ directory itself doesn't get purged of other files (example in this case), only the content of the default file gets purged.

So this is what's required for a workaround which matches my expectations of a full purge : Any resources no longer declared in the manifest are guaranteed to not be there :

resources { 'package_use': purge => true }
exec { '/bin/rm -f /etc/portage/package.use':
  onlyif => '/usr/bin/test -f /etc/portage/package.use',
} ->
file { '/etc/portage/package.use':
  ensure  => directory,
  owner   => 'root',
  group   => 'root',
  mode    => '0755',
  recurse => true,
  purge   => true,
} ->
Package_use <| |>
file { '/etc/portage/package.use/default': }

It looks overkill, but unfortunately it's not... What do you want to do from here? Keep a bug report open to track possible ways of improving this? Have me submit an update to the README to mention this?

@tampakrap
Copy link

Let's keep this open and see what others will say. I don't have a strong opinion yet on how to proceed

@vikraman
Copy link

vikraman commented Oct 7, 2013

I believe this is a limitation of the parsedfile provider. Moving to puppet-filemapper will fix all these issues.

http://adrienthebo.github.io/puppet-filemapper/#Removing_empty_files

@thias
Copy link
Author

thias commented Oct 7, 2013

Update : Note that my workaround no longer works, and is no longer possible to use, once you include the '::portage' class, since it also declares the same directories (without the recurse/purge parameters I need). I just discovered that when continuing porting my existing Gentoo changes to this module, as soon as I wanted to manage make.conf with the module.

As @vikraman wrote, it seems like my initial problem would be solved by moving to the filemapper, though I would still have the purge issue for the directories declared by the main portage class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants