Migration 043 to 14 » History » Version 6
Patrick Schönfeld, 03/04/2014 04:02 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 | 5 | Patrick Schönfeld | # *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 | 1 | Patrick Schönfeld | WILL fail) |
8 | |||
9 | sudo -u postgres pg_dump foreman > /root/foreman_0.4.2.sql |
||
10 | 5 | Patrick Schönfeld | # *Drop the foreman database and remove foreman* |
11 | 1 | Patrick Schönfeld | |
12 | sudo -u postgres dropdb foreman |
||
13 | sudo dpkg -r foreman foreman-pgsql foreman-proxy |
||
14 | 5 | Patrick Schönfeld | # *Backup /etc/foreman* |
15 | 1 | Patrick Schönfeld | sudo cp -r /etc/foreman /root/etc_foreman_0.4.2 |
16 | 5 | Patrick Schönfeld | # *Add foreman sources.list entries* |
17 | 1 | Patrick Schönfeld | |
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 | 5 | Patrick Schönfeld | # *Install some packages:* |
24 | 1 | Patrick Schönfeld | apt-get install build-essential ruby1.9.1-dev |
25 | 4 | Patrick Schönfeld | # *Install foreman-installer package and run the forema installer:* |
26 | 1 | Patrick Schönfeld | |
27 | 4 | Patrick Schönfeld | sudo apt-get install foreman-installer |
28 | 1 | Patrick Schönfeld | sudo foreman-installer |
29 | |||
30 | Should end in a working, clean installation of 1.4 |
||
31 | (otherwise fix all problems, because thats where we want to get) |
||
32 | |||
33 | One possible helpful command to that extend could be: |
||
34 | |||
35 | cd /usr/share/foreman; bundle install |
||
36 | |||
37 | followed by |
||
38 | |||
39 | dpkg --configure -a |
||
40 | |||
41 | 2 | Patrick Schönfeld | If dpkg is successful foreman-installer will be successful too. |
42 | It can be required to re-run the foreman-installer, though. |
||
43 | 5 | Patrick Schönfeld | # *Drop the 1.4 database and recreate it with the 0.4.3 dump* |
44 | 1 | Patrick Schönfeld | |
45 | sudo -u postgres dropdb foreman |
||
46 | sudo -u postgres createdb foreman |
||
47 | |||
48 | Populate it with the 0.4.2 backup |
||
49 | |||
50 | sudo -u postgres psql foreman < /root/foreman_0.4.2.sql |
||
51 | 5 | Patrick Schönfeld | # *Downgrade foreman to 1.1.1+debian1* |
52 | 1 | Patrick Schönfeld | |
53 | apt-get install foreman=1.1.1+debian1 foreman-postgresql=1.1.1+debian1 |
||
54 | 6 | Patrick Schönfeld | |
55 | This is necessary, since we need an older version of the upgrade scripts to get an upgradeable database state. |
||
56 | # *Edit /usr/share/foreman/lib/foreman/default_settings/loader.rb* |
||
57 | |||
58 | Comment out the set-commands for the oauth-Keys around line 79-82; Be careful to keep the "[" in front of line 79! |
||
59 | # *Apply the patch from https://github.com/theforeman/foreman/commit/fb0998a0ecf9e78822d321044b8eed89cbe7a9f9.patch* |
||
60 | 1 | Patrick Schönfeld | (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) |
61 | 6 | Patrick Schönfeld | # *TRUNCATE audits table in foremann (yeah, thats necessary - sorry)* |
62 | 1 | Patrick Schönfeld | sudo -u foreman psql foreman -c 'TRUNCATE audits' |
63 | 6 | Patrick Schönfeld | # *Execute the migration scripts:* |
64 | 1 | Patrick Schönfeld | sudo -u foreman bundle exec rake db:migrate RAILS_ENV=production --trace |
65 | 6 | Patrick Schönfeld | # *Now upgrade to 1.4.1 again* |
66 | 1 | Patrick Schönfeld | sudo apt-get install foreman=1.4.1-1 foreman-postgresql=1.4.1-1 |
67 | 6 | Patrick Schönfeld | # *Add label column to hostgroup table:* |
68 | 1 | Patrick Schönfeld | sudo -u foreman psql foreman -c 'ALTER TABLE hostgroups ADD label character varying(255);' |
69 | 6 | Patrick Schönfeld | # *Comment line 3 and 4 in /usr/share/foreman/db/migrate/20130924145800_remove_unused_role_fields.rb* |
70 | # *Run db migration scripts from 1.4* |
||
71 | |||
72 | 1 | Patrick Schönfeld | foreman-rake db:migrate |
73 | 6 | Patrick Schönfeld | # *Revert the modification of 20130924145800_remove_unused_role_fields.rb* |
74 | # *Done!* |