Project

General

Profile

Actions

Migration 043 to 14 » History » Revision 7

« Previous | Revision 7/10 (diff) | Next »
Patrick Schönfeld, 03/04/2014 04:04 PM


Migration of foreman 0.4.3 to foreman 1.4

Unfortunately the upgrade of foreman 0.4.3 isn't as easy as upgrading the packages, since their are some problems avoiding a working database migration. The following process has been developed and tested on a Debian Squeeze setup with the help of Greg Sutcliffe (gwmngilfen) and should work for other setups, too:

  1. Upgrade the system to Debian Wheezy in case you haven't already
  2. Create a full dump of the database (important step! without it the update
    WILL fail)

    sudo -u postgres pg_dump foreman > /root/foreman_0.4.2.sql

  3. Drop the foreman database and remove foreman

    sudo -u postgres dropdb foreman
    sudo dpkg -r foreman foreman-pgsql foreman-proxy

  4. Backup /etc/foreman
    sudo cp -r /etc/foreman /root/etc_foreman_0.4.2
  5. Add foreman sources.list entries

    cat <<EOF>/etc/apt/sources.list.d/foreman.list
    deb http://deb.theforeman.org/ wheezy stable
    deb http://deb.theforeman.org/ wheezy 1.2
    deb http://deb.theforeman.org/ squeeze 1.2
    EOF

  6. Install some packages:
    apt-get install build-essential ruby1.9.1-dev
  7. Install foreman-installer package and run the forema installer:

    sudo apt-get install foreman-installer
    sudo foreman-installer

    Should end in a working, clean installation of 1.4
    (otherwise fix all problems, because thats where we want to get)

    One possible helpful command to that extend could be:

    cd /usr/share/foreman; bundle install

    followed by

    dpkg --configure -a

    If dpkg is successful foreman-installer will be successful too.
    It can be required to re-run the foreman-installer, though.

  8. Drop the 1.4 database and recreate it with the 0.4.3 dump

    sudo -u postgres dropdb foreman
    sudo -u postgres createdb foreman

    Populate it with the 0.4.2 backup

    sudo -u postgres psql foreman < /root/foreman_0.4.2.sql

  9. Downgrade foreman to 1.1.1+debian1

    apt-get install foreman=1.1.1+debian1 foreman-postgresql=1.1.1+debian1

    This is necessary, since we need an older version of the upgrade scripts to get an upgradeable database state.

  10. Edit /usr/share/foreman/lib/foreman/default_settings/loader.rb

    Comment out the set-commands for the oauth-Keys around line 79-82; Be careful to keep the "[" in front of line 79!

  11. Apply the patch from https://github.com/theforeman/foreman/commit/fb0998a0ecf9e78822d321044b8eed89cbe7a9f9.patch
    (the test/lib/puppet_setting_test.rb part in the patch can be deleted; it does not apply since this is an install and not the source tree)
  12. TRUNCATE audits table in foremann (yeah, thats necessary - sorry)
    sudo -u foreman psql foreman -c 'TRUNCATE audits'
  13. Execute the migration scripts:
    sudo -u foreman bundle exec rake db:migrate RAILS_ENV=production --trace
  14. Now upgrade to 1.4.1 again
    sudo apt-get install foreman=1.4.1-1 foreman-postgresql=1.4.1-1
  15. Add label column to hostgroup table:
    sudo -u foreman psql foreman -c 'ALTER TABLE hostgroups ADD label character varying(255);'
  16. Comment line 3 and 4 in /usr/share/foreman/db/migrate/20130924145800_remove_unused_role_fields.rb
  17. Run db migration scripts from 1.4

    foreman-rake db:migrate

    It might be, that it now complains, that 'label' column already exists (remember? we added it some steps before). If it does, just remove it from the database again with:

    ALTER hostgroup DROP label;

    Then re-run the migration script.

  18. Revert the modification of 20130924145800_remove_unused_role_fields.rb
  19. Done!

Updated by Patrick Schönfeld over 10 years ago · 10 revisions