source: branches/fc17-dev/server/doc/install-howto.sh @ 2230

Last change on this file since 2230 was 2230, checked in by ezyang, 12 years ago
Update instructions for F17.
File size: 19.7 KB
RevLine 
[1058]1# This document is a how-to for installing a Fedora scripts.mit.edu server.
[1693]2# It is semi-vaguely in the form of a shell script, but is not really
3# runnable as it stands.
[181]4
[1961]5# Notation
6# [PRODUCTION] Production server that will be put into the pool
7# [WIZARD]     Semi-production server that will only have
8#              daemon.scripts-security-upd bits, among other
9#              restricted permissions
10# [TESTSERVER] Completely untrusted server
11
[1693]12# 'branch' is the current svn branch you are on.  You want to
13# use trunk if your just installing a new server, and branches/fcXX-dev
14# if your preparing a server on a new Fedora release.
15branch="trunk"
[1063]16
[1693]17# 'server' is the public hostname of your server, for SCP'ing files
18# to and from.
19server=YOUR-SERVER-NAME-HERE
[1063]20
[2066]21# ----------------------------->8--------------------------------------
22#                       FIRST TIME INSTRUCTIONS
23#
[1961]24# [PRODUCTION] If this is the first time you've installed this hostname,
25# you will need to update a bunch of files to add support for it. These
26# include:
[1696]27#   o Adding all aliases to /etc/httpd/conf.d/scripts-vhost-names.conf
28#     (usually this is hostname, hostname.mit.edu, h-n, h-n.mit.edu,
29#     scriptsN, scriptsN.mit.edu, and the IP address.)
30#   o Adding routing rules for the static IP in
31#     /etc/sysconfig/network-scripts/route-eth1
32#   o Adding the IP address to the hosts file (same hosts as for
33#     scripts-vhost-names)
[1704]34#   o Update SSH config at
35#       - server/fedora/config/etc/ssh/shosts.equiv
36#       - server/fedora/config/etc/ssh/ssh_known_hosts
37#       - server/fedora/config/etc/ssh/sshd_config : DenyUsers
38#     (the last part is critical to ensure that rooting one server
39#     doesn't give you root to all the other servers)
[1696]40#   o Put the hostname information in LDAP so SVN and Git work
41#   o Set up Nagios monitoring on sipb-noc for the host
42#   o Set up the host as in the pool on r-b/r-b /etc/heartbeat/ldirectord.cf
[2066]43#   o Update locker/etc/known_hosts
[2068]44#   o Update website files:
45#       /mit/scripts/web_scripts/home/server.css.cgi
46#       /mit/scripts/web_scripts/heartbeat/heartbeat.php
[2066]47#
48# You will also need to prepare the keytabs for credit-card.  In particular,
49# use ktutil to combine the host/scripts.mit.edu and
50# host/scripts-vhosts.mit.edu keys with host/this-server.mit.edu in
51# the keytab.  Do not use 'k5srvutil change' on the combined keytab
52# or you'll break the other servers. (real servers only).  Be
53# careful about writing out the keytab: if you write it to an
54# existing file the keys will just get appended.  The correct
55# credential list should look like:
56#   ktutil:  l
57#   slot KVNO Principal
58#   ---- ---- ---------------------------------------------------------------------
59#      1    5 host/old-faithful.mit.edu@ATHENA.MIT.EDU
60#      2    3 host/scripts-vhosts.mit.edu@ATHENA.MIT.EDU
[2068]61#      3    2 host/scripts.mit.edu@ATHENA.MIT.EDU
62#      4    8 host/scripts-test.mit.edu@ATHENA.MIT.EDU
[2066]63#
64# The LDAP keytab should be by itself, so be sure to delete it and
65# put it in its own file.
[1696]66
[2066]67# ----------------------------->8--------------------------------------
68#                      INFINITE INSTALLATION
[1259]69
[2066]70# Start with a Scripts kickstarted install of Fedora (install-fedora)
[1259]71
[2079]72# IMPORTANT: If you are installing a server without the benefit of
73# Kickstart (for example, you are installing on XVM, it is VITALLY
74# IMPORTANT that you go through the kickstart and apply all of the
75# necessary changes--for example, disabling selinux or enabling
76# network.)
77#   XXX We should make Kickstart work for test servers too
78
[2066]79# Take updates, reboot if there's a kernel update.
80    yum update -y
81
82# Get rid of network manager (XXX figure out to make kickstarter do
83# this for us)
84    yum remove NetworkManager
85
[2195]86# Make sure sendmail isn't installed, replace it with postfix
87    yum shell <<EOF
88remove sendmail
89install postfix
90run
91exit
92EOF
[2066]93
94# Check out the scripts /etc configuration
95    cd /root
96    \cp -a etc /
97    chmod 0440 /etc/sudoers
[2225]98    grub2-mkconfig -o /boot/grub2/grub.cfg
[2066]99
[2080]100# [TEST] You'll need to fix some config now.  See bottom of document.
101
[2066]102# Make sure network is working.  Kickstart should have
[1693]103# configured eth0 and eth1 correctly; use service network restart
[2066]104# to add the new routes from etc in route-eth1.
105    systemctl restart network.service
106    # Check everything worked:
[1693]107    route
108    ifconfig
109    cat /etc/hosts
110    cat /etc/sysconfig/network-scripts/route-eth1
[1259]111
[1693]112# This is the point at which you should start updating scriptsified
113# packages for a new Fedora release.  Consult 'upgrade-tips' for more
114# information.
115    yum install -y scripts-base
116    # Some of these packages are naughty and clobber some of our files
117    cd /etc
[2066]118    svn revert resolv.conf hosts sysconfig/openafs nsswitch.conf
[2079]119    # Troubleshooting: if accountadm, tokensys and nscd fail to install
120    # you probably forgot to turn off selinux
[1259]121
[1058]122# Replace rsyslog with syslog-ng by doing:
[2195]123    yum shell <<EOF
124remove rsyslog
125install syslog-ng
126run
127exit
128EOF
[2066]129    systemctl enable syslog-ng.service
[861]130
[1058]131# Install the full list of RPMs that users expect to be on the
[1259]132# scripts.mit.edu servers.
133rpm -qa --queryformat "%{Name}.%{Arch}\n" | sort > packages.txt
134# arrange for packages.txt to be passed to the server, then run:
[2195]135    cd /tmp
136    yumdownloader --disablerepo=scripts ghc-cgi ghc-cgi-devel
137    yum localinstall ghc-cgi*.x86_64.rpm
138    yum install -y $(cat packages.txt)
139# The reason this works is that ghc-cgi is marked as installonlypkgs
140# in yum.conf, telling yum to install them side-by-side rather than
141# updating them. If it doesn't work, use --skip-broken on the yum
142# command line.
[1259]143
[1190]144# Check which packages are installed on your new server that are not
145# in the snapshot, and remove ones that aren't needed for some reason
146# on the new machine.  Otherwise, aside from bloat, you may end up
147# with undesirable things for security, like sendmail.
[1693]148    rpm -qa --queryformat "%{Name}.%{Arch}\n" | grep -v kernel | sort > newpackages.txt
149    diff -u packages.txt newpackages.txt | grep -v kernel | less
[1382]150    # here's a cute script that removes all extra packages
[1693]151    yum erase -y $(grep -Fxvf packages.txt newpackages.txt)
[1961]152    # 20101208 - Mysteriously we manage to get these extra packages
153    # from kickstart: mcelog mobile-broadband-provider-info
154    # ModemManager PackageKit
[1190]155
[2066]156# ----------------------------->8--------------------------------------
157#                      SPHEROID SHENANIGANS
[1237]158
[2195]159# Install the Python eggs and Ruby gems and PEAR/PECL doohickeys that are on
160# the other scripts.mit.edu servers and do not have RPMs.
161# The general mode of operation will be to run the "list" command
162# on both servers, see what the differences are, check if those diffs
163# are packaged up as rpms, and install them (rpm if possible, native otherwise)
164
[2066]165# Note: Since ultimately we'd like to move away from using per-language
166# package manager and all of these be RPMs, it is of questionable
167# importance how much /good/ automation for these is necessary.
168
169# Warning: For a new release, we're supposed to check if Fedora has
170# packaged up the RPM.  Unfortunately we don't really have good incants
171# for this.
172
[2195]173# Warning: If you're installing a new server mid-lifecycle (or even if
174# this is the start of a cycle, but you've been staggering the
175# installation of servers), upstream may have moved on.  Because we
176# don't normally upgrade spheroid projects, that means executing these
177# instructions directly means that you will have mismatched versions
178# (the new servers will have newer versions.)  Please follow the
179# UPGRADE commentary attached to each of these.
180
181# Warning: The package lists that are generated are inconsistent on
182# the question of whether or not they contain all packages (locally
183# installed as well as distro packaged), or if they just contain locally
184# installed packages.  Check this carefully; many of the install incants
185# filter out already installed packages.
186
187# PERL CPAN
188# ---------
189
[1058]190# Install the full list of perl modules that users expect to be on the
[1108]191# scripts.mit.edu servers.
[1693]192    cd /root
[1259]193    export PERL_MM_USE_DEFAULT=1
[1693]194    cpan # this is interactive, enter the next two lines
[1259]195        o conf prerequisites_policy follow
196        o conf commit
197# on a reference server
198perldoc -u perllocal | grep head2 | cut -f 3 -d '<' | cut -f 1 -d '|' | sort -u | perl -ne 'chomp; print "notest install $_\n" if system("rpm -q --whatprovides \"perl($_)\" >/dev/null 2>/dev/null")' > perl-packages.txt
199# arrange for perl-packages.txt to be transferred to server
[2195]200    # Package list only contains new packages
[1259]201    cat perl-packages.txt | perl -MCPAN -e shell
[2195]202# These are in /usr/local
[812]203
[2195]204# UPGRADE: Installing old versions of CPAN modules requires you to
205# specify the full path of a module, e.g.
206# M/MS/MSCHWERN/Test-Simple-0.62.tar.gz.  It is not currently clear how
207# to get this information programatically.  Furthermore, we have a lot
208# of CPAN managed modules.  Since CPAN is the only thing
209# placed in /usr/local at this point, it may be easier to simple tar and
210# cp the Perl modules from one server to another, to keep them
211# consistent.  But doing this is fiddly XXX
212
213# PYTHON EGGS
214# -----------
215
216# - Look at /usr/lib/python2.7/site-packages and
217#           /usr/lib64/python2.7/site-packages for Python eggs and modules.
[1259]218#   There will be a lot of gunk that was installed from packages;
[1693]219#   easy-install.pth in /usr/lib/ will tell you what was easy_installed.
[1178]220#   First use 'yum search' to see if the relevant package is now available
221#   as an RPM, and install that if it is.  If not, then use easy_install.
[1432]222#   Pass -Z to easy_install to install them unzipped, as some zipped eggs
223#   want to be able to write to ~/.python-eggs.  (Also makes sourcediving
224#   easier.)
[2066]225# 'easy_install AuthKit jsonlib2 pygit'
226cat /usr/lib/python2.7/site-packages/easy-install.pth | grep "^./" | cut -c3- | cut -f1 -d- > egg.txt
[2195]227    # Package list only contains new packages
[1698]228    cat egg.txt | xargs easy_install -Z
[2195]229# These are in /usr
[2066]230
[2195]231# UPGRADE: Use 'easy_install -n' to see what new versions are installed, and if there
232# are updates validate them and upgrade them on the old servers.  Since
233# we have a really small package list (around 4) checking these manually
234# should be fine.  Note that dry run is slightly buggy and may fail
235# midway processing files on account of a missing build directory.
236
237# RUBY GEMS
238# ---------
239
[1058]240# - Look at `gem list` for Ruby gems.
[1178]241#   Again, use 'yum search' and prefer RPMs, but failing that, 'gem install'.
[1259]242#       ezyang: rspec-rails depends on rspec, and will override the Yum
243#       package, so... don't use that RPM yet
[2066]244# XXX This doesn't do the right thing for old version gems
[1693]245gem list --no-version > gem.txt
[2195]246    # Package list contains distro gems too
[1693]247    gem install $(gem list --no-version | grep -Fxvf - gem.txt)
[2066]248    # Also, we need to install the old rails version
249    gem install -v=2.3.5 rails
[2195]250# These are in /usr
[2066]251
[2195]252# UPGRADE:  You can either upgrade out-of-date gems, or leave them at
253# the old version.  We recommend the latter (see below for the
254# rationale), but note that the install script described here doesn't
255# pin against version, so you'll need to supply the -v parameters
256# manually (the gems we install manually don't move too quickly, so this
257# is fairly tractable if you check 'gem outdated'.)
258#
259# If you want to upgrade, do NOT use wildcard 'gem update'; use 'gem
260# outdated' to find out all gems that are out of date, and verify this
261# against our locally installed gems (there will be a lot of out of date
262# gems, but this is simply because Fedora packaging lags behind the
263# canonical versions (this is a good thing).  Manually upgrade just
264# those gems.  Note that this doesn't save you from having to install
265# old gems on the servers that are being installed out-of-cycle,
266# because Ruby supports pinning against old versions, and if those gems
267# then mysteriously disappear, things will be sad (note that this isn't
268# a *huge* problem, because usually when you pin gems it's in
269# conjunction with rvm, so they have their local copy of the gem.)
270
271# PHP PEAR
272# --------
273
[1058]274# - Look at `pear list` for Pear fruits (or whatever they're called).
[1178]275#   Yet again, 'yum search' for RPMs before resorting to 'pear install'.  Note
276#   that for things in the beta repo, you'll need 'pear install package-beta'.
[1259]277#   (you might get complaints about the php_scripts module; ignore them)
[1693]278pear list | tail -n +4 | cut -f 1 -d " " > pear.txt
[2195]279    # Package list contains distro packages
[1693]280    pear config-set preferred_state beta
281    pear channel-update pear.php.net
282    pear install $(pear list | tail -n +4 | cut -f 1 -d " " | grep -Fxvf - pear.txt)
[2195]283# These are in /usr
[2066]284
[2195]285# PHP PECL
286# --------
287
[1190]288# - Look at `pecl list` for PECL things.  'yum search', and if you must,
[1462]289#   'pecl install' needed items. If it doesn't work, try 'pear install
[1544]290#   pecl/foo' or 'pecl install foo-beta' or those two combined.
[1693]291pecl list | tail -n +4 | cut -f 1 -d " " > pecl.txt
[2195]292    # Package list contains distro packages
[1693]293    pecl install --nodeps $(pecl list | tail -n +4 | cut -f 1 -d " " | grep -Fxvf - pecl.txt)
[2195]294# These are in /usr
[785]295
[2066]296# ----------------------------->8--------------------------------------
297#                       INFINITE CONFIGURATION
[812]298
[2195]299# [PROD] Create fedora-ds user (needed for credit-card)
[2215]300useradd -r -d /var/lib/dirsrv fedora-ds
[387]301
[2066]302# Run credit-card to clone in credentials and make things runabble
[2195]303# NOTE: You may be tempted to run credit-card earlier in the install
304# process in order, for example, to be able to SSH in to the servers
305# with Kerberos.  However, it is better to install the credentials
306# *after* we have run a boatload untrusted code as part of the
307# spheroids objects process.  So don't move this step earlier!
[2066]308python host.py push $server
[1961]309
[2066]310# This is superseded by credit-card, but only for [PRODUCTION]
311# Don't use credit-card on [WIZARD]: it will put in the wrong creds!
312#
313#   # All types of servers will have an /etc/daemon.keytab file, however,
314#   # different types of server will have different credentials in this
315#   # keytab.
316#   #   [PRODUCTION] daemon.scripts
317#   #   [WIZARD]     daemon.scripts-security-upd
318#   #   [TESTSERVER] daemon.scripts-test
[1693]319
[2066]320# Test that zephyr is working
321    systemctl enable zhm.service
322    systemctl start zhm.service
323    echo 'Test!' | zwrite -d -c scripts -i test
[1259]324
[2066]325# Check out the scripts /usr/vice/etc configuration
326    cd /root/vice
327    \cp -a etc /usr/vice
[2195]328# [TESTSERVER] If you're installing a test server, this needs to be
329# much smaller; the max filesize on XVM is 10GB.  Pick something like
330# 500000. Also, some of the AFS parameters are kind of retarded (and if
331# you're low on disk space, will actually exhaust our inodes).  Edit
332# these parameters in /etc/sysconfig/openafs (I just chopped a zero
333# off of all of our parameters)
334    echo "/afs:/usr/vice/cache:500000" > /usr/vice/etc/cacheinfo
335    vim /etc/sysconfig/openafs
[2066]336
[1961]337# [PRODUCTION] Set up replication (see ./install-ldap).
[1693]338# You'll need the LDAP keytab for this server: be sure to chown it
339# fedora-ds after you create the fedora-ds user
340    ls -l /etc/dirsrv/keytab
341    cat install-ldap
[785]342
[2230]343# Enable lots of services (currently in /etc checkout)
[2066]344    systemctl enable openafs-client.service
345    systemctl enable dirsrv.service
346    systemctl enable nslcd.service
347    systemctl enable nscd.service
348    systemctl enable postfix.service
[2230]349    systemctl enable nrpe.service # chkconfig'd
[2066]350    systemctl enable httpd.service # not for [WIZARD]
[1961]351
[2066]352    systemctl start openafs-client.service
353    systemctl start dirsrv.service
354    systemctl start nslcd.service
355    systemctl start nscd.service
356    systemctl start postfix.service
357    systemctl start nrpe.service
358    systemctl start httpd.service # not for [WIZARD]
[1961]359
[2066]360# Note about OpenAFS: Check that fs sysname is correct.  You should see,
361# among others, 'amd64_fedoraX_scripts' (vary X) and 'scripts'. If it's
362# not, you probably did a distro upgrade and should update
[2222]363# tokensys (server/common/oursrc/tokensys/scripts-afsagent-startup.in)
[2066]364    fs sysname
[818]365
[1259]366# Postfix doesn't actually deliver mail; fix this
367    cd /etc/postfix
368    postmap virtual
[1178]369
[1451]370# Munin might not be monitoring packages that were installed after it
371    munin-node-configure --suggest --shell | sh
372
[1058]373# Run fmtutil-sys --all, which does something that makes TeX work.
[1693]374# (Note: this errors on XeTeX which is ok.)
[1259]375    fmtutil-sys --all
[803]376
[1259]377# Fix etc by making sure none of our config files got overwritten
378    cd /etc
[1693]379    svn status -q
[2066]380    # Some usual candidates for clobbering include nsswitch.conf,
381    # resolv.conf and sysconfig/openafs
[1961]382    # [WIZARD/TEST] Remember that changes you made should not get
383    # reverted!
[1259]384
[1058]385# Reboot the machine to restore a consistent state, in case you
[1693]386# changed anything. (Note: Starting kdump fails (this is ok))
[875]387
[2066]388# ------------------------------->8-------------------------------
389#                ADDENDA AND MISCELLANEOUS THINGS
390
[1693]391# [OPTIONAL] Your machine's hostname is baked in at install time;
392# in the rare case you need to change it: it appears to be in:
[1259]393#   o /etc/sysconfig/network
394#   o your lvm thingies; probably don't need to edit
[1382]395
[2080]396# [TESTSERVER] Enable password log in
397        vim /etc/ssh/sshd_config
398        service sshd reload
399        vim /etc/pam.d/sshd
400# Replace the first auth block with:
401#           # If they're not root, but their user exists (success),
402#           auth    [success=ignore ignore=ignore default=1]        pam_succeed_if.so uid > 0
403#           # print the "You don't have tickets" error:
404#           auth    [success=die ignore=reset default=die]  pam_echo.so file=/etc/issue.net.no_tkt
405#           # If !(they are root),
406#           auth    [success=1 ignore=ignore default=ignore]        pam_succeed_if.so uid eq 0
407#           # print the "your account doesn't exist" error:
408#           auth    [success=die ignore=reset default=die]  pam_echo.so file=/etc/issue.net.no_user
409
410
[2066]411# [WIZARD/TESTSERVER] If you are setting up a non-production server,
412# there are some services that it won't provide, and you will need to
413# make it talk to a real server instead.  In particular:
414#   - We don't serve the web, so don't bind scripts.mit.edu
415#   - We don't serve LDAP, so use another server
416# This involves editing the following files:
[2080]417        \rm /etc/sysconfig/network-scripts/ifcfg-lo:{0,1,2,3}
418        \rm /etc/sysconfig/network-scripts/route-eth1 # [TESTSERVER] only
[2079]419#   o /etc/nslcd.conf
[2066]420#       replace: uri ldapi://%2fvar%2frun%2fdirsrv%2fslapd-scripts.socket/
421#       with: uri ldap://scripts.mit.edu/
[2079]422#           (what happened to nss-ldapd?)
[2066]423#   o /etc/openldap/ldap.conf
424#       add: URI ldap://scripts.mit.edu/
425#            BASE dc=scripts,dc=mit,dc=edu
426#   o /etc/httpd/conf.d/vhost_ldap.conf
427#       replace: VhostLDAPUrl "ldap://127.0.0.1/ou=VirtualHosts,dc=scripts,dc=mit,dc=edu"
428#       with: VhostLDAPUrl "ldap://scripts.mit.edu/ou=VirtualHosts,dc=scripts,dc=mit,dc=edu"
429#   o /etc/postfix/virtual-alias-{domains,maps}-ldap.cf
430#       replace: server_host ldapi://%2fvar%2frun%2fdirsrv%2fslapd-scripts.socket/
431#       with: server_host = ldap://scripts.mit.edu
432# to use scripts.mit.edu instead of localhost.
433# XXX: someone should write sed scripts to do this
434
435# [WIZARD/TESTSERVER] If you are setting up a non-production server,
436# afsagent's cronjob will attempt to be renewing with the wrong
437# credentials (daemon.scripts). Change this:
438    vim /home/afsagent/renew # replace all mentions of daemon.scripts.mit.edu
439
[1961]440# [TESTERVER]
441#   - You need a self-signed SSL cert or Apache will refuse to start
442#     or do SSL.  Generate with:
[1382]443    openssl req -new -x509 -keyout /etc/pki/tls/private/scripts.key -out /etc/pki/tls/certs/scripts.cert -nodes
[2195]444    ln -s /etc/pki/tls/private/scripts.key /etc/pki/tls/private/scripts-1024.key
445#     Also make /etc/pki/tls/certs/ca.pem match up
446    openssl rsa -in /etc/pki/tls/private/scripts.key -pubout > /etc/pki/tls/certs/ca.pem
[1961]447
448# [TESTSERVER] More stuff for test servers
[1382]449#   - Make (/etc/aliases) root mail go to /dev/null, so we don't spam people
450#   - Edit /etc/httpd/conf.d/scripts-vhost-names.conf to have scripts-fX-test.xvm.mit.edu
451#     be an accepted vhost name
452#   - Look at the old test server and see what config changes are floating around
Note: See TracBrowser for help on using the repository browser.