source: trunk/server/doc/ @ 2066

Last change on this file since 2066 was 2066, checked in by achernya, 10 years ago
Merge branches/fc15-dev to trunk
File size: 16.1 KB
1# This document is a how-to for installing a Fedora server.
2# It is semi-vaguely in the form of a shell script, but is not really
3# runnable as it stands.
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
12# This is actually just "pick an active scripts server".  It can't be
13# because our networking config points that domain
14# at localhost, and if our server is not setup at that point things
15# will break.
18# 'branch' is the current svn branch you are on.  You want to
19# use trunk if your just installing a new server, and branches/fcXX-dev
20# if your preparing a server on a new Fedora release.
23# 'server' is the public hostname of your server, for SCP'ing files
24# to and from.
27# ----------------------------->8--------------------------------------
28#                       FIRST TIME INSTRUCTIONS
30# [PRODUCTION] If this is the first time you've installed this hostname,
31# you will need to update a bunch of files to add support for it. These
32# include:
33#   o Adding all aliases to /etc/httpd/conf.d/scripts-vhost-names.conf
34#     (usually this is hostname,, h-n,,
35#     scriptsN,, and the IP address.)
36#   o Adding routing rules for the static IP in
37#     /etc/sysconfig/network-scripts/route-eth1
38#   o Adding the IP address to the hosts file (same hosts as for
39#     scripts-vhost-names)
40#   o Update SSH config at
41#       - server/fedora/config/etc/ssh/shosts.equiv
42#       - server/fedora/config/etc/ssh/ssh_known_hosts
43#       - server/fedora/config/etc/ssh/sshd_config : DenyUsers
44#     (the last part is critical to ensure that rooting one server
45#     doesn't give you root to all the other servers)
46#   o Put the hostname information in LDAP so SVN and Git work
47#   o Set up Nagios monitoring on sipb-noc for the host
48#   o Set up the host as in the pool on r-b/r-b /etc/heartbeat/
49#   o Update locker/etc/known_hosts
51# You will also need to prepare the keytabs for credit-card.  In particular,
52# use ktutil to combine the host/ and
53# host/ keys with host/ in
54# the keytab.  Do not use 'k5srvutil change' on the combined keytab
55# or you'll break the other servers. (real servers only).  Be
56# careful about writing out the keytab: if you write it to an
57# existing file the keys will just get appended.  The correct
58# credential list should look like:
59#   ktutil:  l
60#   slot KVNO Principal
61#   ---- ---- ---------------------------------------------------------------------
62#      1    5 host/
63#      2    3 host/
64#      3    2      host/
66# The LDAP keytab should be by itself, so be sure to delete it and
67# put it in its own file.
69# ----------------------------->8--------------------------------------
70#                      INFINITE INSTALLATION
72# Start with a Scripts kickstarted install of Fedora (install-fedora)
74# Take updates, reboot if there's a kernel update.
75    yum update -y
77# Get rid of network manager (XXX figure out to make kickstarter do
78# this for us)
79    yum remove NetworkManager
81# Make sure sendmail isn't installed
82    yum remove sendmail
84# Check out the scripts /etc configuration
85    cd /root
86    \cp -a etc /
87    chmod 0440 /etc/sudoers
89# Make sure network is working.  Kickstart should have
90# configured eth0 and eth1 correctly; use service network restart
91# to add the new routes from etc in route-eth1.
92    systemctl restart network.service
93    # Check everything worked:
94    route
95    ifconfig
96    cat /etc/hosts
97    cat /etc/sysconfig/network-scripts/route-eth1
99# This is the point at which you should start updating scriptsified
100# packages for a new Fedora release.  Consult 'upgrade-tips' for more
101# information.
102    yum install -y scripts-base
103    # Some of these packages are naughty and clobber some of our files
104    cd /etc
105    svn revert resolv.conf hosts sysconfig/openafs nsswitch.conf
107# Replace rsyslog with syslog-ng by doing:
108    rpm -e --nodeps rsyslog
109    yum install -y syslog-ng
110    systemctl enable syslog-ng.service
112# Install the full list of RPMs that users expect to be on the
113# servers.
114rpm -qa --queryformat "%{Name}.%{Arch}\n" | sort > packages.txt
115# arrange for packages.txt to be passed to the server, then run:
116# --skip-broken will (usually) prevent you from having to sit through
117# several minutes of dependency resolution until it decides that
118# it can't install /one/ package.
119    yum install -y --skip-broken $(cat packages.txt)
121# Check which packages are installed on your new server that are not
122# in the snapshot, and remove ones that aren't needed for some reason
123# on the new machine.  Otherwise, aside from bloat, you may end up
124# with undesirable things for security, like sendmail.
125    rpm -qa --queryformat "%{Name}.%{Arch}\n" | grep -v kernel | sort > newpackages.txt
126    diff -u packages.txt newpackages.txt | grep -v kernel | less
127    # here's a cute script that removes all extra packages
128    yum erase -y $(grep -Fxvf packages.txt newpackages.txt)
129    # 20101208 - Mysteriously we manage to get these extra packages
130    # from kickstart: mcelog mobile-broadband-provider-info
131    # ModemManager PackageKit
133# We need an upstream version of cgi which we've packaged ourselves, but
134# it doesn't work with the haskell-platform package which expects
135# explicit versions.  So temporarily rpm -e the package, and then
136# install it again after you install haskell-platform.  [Note: You
137# probably won't need this in Fedora 17 or something, when the Haskell
138# Platform gets updated.]
139    rpm -e ghc-cgi-devel ghc-cgi
140    yum install -y haskell-platform
141    yumdownloader ghc-cgi
142    yumdownloader ghc-cgi-devel
143    rpm -i ghc-cgi*1.8.1*.rpm
145# ----------------------------->8--------------------------------------
146#                      SPHEROID SHENANIGANS
148# Note: Since ultimately we'd like to move away from using per-language
149# package manager and all of these be RPMs, it is of questionable
150# importance how much /good/ automation for these is necessary.
152# Warning: For a new release, we're supposed to check if Fedora has
153# packaged up the RPM.  Unfortunately we don't really have good incants
154# for this.
156# Install the full list of perl modules that users expect to be on the
157# servers.
158    cd /root
159    export PERL_MM_USE_DEFAULT=1
160    cpan # this is interactive, enter the next two lines
161        o conf prerequisites_policy follow
162        o conf commit
163# on a reference server
164perldoc -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
165# arrange for perl-packages.txt to be transferred to server
166    cat perl-packages.txt | perl -MCPAN -e shell
168# Install the Python eggs and Ruby gems and PEAR/PECL doohickeys that are on
169# the other servers and do not have RPMs.
170# The general mode of operation will be to run the "list" command
171# on both servers, see what the differences are, check if those diffs
172# are packaged up as rpms, and install them (rpm if possible, native otherwise)
173# - Look at /usr/lib/python2.6/site-packages and
174#           /usr/lib64/python2.6/site-packages for Python eggs and modules.
175#   There will be a lot of gunk that was installed from packages;
176#   easy-install.pth in /usr/lib/ will tell you what was easy_installed.
177#   First use 'yum search' to see if the relevant package is now available
178#   as an RPM, and install that if it is.  If not, then use easy_install.
179#   Pass -Z to easy_install to install them unzipped, as some zipped eggs
180#   want to be able to write to ~/.python-eggs.  (Also makes sourcediving
181#   easier.)
182# 'easy_install AuthKit jsonlib2 pygit'
183cat /usr/lib/python2.7/site-packages/easy-install.pth | grep "^./" | cut -c3- | cut -f1 -d- > egg.txt
184    cat egg.txt | xargs easy_install -Z
186# - Look at `gem list` for Ruby gems.
187#   Again, use 'yum search' and prefer RPMs, but failing that, 'gem install'.
188#       ezyang: rspec-rails depends on rspec, and will override the Yum
189#       package, so... don't use that RPM yet
190# XXX This doesn't do the right thing for old version gems
191gem list --no-version > gem.txt
192    gem install $(gem list --no-version | grep -Fxvf - gem.txt)
193    # Also, we need to install the old rails version
194    gem install -v=2.3.5 rails
196# - Look at `pear list` for Pear fruits (or whatever they're called).
197#   Yet again, 'yum search' for RPMs before resorting to 'pear install'.  Note
198#   that for things in the beta repo, you'll need 'pear install package-beta'.
199#   (you might get complaints about the php_scripts module; ignore them)
200pear list | tail -n +4 | cut -f 1 -d " " > pear.txt
201    pear config-set preferred_state beta
202    pear channel-update
203    pear install $(pear list | tail -n +4 | cut -f 1 -d " " | grep -Fxvf - pear.txt)
205# - Look at `pecl list` for PECL things.  'yum search', and if you must,
206#   'pecl install' needed items. If it doesn't work, try 'pear install
207#   pecl/foo' or 'pecl install foo-beta' or those two combined.
208pecl list | tail -n +4 | cut -f 1 -d " " > pecl.txt
209    pecl install --nodeps $(pecl list | tail -n +4 | cut -f 1 -d " " | grep -Fxvf - pecl.txt)
211# ----------------------------->8--------------------------------------
212#                       INFINITE CONFIGURATION
214# Create fedora-ds user (needed for credit-card)
215useradd -u 103 -r -d /var/lib/dirsrv fedora-ds
217# Run credit-card to clone in credentials and make things runabble
218python push $server
220# This is superseded by credit-card, but only for [PRODUCTION]
221# Don't use credit-card on [WIZARD]: it will put in the wrong creds!
223#   # All types of servers will have an /etc/daemon.keytab file, however,
224#   # different types of server will have different credentials in this
225#   # keytab.
226#   #   [PRODUCTION] daemon.scripts
227#   #   [WIZARD]     daemon.scripts-security-upd
228#   #   [TESTSERVER] daemon.scripts-test
230# [PRODUCTION/WIZARD] Fix the openafs /usr/vice/etc <-> /etc/openafs
231# mapping.
232    echo "/afs:/usr/vice/cache:10000000" > /usr/vice/etc/cacheinfo
233    echo "" > /usr/vice/etc/ThisCell
234# [TESTSERVER] If you're installing a test server, this needs to be
235# much smaller; the max filesize on XVM is 10GB.  Pick something like
236# 500000. Also, some of the AFS parameters are kind of retarded (and if
237# you're low on disk space, will actually exhaust our inodes).  Edit
238# these parameters in /etc/sysconfig/openafs (but wait, that won't
239# work, will it...)
240    echo "/afs:/usr/vice/cache:500000" > /usr/vice/etc/cacheinfo
241    vim /etc/sysconfig/openafs
243# Test that zephyr is working
244    systemctl enable zhm.service
245    systemctl start zhm.service
246    echo 'Test!' | zwrite -d -c scripts -i test
248# Check out the scripts /usr/vice/etc configuration
249    cd /root/vice
250    \cp -a etc /usr/vice
252# [PRODUCTION] Set up replication (see ./install-ldap).
253# You'll need the LDAP keytab for this server: be sure to chown it
254# fedora-ds after you create the fedora-ds user
255    ls -l /etc/dirsrv/keytab
256    cat install-ldap
258# Enable lots of services
259    systemctl enable openafs-client.service
260    systemctl enable dirsrv.service
261    systemctl enable nslcd.service
262    systemctl enable nscd.service
263    systemctl enable postfix.service
264    systemctl enable nrpe.service
265    systemctl enable httpd.service # not for [WIZARD]
267    systemctl start openafs-client.service
268    systemctl start dirsrv.service
269    systemctl start nslcd.service
270    systemctl start nscd.service
271    systemctl start postfix.service
272    systemctl start nrpe.service
273    systemctl start httpd.service # not for [WIZARD]
275# Note about OpenAFS: Check that fs sysname is correct.  You should see,
276# among others, 'amd64_fedoraX_scripts' (vary X) and 'scripts'. If it's
277# not, you probably did a distro upgrade and should update
278# /etc/sysconfig/openafs (XXX this is wrong: figuring out new
279# systemd world order).
280    fs sysname
282# Postfix doesn't actually deliver mail; fix this
283    cd /etc/postfix
284    postmap virtual
286# Munin might not be monitoring packages that were installed after it
287    munin-node-configure --suggest --shell | sh
289# Run fmtutil-sys --all, which does something that makes TeX work.
290# (Note: this errors on XeTeX which is ok.)
291    fmtutil-sys --all
293# Ensure that PHP isn't broken:
294    mkdir /tmp/sessions
295    chmod 01777 /tmp/sessions
296    # XXX: this seems to get deleted if tmp gets cleaned up, so we
297    # might need something a little better (maybe init script.)
299# Fix etc by making sure none of our config files got overwritten
300    cd /etc
301    svn status -q
302    # Some usual candidates for clobbering include nsswitch.conf,
303    # resolv.conf and sysconfig/openafs
304    # [WIZARD/TEST] Remember that changes you made should not get
305    # reverted!
307# Reboot the machine to restore a consistent state, in case you
308# changed anything. (Note: Starting kdump fails (this is ok))
310# When all is said and done, fix up the Subversion checkouts
311    cd /etc
312    svn switch --relocate svn://$source_server/ svn://
313    cd /usr/vice/etc
314    svn switch --relocate svn://$source_server/ svn://
315    cd /srv/repository
316    # Some commands should be run as the scripts-build user, not root.
317    alias asbuild="sudo -u scripts-build"
318    asbuild svn switch --relocate svn://$source_server/ svn://
319    asbuild svn up # verify works
321# ------------------------------->8-------------------------------
324# [OPTIONAL] Your machine's hostname is baked in at install time;
325# in the rare case you need to change it: it appears to be in:
326#   o /etc/sysconfig/network
327#   o your lvm thingies; probably don't need to edit
329# [WIZARD/TESTSERVER] If you are setting up a non-production server,
330# there are some services that it won't provide, and you will need to
331# make it talk to a real server instead.  In particular:
332#   - We don't serve the web, so don't bind
333#   - We don't serve LDAP, so use another server
334# This involves editing the following files:
335#   o /etc/sysconfig/network-scripts/ifcfg-lo:0
336#   o /etc/sysconfig/network-scripts/ifcfg-lo:1
337#   o /etc/sysconfig/network-scripts/ifcfg-lo:2
338#   o /etc/sysconfig/network-scripts/ifcfg-lo:3
339       \rm /etc/sysconfig/network-scripts/ifcfg-lo:{0,1,2,3}
340#   o /etc/ldap.conf
341#       add: host
342#   o /etc/{nss-ldapd,nslcd}.conf
343#       replace: uri ldapi://%2fvar%2frun%2fdirsrv%2fslapd-scripts.socket/
344#       with: uri ldap://
345#   o /etc/openldap/ldap.conf
346#       add: URI ldap://
347#            BASE dc=scripts,dc=mit,dc=edu
348#   o /etc/httpd/conf.d/vhost_ldap.conf
349#       replace: VhostLDAPUrl "ldap://,dc=scripts,dc=mit,dc=edu"
350#       with: VhostLDAPUrl "ldap://,dc=scripts,dc=mit,dc=edu"
351#   o /etc/postfix/virtual-alias-{domains,maps}
352#       replace: server_host ldapi://%2fvar%2frun%2fdirsrv%2fslapd-scripts.socket/
353#       with: server_host = ldap://
354# to use instead of localhost.
355# XXX: someone should write sed scripts to do this
357# [WIZARD/TESTSERVER] If you are setting up a non-production server,
358# afsagent's cronjob will attempt to be renewing with the wrong
359# credentials (daemon.scripts). Change this:
360    vim /home/afsagent/renew # replace all mentions of
363#   - You need a self-signed SSL cert or Apache will refuse to start
364#     or do SSL.  Generate with:
365    openssl req -new -x509 -keyout /etc/pki/tls/private/scripts.key -out /etc/pki/tls/certs/scripts.cert -nodes
366#     Also make /etc/pki/tls/certs/ca.pem match up (XXX what's the
367#     incant for that?)
369# [TESTSERVER] More stuff for test servers
370#   - Make (/etc/aliases) root mail go to /dev/null, so we don't spam people
371#   - Edit /etc/httpd/conf.d/scripts-vhost-names.conf to have
372#     be an accepted vhost name
373#   - Look at the old test server and see what config changes are floating around
Note: See TracBrowser for help on using the repository browser.