Project

General

Profile

Migration 043 to 14 » History » Revision 3

Revision 2 (Patrick Schönfeld, 03/04/2014 03:53 PM) → Revision 3/10 (Patrick Schönfeld, 03/04/2014 03:54 PM)

h1. 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: 

 # Upgrade the system to Debian Wheezy in case you haven't already 
 # 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 
 # Drop the foreman database and remove foreman 
    
     sudo -u postgres dropdb foreman 
     sudo dpkg -r foreman foreman-pgsql foreman-proxy 
 # Backup /etc/foreman 
     sudo cp -r /etc/foreman /root/etc_foreman_0.4.2 
 # 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 
 # Install some packages: 
     apt-get install build-essential ruby1.9.1-dev 
 # Install foreman-installer package and run the forema 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. 
 # Drop the 1.4 database and recreate it with the 0.4.2 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 
 # Downgrade foreman to 1.1.1+debian1 

     apt-get install foreman=1.1.1+debian1 foreman-postgresql=1.1.1+debian1 
 # Open /usr/share/foreman/lib/foreman/default_settings/loader.rb and comment the set commands for the oauth_keys (line 79-82), be careful to keep the "[" in front of line 79. 
 # 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) 
 # TRUNCATE audits table in foremann (yeah, thats neccessary - sorry) 
     sudo -u foreman psql foreman -c 'TRUNCATE audits' 
 # Execute the migration scripts: 
     sudo -u foreman bundle exec rake db:migrate RAILS_ENV=production --trace 
 # Now upgrade to 1.4.1 again 
     sudo apt-get install foreman=1.4.1-1 foreman-postgresql=1.4.1-1 
 # Add label column to hostgroup table: 
     sudo -u foreman psql foreman -c 'ALTER TABLE hostgroups ADD label character varying(255);' 
 # Comment line 3 and 4 in /usr/share/foreman/db/migrate/20130924145800_remove_unused_role_fields.rb: 
 # Run db migration scripts from 1.4: 
     foreman-rake db:migrate 
 # Revert the modification of 20130924145800_remove_unused_role_fields.rb 
 # Done!