Migration 043 to 14 » History » Version 1
Patrick Schönfeld, 03/04/2014 03:52 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 | sudo foreman-installer |
||
27 | |||
28 | Should end in a working, clean installation of 1.4 |
||
29 | (otherwise fix all problems, because thats where we want to get) |
||
30 | |||
31 | One possible helpful command to that extend could be: |
||
32 | |||
33 | cd /usr/share/foreman; bundle install |
||
34 | |||
35 | followed by |
||
36 | |||
37 | dpkg --configure -a |
||
38 | |||
39 | If dpkg is successful foreman-installer will be successful to. |
||
40 | Can be required to re-run it several times. |
||
41 | # Drop the 1.4 database and recreate it with the 0.4.2 dump |
||
42 | |||
43 | sudo -u postgres dropdb foreman |
||
44 | sudo -u postgres createdb foreman |
||
45 | |||
46 | Populate it with the 0.4.2 backup |
||
47 | |||
48 | sudo -u postgres psql foreman < /root/foreman_0.4.2.sql |
||
49 | # Downgrade foreman to 1.1.1+debian1 |
||
50 | |||
51 | apt-get install foreman=1.1.1+debian1 foreman-postgresql=1.1.1+debian1 |
||
52 | # 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. |
||
53 | # Apply the patch from https://github.com/theforeman/foreman/commit/fb0998a0ecf9e78822d321044b8eed89cbe7a9f9.patch |
||
54 | (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) |
||
55 | # TRUNCATE audits table in foremann (yeah, thats neccessary - sorry) |
||
56 | sudo -u foreman psql foreman -c 'TRUNCATE audits' |
||
57 | # Execute the migration scripts: |
||
58 | sudo -u foreman bundle exec rake db:migrate RAILS_ENV=production --trace |
||
59 | # Now upgrade to 1.4.1 again |
||
60 | sudo apt-get install foreman=1.4.1-1 foreman-postgresql=1.4.1-1 |
||
61 | # Add label column to hostgroup table: |
||
62 | sudo -u foreman psql foreman -c 'ALTER TABLE hostgroups ADD label character varying(255);' |
||
63 | # Comment line 3 and 4 in /usr/share/foreman/db/migrate/20130924145800_remove_unused_role_fields.rb: |
||
64 | # Run db migration scripts from 1.4: |
||
65 | foreman-rake db:migrate |
||
66 | # Revert the modification of 20130924145800_remove_unused_role_fields.rb |
||
67 | # Done! |