Bug #5856

Cannot import environments, classes even with foreman 1.5.0

Added by Dis McCarthy over 3 years ago. Updated over 3 years ago.

Status:Closed
Priority:Urgent
Assigned To:Dominic Cleal
Category:Puppet
Target version:Foreman - Sprint 24
Difficulty: Bugzilla link:1107678
Found in release:1.5.0 Pull request:
Story points-
Velocity based estimate-
Release1.5.1Release relationshipAuto

Description

Superficially similar to #5792, but we are running Foreman and proxy at 1.5.0.

Clicking 'import classes from puppetmaster' or 'import environments from puppetmaster' results in the 406 error, and the foreman proxy logs show:

I, [2014-05-21T11:41:30.462997 #20033]  INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf
I, [2014-05-21T11:41:30.590418 #20033]  INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf
I, [2014-05-21T11:41:30.720226 #20033]  INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf
I, [2014-05-21T11:41:30.785593 #20033]  INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf
E, [2014-05-21T11:41:30.892108 #20033] ERROR -- : Failed to show puppet classes: no 'environments' in {:root_environment=>#<Puppet::Node::Environment:0x7f4427990d28 @config_version=nil, @name=:"*root*", @manifest="/etc/foreman-proxy", @modulepath=[], @watching=true>, :current_environment=>#<Puppet::Node::Environment:0x7f4427990d28 @config_version=nil, @name=:"*root*", @manifest="/etc/foreman-proxy", @modulepath=[], @watching=true>} at top of []

# rpm -qa \*foreman\*
foreman-compute-1.5.0-1.el6.noarch
foreman-proxy-1.5.0-1.el6.noarch
foreman-release-1.5.0-1.el6.noarch
foreman-postgresql-1.5.0-1.el6.noarch
rubygem-foreman_api-0.1.11-1.el6.noarch
foreman-selinux-1.5.0-1.el6.noarch
foreman-vmware-1.5.0-1.el6.noarch
foreman-installer-1.5.0-1.el6.noarch
rubygem-hammer_cli_foreman-0.1.0-1.el6.noarch
foreman-1.5.0-1.el6.noarch
# rpm -qa \*puppet\*
puppet-3.6.0-1.el6.noarch
mcollective-puppet-common-1.7.2-1.el6.noarch
mcollective-puppet-client-1.7.2-1.el6.noarch
puppetlabs-release-6-10.noarch
mcollective-puppet-agent-1.7.2-1.el6.noarch
puppetdb-2.0.0-1.el6.noarch
puppet-server-3.6.0-1.el6.noarch
puppetdb-terminus-2.0.0-1.el6.noarch
ruby193-puppet-3.1.1-6.el6.noarch

puppet.conf (2.32 KB) Ollie Lawson, 06/05/2014 09:57 AM

puppet.conf (2.32 KB) Ollie Lawson, 06/05/2014 09:57 AM


Related issues

Duplicated by Smart Proxy - Bug #5867: Cannot Import Puppet Envioronments Duplicate 05/22/2014

Associated revisions

Revision 1dc369d4
Added by Dominic Cleal over 3 years ago

fixes #5856 - use public initializer for Puppet settings

History

#1 Updated by Dominic Cleal over 3 years ago

  • Project changed from Foreman to Smart Proxy
  • Category changed from Importers to Puppet

#2 Updated by Dominic Cleal over 3 years ago

Could you attach your puppet.conf? I think this might happen if you don't have explicit environment sections.

#3 Updated by Dis McCarthy over 3 years ago

It was installed originally with a puppet-apply based installer but is maintained manually.

### File managed with puppet ###
## Module:           'puppet'
## Template source:  'MODULES/puppet/templates/puppet.conf.erb'

[main]
    # The Puppet log directory.
    # The default value is '$vardir/log'.
    logdir = /var/log/puppet

    # Where Puppet PID files are kept.
    # The default value is '$vardir/run'.
    rundir = /var/run/puppet

    # Where SSL certificates are kept.
    # The default value is '$confdir/ssl'.
    ssldir = $vardir/ssl

    # Allow services in the 'puppet' group to access key (Foreman + proxy)
    privatekeydir = $ssldir/private_keys { group = service }
    hostprivkey = $privatekeydir/$certname.pem { mode = 640 }

    # Puppet 3.0.x requires this in both [main] and [master] - harmless on agents
    autosign       = $confdir/autosign.conf { mode = 664 }

[agent]
    # The file in which puppetd stores a list of the classes
    # associated with the retrieved configuratiion.  Can be loaded in
    # the separate ``puppet`` executable using the ``--loadclasses``
    # option.
    # The default value is '$confdir/classes.txt'.
    classfile = $vardir/classes.txt

    # Where puppetd caches the local configuration.  An
    # extension indicating the cache format is added automatically.
    # The default value is '$confdir/localconfig'.
    localconfig = $vardir/localconfig
    report      = true
    pluginsync  = true
    masterport  = 8140
    #environment = production
    certname    = hostname.here
    server      = hostname.here
    listen      = false
    splay       = false
    runinterval = 1800
    noop        = false
    show_diff   = true
    modulepath     = /etc/puppet/environments/$environment/modules:/etc/puppet/environments/common:/usr/share/puppet/modules
    environment=nonop

### Next part of the file is managed by a different template ###
## Module:           'puppet'
## Template source:  'MODULES/puppet/templates/server/puppet.conf.erb'

[master]
    autosign       = $confdir/autosign.conf { mode = 664 }
    reports        = foreman
    external_nodes = /etc/puppet/node.rb
    node_terminus  = exec
    ca             = true
    ssldir         = /var/lib/puppet/ssl
    storeconfigs = true
    storeconfigs_backend = puppetdb

[development]
    modulepath     = /etc/puppet/environments/development/modules:/etc/puppet/environments/common:/etc/puppet/environments/baseline-master:/usr/share/puppet/modules
    config_version = 
[test]
    modulepath     = /etc/puppet/environments/test/modules:/etc/puppet/environments/common:/etc/puppet/environments/baseline-master:/usr/share/puppet/modules
    config_version = 
#[production]
#    modulepath     = /etc/puppet/environments/production/modules:/etc/puppet/environments/common:/usr/share/puppet/modules
#    config_version = 
[nonop]
    modulepath     = /etc/puppet/environments/nonop/modules:/etc/puppet/environments/common:/etc/puppet/environments/baseline:/usr/share/puppet/modules
    config_version = 
[operational]
    modulepath     = /etc/puppet/environments/operational/modules:/etc/puppet/environments/common:/etc/puppet/environments/baseline:/usr/share/puppet/modules
    config_version = 

[frozen]
    modulepath     = /etc/puppet/environments/frozen/modules
    config_version = 

#4 Updated by Xesc Arbona over 3 years ago

Hi,

I've run into the same issue, and solve it by downgrading puppet to version 3.5.1.

curl -k -H "Content-Type:application/json" -H "Accept:application/json" http://localhost:8443/puppet/environments
["acceptance","development"]

curl -k -H "Content-Type:application/json" -H "Accept:application/json" http://localhost:8443/puppet/environments/acceptance/classes
Failed to show puppet classes: no 'environments' in {:current_

apt-get install puppet=3.5.1-1puppetlabs1 puppet-common=3.5.1-1puppetlabs1 puppetmaster=3.5.1-1puppetlabs1 puppetmaster-common=3.5.1-1puppetlabs1
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
puppet-el vim-puppet ruby-selinux libselinux-ruby1.8 librrd-ruby1.9.1 librrd-ruby1.8 stompserver ruby-ldap libldap-ruby1.8
The following packages will be DOWNGRADED:
puppet puppet-common puppetmaster puppetmaster-common

/etc/init.d/foreman-proxy restart

curl -k -H "Content-Type:application/json" -H "Accept:application/json" http://localhost:8443/puppet/environments/acceptance/classes
[{"postfix::satellite":{"name":"satellite","module":"postfix","params":{}}},{"postfix":{"name":"postfix","module":null,"params":{"postfix_smtp_listen":"127.0.0.1","root_mail_recipient":"nobody","postfix_use_amavisd":"no","postfix_use_dovecot_lda":"no","postfix_use_schleuder":"no","postfix_use_sympa":"no","postfix_mail_user":"postfix","postfix_mail_origin":"${$::fqdn}"}}},{"p....

Foreman 1.5 does not seem comaptible with Puppet 3.6, see http://theforeman.org/manuals/1.5/index.html#3.1.2PuppetCompatibility

I guess it has to do with directory environments mixed up?

#5 Updated by Dominic Cleal over 3 years ago

  • Priority changed from Normal to Urgent
  • Target version set to Sprint 24
  • Release set to 1.5.1

#6 Updated by Dominic Cleal over 3 years ago

  • Duplicated by Bug #5867: Cannot Import Puppet Envioronments added

#7 Updated by Jon Skarpeteig over 3 years ago

Using Foreman 1.5.0 and Puppet 3.6.0 on remote node

From foreman-proxy.log

I, [2014-05-22T16:17:41.243564 #30842]  INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf
W, [2014-05-22T16:17:41.284902 #30842]  WARN -- : No environments found - falling back to defaults (production - /etc/puppet/modules)
I, [2014-05-22T16:17:41.626662 #30842]  INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf
W, [2014-05-22T16:17:41.662242 #30842]  WARN -- : No environments found - falling back to defaults (production - /etc/puppet/modules)
I, [2014-05-22T16:17:41.662626 #30842]  INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf
I, [2014-05-22T16:17:41.742015 #30842]  INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf
E, [2014-05-22T16:17:41.768046 #30842] ERROR -- : Failed to show puppet classes: no 'environments' in {:current_environment=>#<Puppet::Node::Environment:0x7f797da688f0 @modulepath=[], @watching=true, @name=:"*root*", @config_version=nil, @manifest="/">, :root_environment=>#<Puppet::Node::Environment:0x7f797da688f0 @modulepath=[], @watching=true, @name=:"*root*", @config_version=nil, @manifest="/">} at top of []

From GUI:

Oops, we're sorry but something went wrong

Warning!
ERF12-4115 [ProxyAPI::ProxyException]: Unable to get classes from Puppet for production ([RestClient::NotAcceptable]: 406 Not Acceptable) for proxy http://host.fqdn:8443/puppet

If you feel this is an error with Foreman itself, please open a new issue with Foreman ticketing system, You would probably need to attach the Full trace and relevant log entries.
ProxyAPI::ProxyException
ERF12-4115 [ProxyAPI::ProxyException]: Unable to get classes from Puppet for production ([RestClient::NotAcceptable]: 406 Not Acceptable) for proxy http://host.fqdn:8443/puppet
lib/proxy_api/puppet.rb:27:in `rescue in classes'
lib/proxy_api/puppet.rb:21:in `classes'
app/services/puppet_class_importer.rb:155:in `actual_classes'
app/services/puppet_class_importer.rb:78:in `new_classes_for'
app/services/puppet_class_importer.rb:25:in `block in changes'
app/services/puppet_class_importer.rb:24:in `each'
app/services/puppet_class_importer.rb:24:in `changes'
app/controllers/concerns/foreman/controller/environments.rb:11:in `import_environments'
app/models/concerns/foreman/thread_session.rb:33:in `clear_thread'
lib/middleware/catch_json_parse_errors.rb:9:in `call'

#8 Updated by Jon Skarpeteig over 3 years ago

No way to edit posts?

#9 Updated by Dominic Cleal over 3 years ago

Jon Skarpeteig wrote:

No way to edit posts?

You should be able to now, you weren't "joined" to the project as a reporter.

#10 Updated by Dominic Cleal over 3 years ago

  • Status changed from New to Assigned
  • Assigned To set to Dominic Cleal

Paul, as a workaround, uncommenting the production environment in your puppet.conf seems to get it working.

Xesc, we don't currently support directory environments if that's what you meant (#4699) and it may throw a confusingly identical error message if you attempt to do this. If you're using ordinary (older style) environments then please attach your puppet.conf.

Jon, could you attach your puppet.conf please?

#11 Updated by Dominic Cleal over 3 years ago

  • Status changed from Assigned to Ready For Testing

Don't worry about puppet.conf, I got what I needed from the foreman-users list.

If you want to try the patch:

PR: https://github.com/theforeman/smart-proxy/pull/161

#12 Updated by Dis McCarthy over 3 years ago

That patch worked for us.

Thanks!

#13 Updated by Paul Calabro over 3 years ago

Thanks! That worked w/o error! :)

#14 Updated by Ollie Lawson over 3 years ago

I have applied the patch above with Foreman 1.5.0 and Puppet 3.6.1 but the environments still do not import.

Proxy log shows:
I, [2014-06-05T09:51:10.523466 #22641] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf
W, [2014-06-05T09:51:10.624875 #22641] WARN -- : No environments found - falling back to defaults (production - /etc/puppet/modules)
I, [2014-06-05T09:51:10.626139 #22641] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf
I, [2014-06-05T09:51:10.670755 #22641] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf
I, [2014-06-05T09:55:00.603963 #23649] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf
W, [2014-06-05T09:55:00.748032 #23649] WARN -- : No environments found - falling back to defaults (production - /etc/puppet/modules)
I, [2014-06-05T09:55:00.898409 #23649] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf
W, [2014-06-05T09:55:00.943845 #23649] WARN -- : No environments found - falling back to defaults (production - /etc/puppet/modules)
I, [2014-06-05T09:55:00.944576 #23649] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf
I, [2014-06-05T09:55:01.048171 #23649] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf

Puppet.conf file is attached

Thanks

Ollie

#15 Updated by Dominic Cleal over 3 years ago

Ollie Lawson wrote:

I have applied the patch above with Foreman 1.5.0 and Puppet 3.6.1 but the environments still do not import.

Your puppet.conf shows you're using directory environments ("environmentpath"), which we don't yet support (#4699). Although they're now deprecated in 3.6, I'd suggest using the old style environments.

#16 Updated by Dominic Cleal over 3 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#17 Updated by Bryan Kearney over 3 years ago

  • Bugzilla link set to https://bugzilla.redhat.com/show_bug.cgi?id=1107678

#18 Updated by Paul Calabro over 3 years ago

I didn't have to downgrade to an earlier version of Puppet to resolve this issue. I'm on 3.6.2 and I'm working fine.
I just had to use the older style of declaring environments.
Is there some unintentional side-effect that I'm permitting that I'm not aware of?

#19 Updated by Elisiano Petrini over 3 years ago

Dominic Cleal wrote:

Don't worry about puppet.conf, I got what I needed from the foreman-users list.

If you want to try the patch:

PR: https://github.com/theforeman/smart-proxy/pull/161

Hi All,
I tried to apply this patch but I had no benefit from it.

I'm a bit reluctant to go back to config environments because puppet would start throwing out deprecation warnings.
Is there a solution for this?

Thanks for your help.

Puppet 3.6.2, Foreman 1.5 (with above patch)

#20 Updated by Dominic Cleal over 3 years ago

As per my above comment(s), directory environments are not supported at the moment and this patch does not provide support. It only fixes an issue with initialising Puppet 3.6.

You'll need to use the older configured environments with deprecation warnings (though the next version of Puppet may provide controls over what deprecation warnings you see). Please follow #4699 for directory environment support.

#21 Updated by Elisiano Petrini over 3 years ago

Dominic Cleal wrote:

As per my above comment(s), directory environments are not supported at the moment and this patch does not provide support. It only fixes an issue with initialising Puppet 3.6.

You'll need to use the older configured environments with deprecation warnings (though the next version of Puppet may provide controls over what deprecation warnings you see). Please follow #4699 for directory environment support.

Apologies for the mixup.
I guess living with deprecation warnings is better than not having Foreman importing classes :).
Following the other ticket now, thanks for your help.

Best Regards.

Also available in: Atom PDF