Skip to content

Add ability to override default system confdir and vardir#2236

Closed
jeffmccune wants to merge 1 commit intopuppetlabs:masterfrom
jeffmccune:confdir_vardir
Closed

Add ability to override default system confdir and vardir#2236
jeffmccune wants to merge 1 commit intopuppetlabs:masterfrom
jeffmccune:confdir_vardir

Conversation

@jeffmccune
Copy link
Contributor

Without this patch it's difficult to change the behavior of determining the
default confdir and vardir settings. This is a problem because it's difficult
to relocate Puppet which is necessary in certain cases, such as Puppet
Enterprise and our Ops team using /etc/operations/puppet as the default
confdir.

This patch exposes a public API to allow third party tools to easily determine
the file to write to override the default confdir and vardir. The API method is
Puppet::Util::RunMode.override_path(type) where type is either "confdir" or
"vardir" An anticipated use case is that a simple rubygems plugin gem could
register a post_install hook to write an override file which will relocate
puppet.

A path relative to the gem source file has been chosen to facilitate multiple
copies of the Puppet library being installed and relocated to their own
isolated paths or gemset.

@puppetcla
Copy link

CLA signed by all contributors.

jeffmccune pushed a commit to jeffmccune/puppet_transplant that referenced this pull request Jan 13, 2014
This is just a work in progress of where I left off.  This branch will
be rebased.

Where I left off was using the new API that I hope will be merged in as
puppetlabs/puppet#2236

In addition, we'll need to implement the fallback behavior of modifying
run_mode.rb directly which I consider the "hacky" solution, but it's
necessary for versions of Puppet that are released today without the
public relocation API.
Without this patch it's difficult to change the behavior of determining
the default confdir and vardir settings.  This is a problem because it's
difficult to relocate Puppet which is necessary in certain cases, such
as Puppet Enterprise and our Ops team using /etc/operations/puppet as
the default confdir.

This patch exposes a public API to allow third party tools to easily
determine the file to write to override the default confdir and vardir.
The API method is Puppet::Util::RunMode.override_path(type) where type
is either "confdir" or "vardir"  An anticipated use case is that a
simple rubygems plugin gem could register a post_install hook to write
an override file which will relocate puppet.

A path relative to the gem source file has been chosen to facilitate
multiple copies of the Puppet library being installed and relocated to
their own isolated paths or gemset.
@jeffmccune
Copy link
Contributor Author

If it might help, here's the Gem that I've written that takes advantage of this API in order to install the official, released puppet gem and have it automatically relocated.

This gem demonstrates the approach required without this patch applied, directly patching run_mode.rb, and the improved approach of using the public API to relocate an officially released Gem.

@zaphod42
Copy link
Contributor

After a bit of discussion during the PR triage, a long discussion and IRC, and @adrienthebo talking to some others (@haus, I believe), the decision is that we aren't going to take this change as is.

The crux of the problem comes down to the desire to use released gems, supposedly unmodified, but configured to work differently at install time, to remove any need to specify the confdir and vardir, yet use the non-default confdir and vardir. This is a very specific set of requirements, which is not something that we want to maintain.

If we drop the requirement to use the released gems, then there is an approach that I would be happy to maintain: introduce a build step into how puppet gets packaged and allow that to control the default confdir and vardir of that build of puppet.

@jeffmccune
Copy link
Contributor Author

The purpose of the change is to enable those who are currently
rebuilding puppet manually to avoid doing so and instead use the
official release in an automated fashion.

The alternatives proposed don't address the primary use case and as
such would defeat the purpose of the change in the first place.

Go ahead and close this pull request unless there's some way we can
move forward while taking the primary use case into account.

@jeffmccune
Copy link
Contributor Author

@zaphod42 One of the questions you asked last week in IRC was what other systems are out there that override defaults like this. At the time I didn't provide anything constructive or useful.

