Bug #10906
openPuppet environment import returns 500 because it exists in different organization
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.
Is this an expected behaviour and I should try try importing environments first and then classes?Warning!
Validation failed: Name has already been takenIf 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'
Updated by Marek Hulán over 9 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.
Updated by Tom Zven over 9 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
Updated by Tom Zven over 9 years ago
Ther are also 5 organizations and 4 locations configured. The "production" environment is the one that comes with the default install.
Updated by Marek Hulán over 9 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.
Updated by Tom Zven over 9 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!
Updated by Marek Hulán over 9 years ago
Well if you saw 500 error page, I'd say it's still a bug in how we treat this error.
Updated by Marek Hulán over 9 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
Updated by Dominic Cleal over 8 years ago
- Has duplicate Bug #11328: "Name has already been taken" error when importing Puppet classes added
Updated by Dominic Cleal over 8 years ago
- Related to Bug #14339: PuppetClassImporter doesn't respect access control or taxonomies added
Updated by Dominic Cleal over 8 years ago
- Has duplicate Bug #12048: Unable to import puppet environment "production" via foreman web interface added
Updated by Dominic Cleal over 8 years ago
- Has duplicate Bug #14710: After upgrading from 1.8 to 1.10 I have problems importing puppet classes added