Forman 0.3-1 & storeconfigs in same database as puppet - migrate fails "Table 'reports' already exists"

Hi all!

I am trying to let forman and puppet share the same database.

Initial Setup was:
DB Empty, Puppet creates everything it needs for storedconfigs,
foreman gets configured to use the same database and
"RAILS_ENV=production rake db:migrate --trace" gets called. And yields
the following error:

puppetdash:/usr/share/foreman# RAILS_ENV=production rake db:migrate –
trace
(in /usr/share/foreman)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
== CreateReports: migrating

··· ================================================== -- create_table(:reports) rake aborted! An error has occurred, all later migrations canceled:

Mysql::Error: Table ‘reports’ already exists: CREATE TABLE reports
(id int(11) DEFAULT NULL auto_increment PRIMARY KEY, host_id
int(11) NOT NULL, log text, reported_at datetime, created_at
datetime, updated_at datetime) ENGINE=InnoDB
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/
connection_adapters/abstract_adapter.rb:227:in log' /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ connection_adapters/mysql_adapter.rb:324:inexecute’
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/
connection_adapters/abstract/schema_statements.rb:109:in
create_table' /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ connection_adapters/mysql_adapter.rb:478:increate_table’
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/
migration.rb:352:in send' /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ migration.rb:352:inmethod_missing’
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/
migration.rb:328:in say_with_time' /usr/lib/ruby/1.8/benchmark.rb:293:inmeasure’
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/
migration.rb:328:in say_with_time' /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ migration.rb:348:inmethod_missing’
./db/migrate//20090729132209_create_reports.rb:3:in
up_without_benchmarks' /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ migration.rb:282:insend’
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/
migration.rb:282:in migrate' /usr/lib/ruby/1.8/benchmark.rb:293:inmeasure’
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/
migration.rb:282:in migrate' /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ migration.rb:365:insend
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/
migration.rb:365:in migrate' /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ migration.rb:491:inmigrate’
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/
migration.rb:567:in call' /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ migration.rb:567:inddl_transaction’
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/
migration.rb:490:in migrate' /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ migration.rb:477:ineach’
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/
migration.rb:477:in migrate' /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ migration.rb:401:inup’
/usr/share/foreman/vendor/rails/activerecord/lib/active_record/
migration.rb:383:in migrate' /usr/share/foreman/vendor/rails/railties/lib/tasks/databases.rake:112 /usr/lib/ruby/1.8/rake.rb:636:incall’
/usr/lib/ruby/1.8/rake.rb:636:in execute' /usr/lib/ruby/1.8/rake.rb:631:ineach’
/usr/lib/ruby/1.8/rake.rb:631:in execute' /usr/lib/ruby/1.8/rake.rb:597:ininvoke_with_call_chain’
/usr/lib/ruby/1.8/monitor.rb:242:in synchronize' /usr/lib/ruby/1.8/rake.rb:590:ininvoke_with_call_chain’
/usr/lib/ruby/1.8/rake.rb:583:in invoke' /usr/lib/ruby/1.8/rake.rb:2051:ininvoke_task’
/usr/lib/ruby/1.8/rake.rb:2029:in top_level' /usr/lib/ruby/1.8/rake.rb:2029:ineach’
/usr/lib/ruby/1.8/rake.rb:2029:in top_level' /usr/lib/ruby/1.8/rake.rb:2068:instandard_exception_handling’
/usr/lib/ruby/1.8/rake.rb:2023:in top_level' /usr/lib/ruby/1.8/rake.rb:2001:inrun’
/usr/lib/ruby/1.8/rake.rb:2068:in standard_exception_handling' /usr/lib/ruby/1.8/rake.rb:1998:inrun’
/usr/bin/rake:28
puppetdash:/usr/share/foreman#

While the error in itself is “correct” (the table/fields do exist) I
think it is wrong that this is raised as an error and the table does
not get expanded, as the documentation states that “If you want to
share the database with Puppets (storeconfig), just modify config/
database.yml to point to the same database configuration as puppet
is.”.

I’d guess that if I cleared out the database and let first foremans
db:migrate and then puppet do its thing it would work, but I’d rather
not do that if anyone could provide a decent workaround.

Or am I just doing something wrong?

Cheers,
Simon

P.s.:
System:
Puppetmaster: Debian Squeeze, puppetmaster 2.6.8 & passenger 2.2.11
via debs
MysqlDB: Debian Lenny, Mysql 5.1
Foreman: 0.3-1 (official deb)