If it helps, and is additional information, there are two systems that served as inspiration for this change. First, Java .properties files were the inspiration for placing the .override file in this change along side the code itself instead of a well-known and absolute path. It's my understanding that .properties files are commonly used to override the default behavior of the code itself. Second, there's the alternatives system in some Linux distributions. This system allows a system administrator or end user to override the default behavior of the system and replace it with an alternative. Alternatives uses symlinks, however, which I didn't think were well-suited to this use case since symlinks don't behave consistently on all of our supported platforms.

This led me to select reading the first line of a plain text files as the basis for the implementation. It's similar to a symbolic link, but behaves consistently across all of our supported platforms.

In the past week have there been any ideas that have come up that would allow us to accomplish something like this with the released puppet gem? On my end, the only thing I've been able to come up with is to eliminate the filesystem altogether and instead try to load some gem library and, if successful, use an instance method from that library to set the default system confdir and vardir.

@zaphod42
Copy link
Contributor

@jeffmccune anything that causes defaults to come from configuration files is off the table from my perspective, it just causes too much complexity at the point of fallbacks where we want nothing to go wrong. @adrienthebo talk with @haus and Matt and came to the conclusion that making this a build time configuration and having packages that are built to have puppet in a different location would work well for them.

Thank you for talking with us about this, unfortunately we just don't see eye to eye on if this is the right direction to take to solve the underlying problem and also take the codebase in the direction that I'd like to see. I'm open to changes that introduce a build step and make the defaults configurable at build/packaging time.

@zaphod42 zaphod42 closed this Jan 29, 2014
@jeffmccune
Copy link
Contributor Author

On Jan 29, 2014, at 6:56 PM, Andrew Parker notifications@github.com wrote:

@jeffmccune https://github.com/jeffmccune anything that causes defaults
to come from configuration files is off the table from my perspective

Thanks for the response. If I'm understanding your position I take it you'd
also be opposed to taking defaults from a third party via code/API if it
were done in a way that didn't involve configuration files. It seems like
it's the added complexity that's the bulk of the concern, not necessarily
only the fact that this implementation uses configuration files.

Is that correct?

Just trying to figure out if it'd be worth my time trying again with the
aim of eliminating the config files.

-Jeff

@zaphod42
Copy link
Contributor

On Thu, Jan 30, 2014 at 4:00 AM, Jeff McCune notifications@github.comwrote:

On Jan 29, 2014, at 6:56 PM, Andrew Parker notifications@github.com
wrote:

@jeffmccune https://github.com/jeffmccune anything that causes defaults
to come from configuration files is off the table from my perspective

Thanks for the response. If I'm understanding your position I take it you'd
also be opposed to taking defaults from a third party via code/API if it
were done in a way that didn't involve configuration files. It seems like
it's the added complexity that's the bulk of the concern, not necessarily
only the fact that this implementation uses configuration files.

Is that correct?

Yep, my main concern is the added complexity.

Just trying to figure out if it'd be worth my time trying again with the
aim of eliminating the config files.

Would you be interested in trying to change it to a packaging time
configuration?

-Jeff

Reply to this email directly or view it on GitHubhttps://github.com//pull/2236#issuecomment-33681554
.

Andrew Parker
andy@puppetlabs.com
Freenode: zaphod42
Twitter: @aparker42
Software Developer

Join us at PuppetConf 2014, September 23-24 in San Francisco

@jeffmccune
Copy link
Contributor Author

On Jan 30, 2014, at 12:46 PM, Andrew Parker notifications@github.com wrote:

Yep, my main concern is the added complexity.

OK. I may try once more just for my own exercise, but please know I'm
not trying to create any additional work or anything and I'm
personally 100% OK if a second try doesn't get merged either.

I'll try to keep it as simple as possible since complexity is the main concern.

Just trying to figure out if it'd be worth my time trying again with the
aim of eliminating the config files.

Would you be interested in trying to change it to a packaging time
configuration?

Not really, I mean, I'm really not trying to be deliberately difficult
or stubborn, it's just that my primary motivation is to try to avoid
re-packaging altogether by making the official gem feasible in these
types of alternate confdir scenarios.

It's really not that big of a deal, so I'm fine just keeping these
ideas on a back burner percolating.

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

Successfully merging this pull request may close these issues.

3 participants