I am getting the following error:
ERROR -- : Failed to list puppet environments: Failed to query Puppet find environments API (400): The environment must be purely alphanumeric, not 'v2.0'
The reason for the error is described in: http://projects.theforeman.org/projects/foreman/wiki/ERF12-2749
Resolution Suggested: Ensure you have foreman-proxy 1.5.2 or higher when using Puppet 3.6+ and directory environments ("environmentpath" setting).
Topology of my environment
--- Puppet Master with Foreman on IP1
Puppet 3.7.5, foreman-1.8.2-1.el6.noarch, ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
--- Puppet Master with Foreman Proxy on IP2 which connects to IP1
Puppet 3.7.5, foreman-proxy-1.7.5-1.el6.noarch and ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
Both puppet masters are configured to have directory environment path the same way. I am able to import classes from IP1 where foreman also resides. But not from IP2 where only foreman-proxy is installed.
I am able to see IP2 registered to IP1.
Trying to import puppet classes from IP2 from foreman sitting on IP1 is throwing the above error.
Command tried from IP1 to list puppet environments of IP2: (This is to replicate the error I am getting in foreman from CLI)
curl -vs \
--key /var/lib/puppet/ssl/private_keys/ip2.dns.com.pem \
--cacert /var/lib/puppet/ssl/certs/ca.pem \
--cert /var/lib/puppet/ssl/certs/ip2-dns.com.pem \
https://ip2-dns.com:8443/puppet/environments
Error reported in ip2 proxy logs:
[root@ip2 httpd]# tail -f /var/log/foreman-proxy/proxy.log
E, [2015-09-10T14:52:10.201506 #24275] ERROR -- : Failed to list puppet environments: Failed to query Puppet find environments API (400): The environment must be purely alphanumeric, not 'v2.0'
ip1 - - [10/Sep/2015 14:52:10] "GET /environments HTTP/1.1" 406 143 1.8941
E, [2015-09-10T14:53:33.477247 #24275] ERROR -- : Failed to list puppet environments: Failed to query Puppet find environments API (400): The environment must be purely alphanumeric, not 'v2.0'
ip1 - - [10/Sep/2015 14:53:33] "GET /environments HTTP/1.1" 406 143 0.5582
E, [2015-09-10T14:56:59.390056 #24275] ERROR -- : Failed to list puppet environments: Failed to query Puppet find environments API (400): The environment must be purely alphanumeric, not 'v2.0'
ip1 - - [10/Sep/2015 14:56:59] "GET /environments HTTP/1.1" 406 143 0.5364
E, [2015-09-10T14:57:11.816250 #24275] ERROR -- : Failed to list puppet environments: Failed to query Puppet find environments API (400): The environment must be purely alphanumeric, not 'v2.0'
ip1 - - [10/Sep/2015 14:57:11] "GET /environments HTTP/1.1" 406 143 0.5434
E, [2015-09-11T09:18:12.636880 #24275] ERROR -- : Failed to list puppet environments: Failed to query Puppet find environments API (400): The environment must be purely alphanumeric, not 'v2.0'
ip1 - - [11/Sep/2015 09:18:12] "GET /environments HTTP/1.1" 406 143 0.5595
Error While Importing classes in foreman:
Warning!
ERF12-2749 [ProxyAPI::ProxyException]: Unable to get environments from Puppet ([RestClient::NotAcceptable]: 406 Not Acceptable) for proxy https://ip2: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-2749 [ProxyAPI::ProxyException]: Unable to get environments from Puppet ([RestClient::NotAcceptable]: 406 Not Acceptable) for proxy https://devci2-puppet.vzbi.com:8443/puppet
lib/proxy_api/puppet.rb:11:in `rescue in environments'
lib/proxy_api/puppet.rb:9:in `environments'
app/services/puppet_class_importer.rb:131:in `actual_environments'
app/services/puppet_class_importer.rb:23:in `changes'
app/controllers/concerns/foreman/controller/environments.rb:11:in `import_environments'
app/controllers/concerns/application_shared.rb:13:in `set_timezone'
app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
lib/middleware/catch_json_parse_errors.rb:9:in `call'
http://projects.theforeman.org/issues/11780
Seems the issue is the installation had both puppet package and puppet gem. Puppet package was of version 2.7.x and puppet gem was of version 3.7.x
I will have to get this corrected.