Project

General

Profile

Migration 043 to 14 » History » Version 3

Patrick Schönfeld, 03/04/2014 03:54 PM

1 1 Patrick Schönfeld
h1. Migration of foreman 0.4.3 to foreman 1.4
2
3
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:
4
5
# Upgrade the system to Debian Wheezy in case you haven't already
6
# Create a full dump of the database (important step! without it the update
7
   WILL fail)
8
    
9
       sudo -u postgres pg_dump foreman > /root/foreman_0.4.2.sql
10
# Drop the foreman database and remove foreman
11
    
12
    sudo -u postgres dropdb foreman
13
    sudo dpkg -r foreman foreman-pgsql foreman-proxy
14
# Backup /etc/foreman
15
    sudo cp -r /etc/foreman /root/etc_foreman_0.4.2
16
# Add foreman sources.list entries
17
18
   cat <<EOF>/etc/apt/sources.list.d/foreman.list
19
deb http://deb.theforeman.org/ wheezy stable
20
deb http://deb.theforeman.org/ wheezy 1.2
21
deb http://deb.theforeman.org/ squeeze 1.2
22
EOF
23
# Install some packages:
24
    apt-get install build-essential ruby1.9.1-dev
25
# Install foreman-installer package and run the forema installer.
26 3 Patrick Schönfeld
   
27 1 Patrick Schönfeld
   sudo foreman-installer
28
29
   Should end in a working, clean installation of 1.4
30
   (otherwise fix all problems, because thats where we want to get)
31
   
32
   One possible helpful command to that extend could be:
33
34
   cd /usr/share/foreman; bundle install
35
36
   followed by
37
38
   dpkg --configure -a
39
40 2 Patrick Schönfeld
   If dpkg  is successful foreman-installer will be successful too.
41
   It can be required to re-run the foreman-installer, though.
42 1 Patrick Schönfeld
# Drop the 1.4 database and recreate it with the 0.4.2 dump
43
44
   sudo -u postgres dropdb foreman
45
   sudo -u postgres createdb foreman
46
47
   Populate it with the 0.4.2 backup
48
49
   sudo -u postgres psql foreman < /root/foreman_0.4.2.sql
50
# Downgrade foreman to 1.1.1+debian1
51
52
    apt-get install foreman=1.1.1+debian1 foreman-postgresql=1.1.1+debian1
53
# 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.
54
# Apply the patch from https://github.com/theforeman/foreman/commit/fb0998a0ecf9e78822d321044b8eed89cbe7a9f9.patch  
55
  (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)
56
# TRUNCATE audits table in foremann (yeah, thats neccessary - sorry)
57
    sudo -u foreman psql foreman -c 'TRUNCATE audits'
58
# Execute the migration scripts:
59
    sudo -u foreman bundle exec rake db:migrate RAILS_ENV=production --trace
60
# Now upgrade to 1.4.1 again
61
    sudo apt-get install foreman=1.4.1-1 foreman-postgresql=1.4.1-1
62
# Add label column to hostgroup table:
63
    sudo -u foreman psql foreman -c 'ALTER TABLE hostgroups ADD label character varying(255);'
64
# Comment line 3 and 4 in /usr/share/foreman/db/migrate/20130924145800_remove_unused_role_fields.rb:
65
# Run db migration scripts from 1.4:
66
    foreman-rake db:migrate
67
# Revert the modification of 20130924145800_remove_unused_role_fields.rb
68
# Done!