> Hi all!
>
> I am trying to let forman and puppet share the same database.
>
> Initial Setup was:
> DB Empty, Puppet creates everything it needs for storedconfigs,
> foreman gets configured to use the same database and
> "RAILS_ENV=production rake db:migrate --trace" gets called. And yields
> the following error:
>
> puppetdash:/usr/share/foreman# RAILS_ENV=production rake db:migrate –
> trace
> (in /usr/share/foreman)
> ** Invoke db:migrate (first_time)
> ** Invoke environment (first_time)
> ** Execute environment
> ** Execute db:migrate
> == CreateReports: migrating
> ==================================================
> – create_table(:reports)
> rake aborted!
> An error has occurred, all later migrations canceled:
>
> Mysql::Error: Table 'reports' already exists: CREATE TABLE reports
> (id int(11) DEFAULT NULL auto_increment PRIMARY KEY, host_id
> int(11) NOT NULL, log text, reported_at datetime, created_at
> datetime, updated_at datetime) ENGINE=InnoDB
> /usr/share/foreman/vendor/rails/activerecord/lib/active_record/
> connection_adapters/abstract_adapter.rb:227:in log' > /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ > connection_adapters/mysql_adapter.rb:324:inexecute'
> /usr/share/foreman/vendor/rails/activerecord/lib/active_record/
> connection_adapters/abstract/schema_statements.rb:109:in
> create_table' > /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ > connection_adapters/mysql_adapter.rb:478:increate_table'
> /usr/share/foreman/vendor/rails/activerecord/lib/active_record/
> migration.rb:352:in send' > /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ > migration.rb:352:inmethod_missing'
> /usr/share/foreman/vendor/rails/activerecord/lib/active_record/
> migration.rb:328:in say_with_time' > /usr/lib/ruby/1.8/benchmark.rb:293:inmeasure'
> /usr/share/foreman/vendor/rails/activerecord/lib/active_record/
> migration.rb:328:in say_with_time' > /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ > migration.rb:348:inmethod_missing'
> ./db/migrate//20090729132209_create_reports.rb:3:in
> up_without_benchmarks' > /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ > migration.rb:282:insend'
> /usr/share/foreman/vendor/rails/activerecord/lib/active_record/
> migration.rb:282:in migrate' > /usr/lib/ruby/1.8/benchmark.rb:293:inmeasure'
> /usr/share/foreman/vendor/rails/activerecord/lib/active_record/
> migration.rb:282:in migrate' > /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ > migration.rb:365:insend'
> /usr/share/foreman/vendor/rails/activerecord/lib/active_record/
> migration.rb:365:in migrate' > /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ > migration.rb:491:inmigrate'
> /usr/share/foreman/vendor/rails/activerecord/lib/active_record/
> migration.rb:567:in call' > /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ > migration.rb:567:inddl_transaction'
> /usr/share/foreman/vendor/rails/activerecord/lib/active_record/
> migration.rb:490:in migrate' > /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ > migration.rb:477:ineach'
> /usr/share/foreman/vendor/rails/activerecord/lib/active_record/
> migration.rb:477:in migrate' > /usr/share/foreman/vendor/rails/activerecord/lib/active_record/ > migration.rb:401:inup'
> /usr/share/foreman/vendor/rails/activerecord/lib/active_record/
> migration.rb:383:in migrate' > /usr/share/foreman/vendor/rails/railties/lib/tasks/databases.rake:112 > /usr/lib/ruby/1.8/rake.rb:636:incall'
> /usr/lib/ruby/1.8/rake.rb:636:in execute' > /usr/lib/ruby/1.8/rake.rb:631:ineach'
> /usr/lib/ruby/1.8/rake.rb:631:in execute' > /usr/lib/ruby/1.8/rake.rb:597:ininvoke_with_call_chain'
> /usr/lib/ruby/1.8/monitor.rb:242:in synchronize' > /usr/lib/ruby/1.8/rake.rb:590:ininvoke_with_call_chain'
> /usr/lib/ruby/1.8/rake.rb:583:in invoke' > /usr/lib/ruby/1.8/rake.rb:2051:ininvoke_task'
> /usr/lib/ruby/1.8/rake.rb:2029:in top_level' > /usr/lib/ruby/1.8/rake.rb:2029:ineach'
> /usr/lib/ruby/1.8/rake.rb:2029:in top_level' > /usr/lib/ruby/1.8/rake.rb:2068:instandard_exception_handling'
> /usr/lib/ruby/1.8/rake.rb:2023:in top_level' > /usr/lib/ruby/1.8/rake.rb:2001:inrun'
> /usr/lib/ruby/1.8/rake.rb:2068:in standard_exception_handling' > /usr/lib/ruby/1.8/rake.rb:1998:inrun'
> /usr/bin/rake:28
> puppetdash:/usr/share/foreman#
>
> While the error in itself is "correct" (the table/fields do exist) I
> think it is wrong that this is raised as an error and the table does
> not get expanded, as the documentation states that "If you want to
> share the database with Puppets (storeconfig), just modify config/
> database.yml to point to the same database configuration as puppet
> is.".
>
> reports table is not part of the puppet database scheme, most likely you
were running puppet dashboard on the same database?

>
> I'd guess that if I cleared out the database and let first foremans
> db:migrate and then puppet do its thing it would work, but I'd rather
> not do that if anyone could provide a decent workaround.
>
> Or am I just doing something wrong?
>

You can probably try to delete the reports table, but I have no idea what
other left overs might be there :slight_smile:

Ohad

··· On Fri, Jul 8, 2011 at 2:47 PM, SimonM wrote:

Cheers,
Simon

P.s.:
System:
Puppetmaster: Debian Squeeze, puppetmaster 2.6.8 & passenger 2.2.11
via debs
MysqlDB: Debian Lenny, Mysql 5.1
Foreman: 0.3-1 (official deb)


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.