Project

General

Profile

Bug #10906

Puppet environment import returns 500 because it exists in different organization

Added by Tom Zven about 5 years ago. Updated about 5 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Organizations and Locations
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:

Description

Hi,

I have a problem adding or importing new puppet environments in Foreman 1.8.2.

After installing foreman i went to "Puppet classes" and imported the classes from puppetmaster.host.com. This was succesfull and i can see the classes and the environments that they are in (e.g.):

abrt development management production 0 18 0

The problem appears when i try to add a new puppet environment (e.g. development) under Configure->Environments. This fails with "Name has already been taken". I don't see the environment there and I can't assign hosts to it. Import Environments from puppetmaster.host.com also fails.

Warning!
Validation failed: Name has already been taken

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.
ActiveRecord::RecordInvalid
Validation failed: Name has already been taken
app/services/puppet_class_importer.rb:272:in `find_or_create_env'
app/services/puppet_class_importer.rb:192:in `add_classes_to_foreman'
app/services/puppet_class_importer.rb:59:in `block in obsolete_and_new'
app/services/puppet_class_importer.rb:57:in `each'
app/services/puppet_class_importer.rb:57:in `obsolete_and_new'
app/controllers/concerns/foreman/controller/environments.rb:30:in `obsolete_and_new'
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'

Is this an expected behaviour and I should try try importing environments first and then classes?

Related issues

Related to Foreman - Bug #14339: PuppetClassImporter doesn't respect access control or taxonomiesNew2016-03-23
Has duplicate Foreman - Bug #11328: "Name has already been taken" error when importing Puppet classesDuplicate2015-08-11
Has duplicate Foreman - Bug #12048: Unable to import puppet environment "production" via foreman web interfaceDuplicate2015-10-02
Has duplicate Foreman - Bug #14710: After upgrading from 1.8 to 1.10 I have problems importing puppet classes Duplicate2016-04-19

History

#1 Updated by Marek Hulán about 5 years ago

  • Project changed from Smart Proxy to Foreman
  • Category set to Puppet integration

Do you use organizations or locations or do you use any plugins, more specifically katello? There might be environment with the same name hidden out of current context. Anyway if it was the case we should improve displaying the error.

#2 Updated by Tom Zven about 5 years ago

Hi Marek,

Yes katello is installed. The environments are indeed present in the database:

foreman=# select * from environments;
id | name | created_at | updated_at | katello_id | hosts_count | hostgroups_count
----+-------------+----------------------------+----------------------------+------------+-------------+------------------
2 | management | 2015-06-19 13:37:48.278448 | 2015-06-19 13:37:48.278448 | | 0 |
5 | windows | 2015-06-19 13:40:50.746478 | 2015-06-19 13:40:50.746478 | | 0 | 0
1 | development | 2015-06-19 13:36:33.596428 | 2015-06-19 13:36:33.596428 | | 0 | 2
4 | production | 2015-06-19 13:40:23.833636 | 2015-06-19 13:40:23.833636 | | 1 | 0

#3 Updated by Tom Zven about 5 years ago

Ther are also 5 organizations and 4 locations configured. The "production" environment is the one that comes with the default install.

#4 Updated by Marek Hulán about 5 years ago

So the production environment is not set to any organization which is why you don't see it, when you try to create it during import, it fails because it conflicts with the existing one. I suppose you can edit the environment and assign it to all organizations and locations that should use it.

#5 Updated by Tom Zven about 5 years ago

Correct, it wasn't added to any organizations.

So this is not a bug, it was a configuration issue.

Thanks for all the help!

#6 Updated by Marek Hulán about 5 years ago

Well if you saw 500 error page, I'd say it's still a bug in how we treat this error.

#7 Updated by Marek Hulán about 5 years ago

  • Subject changed from Puppet environment import fails to Puppet environment import returns 500 because it exists in different organization
  • Category changed from Puppet integration to Organizations and Locations

#8 Updated by Dominic Cleal about 4 years ago

  • Has duplicate Bug #11328: "Name has already been taken" error when importing Puppet classes added

#9 Updated by Dominic Cleal about 4 years ago

  • Related to Bug #14339: PuppetClassImporter doesn't respect access control or taxonomies added

#10 Updated by Dominic Cleal about 4 years ago

  • Has duplicate Bug #12048: Unable to import puppet environment "production" via foreman web interface added

#11 Updated by Dominic Cleal about 4 years ago

  • Has duplicate Bug #14710: After upgrading from 1.8 to 1.10 I have problems importing puppet classes added

Also available in: Atom PDF