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

Wildcards in default_file block #8

Closed
bodgit opened this issue Oct 17, 2017 · 4 comments
Closed

Wildcards in default_file block #8

bodgit opened this issue Oct 17, 2017 · 4 comments

Comments

@bodgit
Copy link

bodgit commented Oct 17, 2017

I'm trying to create a new provider for managing devices in RANCiD using the lens I've created in hercules-team/augeas/pull/514 and I need to use a wildcard to match potentially multiple files with the pattern /etc/rancid/*/router.db. The lens in question works in augtool as a standalone lens with this pattern but I've found I can't use the same pattern in the default_file block as it hits https://github.com/hercules-team/augeasproviders_core/blob/604680cb5fe7e32fd1ad1051fc34ef100a4d6923/lib/puppet/provider/augeasprovider/default.rb#L555 which errors when there are multiple matches.

If I comment out that line then the provider seems to work using puppet resource rancid_device ... however I can see in the code there are a few places which expect to be given a single file and it's likely only working by fluke.

My provider is here: https://github.com/bodgit/puppet-rancid/blob/master/lib/puppet/provider/rancid_device/augeas.rb

I'm not sure if the answer is some Dir.glob action somewhere?

@raphink
Copy link
Member

raphink commented Oct 17, 2017

Eventually, I'm sure you'll be modifying only one file though. Would that kind of approach work for you? https://github.com/hercules-team/augeasproviders_grub/blob/master/lib/puppet/provider/kernel_parameter/grub.rb#L10-L12

@bodgit
Copy link
Author

bodgit commented Oct 18, 2017

That doesn't really help, it's not an "either/or" pattern. RANCiD has the concept of groups which are collections of network devices and it's quite common to have more than one group. Each group is a separate directory with a separate router.db file, hence the wildcard; it's matching "all groups".

@bodgit
Copy link
Author

bodgit commented Oct 18, 2017

It seems the only sticky bits are the aug.set('/augeas/context', ...) I mentioned originally and this block https://github.com/hercules-team/augeasproviders_core/blob/604680cb5fe7e32fd1ad1051fc34ef100a4d6923/lib/puppet/provider/augeasprovider/default.rb#L688 which won't currently run as File.exists? won't work if passed a glob, but something like Dir.glob(file).any? could work around that perhaps?

I can't see anything else that might be confused with a wildcard so would it be possible to expose some method of selectively disabling that aug.set('/augeas/context', ...) call from a child provider?

@raphink
Copy link
Member

raphink commented Oct 18, 2017

OK. What do you think @domcleal ?

@bodgit bodgit closed this as completed Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants