Facter 2.0.1 produces an error

Hello,

With recently installed machines, I observe the following error in the
puppet agent log :

Info: Retrieving pluginfacts
Error: /File[/var/lib/puppet/facts.d]: Failed to generate additional
resources using 'eval_generate': Error 400 on SERVER: Not authorized to
call search on /file_metadata/pluginfacts with {:recurse=>true,
:checksum_type=>"md5", :ignore=>[".svn", "CVS", ".git"], :links=>"manage"}
Error: /File[/var/lib/puppet/facts.d]: Could not evaluate: Could not
retrieve file metadata for puppet://nanpuppet01.in2p3.fr/pluginfacts:
Error 400 on SERVER: Not authorized to call find on
/file_metadata/pluginfacts with {:links=>"manage",
:source_permissions=>"use"}
Wrapped exception:
Error 400 on SERVER: Not authorized to call find on
/file_metadata/pluginfacts with {:links=>"manage",
:source_permissions=>"use"}

I believe this is because these machines have facter v2.0.1.

This does not happen on machines equiped with facter v1.7.5.

=> What can I do ?

Thanks

JM

··· -- ------------------------------------------------------------------------ Jean-michel BARBET | Tel: +33 (0)2 51 85 84 86 Laboratoire SUBATECH Nantes France | Fax: +33 (0)2 51 85 84 79 CNRS-IN2P3/Ecole des Mines/Universite | E-Mail: barbet@subatech.in2p3.fr ------------------------------------------------------------------------

Hello,

I was happy to see that upgrading facter on the Puppet/Foreman server
suppresses this message but Foreman does not like it and I get this
error when accessing Foreman dashboard :

··· On 04/29/2014 09:57 AM, Jean-Michel Barbet wrote: > Hello, > > With recently installed machines, I observe the following error in the > puppet agent log : > > Info: Retrieving pluginfacts > Error: /File[/var/lib/puppet/facts.d]: Failed to generate additional > resources using 'eval_generate': Error 400 on SERVER: Not authorized to > call search on /file_metadata/pluginfacts with {:recurse=>true, > :checksum_type=>"md5", :ignore=>[".svn", "CVS", ".git"], :links=>"manage"} > Error: /File[/var/lib/puppet/facts.d]: Could not evaluate: Could not > retrieve file metadata for puppet://nanpuppet01.in2p3.fr/pluginfacts: > Error 400 on SERVER: Not authorized to call find on > /file_metadata/pluginfacts with {:links=>"manage", > :source_permissions=>"use"} > Wrapped exception: > Error 400 on SERVER: Not authorized to call find on > /file_metadata/pluginfacts with {:links=>"manage", > :source_permissions=>"use"} > > I believe this is because these machines have facter v2.0.1. > > This does not happen on machines equiped with facter v1.7.5.

Ruby (Rack) application could not be started
These are the possible causes:

 There may be a syntax error in the application's code. Please check 

for such errors and fix them.
A required library may not installed. Please install all libraries
that this application requires.
The application may not be properly configured. Please check
whether all configuration files are written correctly, fix any incorrect
configurations, and restart this application.
A service that the application relies on (such as the database
server or the Ferret search engine server) may not have been started.
Please start that service.

Further information about the error may have been written to the
application’s log file. Please check it in order to analyse the problem.

Error message:
undefined method domain' for Facter:Module Exception class: NoMethodError Application root: /usr/share/foreman Backtrace: # File Line Location 0 /usr/share/foreman/lib/foreman/default_settings/loader.rb 34 inload’
1
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.20/lib/active_record/connection_adapters/abstract/database_statements.rb
139 in transaction' 2 /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.20/lib/active_record/transactions.rb 207 intransaction’
3 /usr/share/foreman/lib/foreman/default_settings/loader.rb 33
in load' 4 /usr/share/foreman/config/initializers/foreman.rb 4 5 /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.20/lib/active_support/dependencies.rb 236 inload’
6
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.20/lib/active_support/dependencies.rb
236 in load' 7 /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.20/lib/active_support/dependencies.rb 227 inload_dependency’
8
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.20/lib/active_support/dependencies.rb
236 in load' 9 /usr/lib/ruby/gems/1.8/gems/railties-3.0.20/lib/rails/engine.rb 201 10 /usr/lib/ruby/gems/1.8/gems/railties-3.0.20/lib/rails/engine.rb 200 ineach’
11
/usr/lib/ruby/gems/1.8/gems/railties-3.0.20/lib/rails/engine.rb 200
12
/usr/lib/ruby/gems/1.8/gems/railties-3.0.20/lib/rails/initializable.rb 25
in instance_exec' 13 /usr/lib/ruby/gems/1.8/gems/railties-3.0.20/lib/rails/initializable.rb 25 inrun’
14
/usr/lib/ruby/gems/1.8/gems/railties-3.0.20/lib/rails/initializable.rb 50
in run_initializers' 15 /usr/lib/ruby/gems/1.8/gems/railties-3.0.20/lib/rails/initializable.rb 49 ineach’
16
/usr/lib/ruby/gems/1.8/gems/railties-3.0.20/lib/rails/initializable.rb 49
in run_initializers' 17 /usr/lib/ruby/gems/1.8/gems/railties-3.0.20/lib/rails/application.rb 134 ininitialize!'
18
/usr/lib/ruby/gems/1.8/gems/railties-3.0.20/lib/rails/application.rb
77 in send' 19 /usr/lib/ruby/gems/1.8/gems/railties-3.0.20/lib/rails/application.rb 77 inmethod_missing’
20 /usr/share/foreman/config/environment.rb 5
21 config.ru 3 in require' 22 config.ru 3 23 /usr/lib/ruby/gems/1.8/gems/rack-1.2.5/lib/rack/builder.rb 46 ininstance_eval’
24 /usr/lib/ruby/gems/1.8/gems/rack-1.2.5/lib/rack/builder.rb
46 in initialize' 25 config.ru 1 innew’
26 config.ru 1

I suppose I should also update some of the foreman packages but
which ones (considering that I still run Foreman 1.1)

rpm -qa | grep foreman
foreman-installer-1.1.2-1.noarch
foreman-proxy-1.1stable-1.el6.noarch
foreman-mysql-1.1stable-3.el6.noarch
foreman-release-1.1stable-3.el6.noarch
foreman-1.1stable-3.el6.noarch

JM

Jean-michel BARBET | Tel: +33 (0)2 51 85 84 86
Laboratoire SUBATECH Nantes France | Fax: +33 (0)2 51 85 84 79
CNRS-IN2P3/Ecole des Mines/Universite | E-Mail: barbet@subatech.in2p3.fr

All of them :slight_smile:

There was an API change in Facter between v1 and v2, which we adapted to
in Foreman 1.4.2.

http://theforeman.org/manuals/1.4/index.html#3.1.2PuppetCompatibility

Alternatively you can patch the source where these errors occur. It's a
simple change moving from "Facter.domain" to "Facter.value(:domain)"
(ditto for .fqdn etc).

··· On 30/04/14 09:19, Jean-Michel Barbet wrote: > On 04/29/2014 09:57 AM, Jean-Michel Barbet wrote: > I suppose I should also update some of the foreman packages but > which ones (considering that I still run Foreman 1.1) > > rpm -qa | grep foreman > foreman-installer-1.1.2-1.noarch > foreman-proxy-1.1stable-1.el6.noarch > foreman-mysql-1.1stable-3.el6.noarch > foreman-release-1.1stable-3.el6.noarch > foreman-1.1stable-3.el6.noarch


Dominic Cleal
Red Hat Engineering

Thank you Dominic,

I know I have to go to Foreman 1.4 and it is on my ToDo list but it
looks like a serious business and I need time to plan it. So I would
rather patch to solve the issue immediately. Do you know which files
exactly should be patched ?

JM

··· On 04/30/2014 10:27 AM, Dominic Cleal wrote:

All of them :slight_smile:

There was an API change in Facter between v1 and v2, which we adapted to
in Foreman 1.4.2.

Foreman :: Manual

Alternatively you can patch the source where these errors occur. It’s a
simple change moving from “Facter.domain” to “Facter.value(:domain)”
(ditto for .fqdn etc).

Jean-michel BARBET | Tel: +33 (0)2 51 85 84 86
Laboratoire SUBATECH Nantes France | Fax: +33 (0)2 51 85 84 79
CNRS-IN2P3/Ecole des Mines/Universite | E-Mail: barbet@subatech.in2p3.fr

Below are the instances I can see in 1.1 which need changing - again,
just change any "Facter.example" call to "Facter.value(:example)".

lib/tasks/reset_permissions.rake
4: user = User.find_or_create_by_login(:login => "admin", :firstname
=> "Admin", :lastname => "User", :mail => "root@#{Facter.domain}")

lib/foreman/default_settings/loader.rb
34: domain = Facter.domain
59: param_enc =
Gem::Version.new(Facter.puppetversion.split('-').first) >=
Gem::Version.new('2.6.5')

db/migrate/20100628123400_add_internal_auth.rb
9: user = User.unscoped.find_or_create_by_login(:login => "admin",
:firstname => "Admin", :lastname => "User", :mail =>
"root@#{Facter.domain}")

db/migrate/20100419151910_add_owner_to_hosts.rb
12: email = SETTINGS[:administrator] || "root@#{Facter.domain}"

config/initializers/puppet.rb
43:if Facter.puppetversion == "0.25.5"

··· On 30/04/14 09:46, Jean-Michel Barbet wrote: > On 04/30/2014 10:27 AM, Dominic Cleal wrote: > >> All of them :) >> >> There was an API change in Facter between v1 and v2, which we adapted to >> in Foreman 1.4.2. >> >> http://theforeman.org/manuals/1.4/index.html#3.1.2PuppetCompatibility >> >> Alternatively you can patch the source where these errors occur. It's a >> simple change moving from "Facter.domain" to "Facter.value(:domain)" >> (ditto for .fqdn etc). > > Thank you Dominic, > > I know I have to go to Foreman 1.4 and it is on my ToDo list but it > looks like a serious business and I need time to plan it. So I would > rather patch to solve the issue immediately. Do you know which files > exactly should be patched ?


Dominic Cleal
Red Hat Engineering

Thank you very much, it work again by changing at least :

lib/foreman/default_settings/loader.rb
config/initializers/puppet.rb

I suppose the db/migrate is used only for db migration and I am not
sure when lib/tasks/reset_permissions.rake is used.

Service restored it seems. Thank you very much.

As for the upgrade to Foreman 14., I have several options (it is a
virtual machine)

a) snapshot the VM and attempt an "in place migration"
b) install a brand new VM with Foreman 1.4 and import all the data
(puppet manifests, foreman db)

=> Which scenario do you recommend ?

JM

··· On 04/30/2014 10:53 AM, Dominic Cleal wrote:

Below are the instances I can see in 1.1 which need changing - again,
just change any “Facter.example” call to “Facter.value(:example)”.

Jean-michel BARBET | Tel: +33 (0)2 51 85 84 86
Laboratoire SUBATECH Nantes France | Fax: +33 (0)2 51 85 84 79
CNRS-IN2P3/Ecole des Mines/Universite | E-Mail: barbet@subatech.in2p3.fr

I'd suggest (b), as the installation on EL6 has changed quite a bit
since 1.1 so you'll get a lot of benefits by running the installer on a
clean system.

You should copy /var/lib/puppet/ssl over first if this is also your
puppet master (CA), but you can copy the DB over after and then run the
DB migration.

There have been some small gotchas with DB migrations, so you should be
ready to retry this a few times from a backup of the original.

Bug #4518: DB migrations: Can't DROP 'role_id'; check that column/key exists - Foreman in particular comes to mind,
which seems to affect older databases as they're upgraded. There are
also some useful notes on
Migration 043 to 14 - Foreman
from a recent upgrade from 0.4.3 to 1.4 - though it's written for
Debian, much will be relevant still.

··· On 30/04/14 09:59, Jean-Michel Barbet wrote: > On 04/30/2014 10:53 AM, Dominic Cleal wrote: > >> Below are the instances I can see in 1.1 which need changing - again, >> just change any "Facter.example" call to "Facter.value(:example)". > > Thank you very much, it work again by changing at least : > > lib/foreman/default_settings/loader.rb > config/initializers/puppet.rb > > I suppose the db/migrate is used only for db migration and I am not > sure when lib/tasks/reset_permissions.rake is used. > > Service restored it seems. Thank you very much. > > As for the upgrade to Foreman 14., I have several options (it is a > virtual machine) > > a) snapshot the VM and attempt an "in place migration" > b) install a brand new VM with Foreman 1.4 and import all the data > (puppet manifests, foreman db) > > => Which scenario do you recommend ?


Dominic Cleal
Red Hat Engineering