Bug #8547
puppetstoredconfigclean checks only [master] for database configuration, should also check [main]
| Status: | Re-opened | Start date: | 07/21/2011 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | ext | |||
| Target version: | - | |||
| Affected Puppet version: | 2.6.8 | Branch: | ||
| Keywords: | puppetstoredconfigclean | |||
| Votes: | 0 |
Description
I use stored configs on the puppetmaster. The database information is in the [main] section of puppet.conf (because of queuing, puppetqd checks the [main] for this information).
The [master] section of puppet.conf is empty. Puppet works as expected. However,
puppetstoredconfigclean
doesn’t
The following error is thrown:
/usr/sbin/puppetstoredconfigclean:74: Invalid db adapter (ArgumentError)
When the database information is specified in the [master] section, puppetstoredconfigclean works as expected. I would expect that puppetstoredconfigclean behaves the same as the puppetmaster when reading it’s configuration.
The puppet version is 2.6.8 from debian-backports.
History
Updated by Nan Liu 9 months ago
- Status changed from Unreviewed to Investigating
- Assignee set to Nan Liu
This is technically an ext script, so part of the extra scripts and not core. I don’t think this is as rigorously supported and tested. However please check the following branch:
https://github.com/nanliu/puppet/blob/ticket%2F2.7.x%2F8547/ext/puppetstoredconfigclean.rb
If the patch is sufficient, I’ll send it for merging against puppet.
Updated by Pieter Lexis 9 months ago
The patched script does the job, However, the problem is now reversed.
When the DB information is in main (and not in master), the new version works When the DB information is in master (and not in main), the new version doesn’t work (it tries to open a sqlite DB):
/usr/lib/ruby/1.8/sqlite3/errors.rb:62:in `check': could not open database: unable to open database file (SQLite3::CantOpenException)
When the DB information is in main (and not in master), the packaged version is broken (Invalid db adapter (ArgumentError)) When the DB information is in master (and not in main), the packaged version works.
So, while the new script is a solution for me, it isn’t a permanent solution, as it will most likely break other setups.
Updated by Nan Liu 9 months ago
Ok, I had a chance to look at this, it’s appears puppet use run_mode to determine the setting. I’m not sure what implications we have setting run_mode :master which also requires this script to be rewritten as a Puppet::Application. I think it was best avoided when I saw the comment with set_run_mode. Also Puppet.settings.use(:main, :master) alone wan’t sufficient and puppet was trying to create directories specified in the config file, which was beyond the purpose of this tool, so I did another rewrite to merge the config hash instead and load the puppet defaults for missing values.
https://github.com/nanliu/puppet/blob/ticket%2F2.7.x%2F8547/ext/puppetstoredconfigclean.rb
Updated by Pieter Lexis 9 months ago
The last script works as expected, whether the DB information is in [main] or [master].
Thanks!
Updated by James Turnbull 9 months ago
- Status changed from Investigating to Needs Decision
Nan – could you turn this into a final patch and pull request please. Thanks!
Updated by Nan Liu 7 months ago
- Status changed from Needs Decision to In Topic Branch Pending Review
- Assignee deleted (
Nan Liu)
Submitted pull request: https://github.com/puppetlabs/puppet/pull/171
Updated by Patrick Carlisle 6 months ago
- Status changed from In Topic Branch Pending Review to Merged - Pending Release
- Target version set to 2.7.9
Merged in commit:5e46f6ae171ad975b36c638c69cd72be5d8fafa4
(#8547) Update storeconfigclean script to read puppet.conf
The existing storeconfig script is parsing and reading puppet.conf
specifically from the master section. This change allows the script to
read from the settings from puppet.conf in the order of master, main,
and loads the rails default. This should match the puppet application
behaviour.
Updated by Michael Stahnke 4 months ago
- Status changed from Merged - Pending Release to Closed
- Target version changed from 2.7.9 to 2.7.10
Closed and released in 2.7.10rc1
Updated by Jason Hancock 3 months ago
- Status changed from Closed to Re-opened
- Target version deleted (
2.7.10)
I have a problem with the patch….I’m running 2.7.10 with stored configs turned on and using MySQL as the dbadapter. My database settings are in the [master] section of /etc/puppet/puppet.conf.
The problem is that puppet.conf isn’t getting read at all now….all of the settings are getting their default values. I noticed this because I got a stack trace complaining about not being able to load the sqlite3 driver. Some investigation and puts debugging inside the puppetstoredconfigclean.rb script proved that it wasn’t picking up the settings from puppet.conf.
I traced the problem back to this code:
if config != Puppet[:config]
Puppet[:config]=config
Puppet.settings.parse
end
To get it to work for my case, I moved the call to Puppet.settings.parse outside the if statement and it now works fine.
if config != Puppet[:config]
Puppet[:config]=config
end
Puppet.settings.parse
I didn’t test the case where you have the db settings in the [main] section.