Remove NUMNODES and WITH_TSM_NODE configuration variables
[tridge/autocluster.git] / config.d / 00base.defconf
1 # Hey Emacs, this is a -*- shell-script -*- !!!
2
3 ######################################################################
4
5 # Cluster
6
7 defconf CLUSTERFS_TYPE "gpfs" \
8         "<gpfs|?>" "type of cluster filesystem to use"
9
10 defconf CLUSTERFS_DEFAULT_MOUNTPOINT "/clusterfs" \
11         "<directory>" "mountpoint for default cluster filesystem"
12
13 defconf NODES "nas:0-3 rhel_base:4" \
14         "<nodes>" "list of node types to create, with associated IP offsets"
15
16 # a directory on the host which will be mounted via NFS onto the nodes
17 # as $NFS_MOUNTPOINT, giving a nice common area independent of the
18 # cluster filesystem.  This is useful for compiles, RPMs, devel
19 # scripts etc you need to add this to your /etc/exports and run
20 # exportfs -av yourself on the virtualisation host
21 defconf NFSSHARE "10.0.0.1:/home" \
22         "<mnt>" "NFS share to mount on each node"
23
24 defconf NFS_MOUNTPOINT "/home" \
25         "<dir>" "mount point for NFS share"
26
27 ######################################################################
28
29 # Directories and files
30
31 # these are the default autocluster config options
32 # please override with your own options in your own config file
33
34 defconf VIRTBASE /virtual \
35         "<path>" "virtual machine directory for this host"
36
37 # the name of the base RHEL install image that the nodes will be based on
38 # a kvm image called $VIRTBASE/$BASENAME.img will be created
39 # that will form the basis file for the images for each of the nodes
40 defconf BASENAME "ac-base" \
41         "<file>" "filename for cluster base image"
42
43 defconf BASE_PER_NODE_TYPE "no" \
44         "<yes|no>" "Use per-node-type base images"
45
46 defconf DISK_FOLLOW_SYMLINKS "no" \
47         "<yes|no>" "If disk images use symlinks then follow them to overwrite"
48
49 ######################################################################
50
51 # Virtualisation
52
53 defconf VIRSH "virsh -c qemu:///system" \
54         "<cmd>" "how to invoke virsh"
55
56 defconf KVM "@uto" \
57         "<file>"  "location of KVM executable"
58
59 defconf KVMLOG "/var/log/kvm" \
60         "<dir>" "directory for serial logs"
61
62 defconf NODE_TEMPLATE "$installdir/templates/node.xml" \
63         "<file>" "libvirt template for nodes"
64
65 defconf INSTALL_TEMPLATE "$installdir/templates/install.xml" \
66         "<file>" "libvirt template for initial install"
67
68 defconf INSTALL_KERNEL_OPTIONS "@uto" \
69         "<options>" "installer kernel command-line options"
70
71 defconf BOOT_TEMPLATE "$installdir/templates/bootbase.xml" \
72         "<file>" "libvirt template for \"bootbase\" command"
73
74 defconf BASE_TEMPLATES "$installdir/base" \
75         "<dir>" "directory containing base templates"
76
77 defconf BASE_FORMAT "qcow2" \
78         "<fmt>" "format to use for the qemu base images"
79
80 defconf SYSTEM_DISK_TYPE "ide" \
81         "scsi|ide|virtio" "type of disks to use in nodes"
82
83 rhel_disk_prefix ()
84 {
85     case "$1" in
86         (scsi|iscsi) echo "sd" ;;
87         (virtio)     echo "vd" ;;
88         ide)
89             case "$RHEL_VERSION" in
90                 (5.*) echo "hd" ;;
91                 ([67].*) echo "sd" ;;
92                 (*) die "Unknown RHEL_VERSION in rhel_disk_prefix" ;;
93             esac
94             ;;
95         (*) die "Unknown disk type \"$1\" in rhel_disk_prefix" ;;
96             
97     esac
98 }
99
100 defconf SYSTEM_DISK_PREFIX "@uto" \
101         "sd|hd|vd" "system disk device prefix"
102
103 defconf SYSTEM_DISK_CACHE "writeback" \
104         "default|none|writeback|writethrough" "system disk cache type"
105
106 defconf SYSTEM_DISK_FORMAT "qcow2" \
107         "qcow2|raw|reflink|mmclone|none" "system disk image format"
108
109 defconf SYSTEM_DISK_ACCESS_METHOD "@uto" \
110         "loopback|guestfish|guestmount" "how to setup up disk images"
111
112 system_disk_access_method_hook ()
113 {
114     if [ "$SYSTEM_DISK_ACCESS_METHOD" = "@uto" ] ; then
115         if [ "$SYSTEM_DISK_FORMAT" = "qcow2" ] ; then
116             if which guestmount >/dev/null 2>&1 ; then
117                 SYSTEM_DISK_ACCESS_METHOD="guestmount"
118             elif which guestfish >/dev/null 2>&1 ; then
119                 SYSTEM_DISK_ACCESS_METHOD="guestfish"
120             elif which qemu-nbd nbd-client >/dev/null 2>&1 ; then
121                 SYSTEM_DISK_ACCESS_METHOD="loopback"
122             else
123                 die "Can't determine SYSTEM_DISK_ACCESS_METHOD.  Need guestfish or qemu-nbd + nbd-client."
124             fi
125         else
126             SYSTEM_DISK_ACCESS_METHOD="loopback"
127         fi
128     fi
129 }
130
131 register_hook post_config_hooks system_disk_access_method_hook
132
133 system_disk_mounts ()
134 {
135     # We could call a function using call_func().  However, we want
136     # the options listed in the documentation for
137     # SYSTEM_DISK_ACCESS_METHOD, so they need to be hardcoded...  so
138     # we might as well hardcode this function (for now).
139     case "$SYSTEM_DISK_ACCESS_METHOD" in
140         loopback)
141             case "$RHEL_VERSION" in
142                 (5.*) echo "/:32256" ;;
143                 ([67].*) echo "/:1048576" ;;
144                 (*) die "Unknown RHEL_VERSION in system_disk_mounts" ;;
145             esac
146             ;;
147         (guestfish|guestmount) : ;;
148         (*) die "Unknown SYSTEM_DISK_ACCESS_METHOD in system_disk_mounts" ;;
149     esac
150 }
151
152 defconf SYSTEM_DISK_MOUNTS "@uto" \
153         "<list>" "list of mountpoints and offsets/devices for mount_disk()"
154
155 ######################################################################
156
157 # Node
158
159 # what timezone to put the nodes in
160 # leave this empty to base the timezone on the zone that
161 # this host is in
162 defconf TIMEZONE "" \
163         "<tz>" "timezone for each node"
164
165 # how much disk space to use on each node
166 # note that it will only use what is actually occupied,
167 # so start this larger than you think you'll need
168 defconf DISKSIZE "20G" \
169         "<n>G" "maximum disk size for each node"
170
171 defconf ROOTSIZE 15000 \
172         "<n>" "size of root partition in MB"
173
174 defconf SWAPSIZE 2000 \
175         "<n>" "size of swap partition in MB"
176
177 rhel_default_mem ()
178 {
179     case "$RHEL_VERSION" in
180         (5.*) echo "262144" ;;
181         ([67].*) echo "512000" ;;
182         (*) die "Unknown RHEL_VERSION in rhel_default_mem" ;;
183     esac
184 }
185
186 defconf MEM "@uto" \
187         "<n>" "memory allocated for each node"
188
189 defconf NICMODEL "e1000" \
190         "<module>" "choice of KVM network adapter"
191
192 defconf ROOTPASSWORD "password" \
193         "<string>" "initial root password for each node"
194
195 defconf NUMCPUS 2 \
196         "<n>" "number of virtual CPUs per node"
197
198 # Some machines need "clocksource=jiffies"
199 defconf EXTRA_KERNEL_OPTIONS "" \
200         "<string>" "extra kernel options for nodes"
201
202 defconf HOSTNAME_HACKING_FUNCTION "" \
203         "<string>" "function to modify node hostnames, see the code for details"
204
205 defconf HOSTS_STATIC_ENTRIES "/dev/null" \
206         "<file>" "a file containing extra static entries to add to /etc/hosts"
207
208 ######################################################################
209
210 # Networking
211
212 defconf DOMAIN "EXAMPLE.COM" \
213         "<dom>" "Windows(TM) domain name for each node"
214
215 defconf WORKGROUP "EXAMPLE" \
216         "<grp>" "Windows(TM) workgroup for node"
217
218 # DNS name server. Usually set this to the
219 # kvm host, then setup DNS on the kvm host to direct 
220 # queries for the windows domain name to the w2003 server
221 defconf NAMESERVER "10.0.0.1" \
222         "<ip>" "DNS server for each node"
223
224 defconf DNSSEARCH "$DOMAIN" \
225         "<dom>" "extra domains for DNS search list"
226
227 # Networks:
228 # * First network is private and contains the CTDB node addresses.
229 # * Items look like: net/bits,dev[,nat|bridge=host_iface][,gw=gateway_ip]
230
231 # * Right now autocluster only supports 24 bit networks.  This will
232 #   be improved in the future.
233 defconf NETWORKS "10.0.0.0/24,eth0,gw=10.0.0.1 10.0.1.0/24,eth1 10.0.2.0/24,eth2" \
234         "<list>" "description of IP networks"
235
236 make_public_addresses()
237 {
238         local firstip="${1:-$[${FIRSTIP} + ${PUBLIC_IP_OFFSET}]}"
239         local num_addrs="$2"
240
241         # By default the number of addresses on each public network is
242         # the same as the number of nodes
243         if [ -z "$num_addrs" ] ; then
244             num_addrs=0
245             _count_ctdb_nodes ()
246             {
247                 if [ "$4" = "1" ] ; then
248                     num_addrs=$(($num_addrs + 1))
249                 fi
250             }
251             for_each_node _count_ctdb_nodes
252         fi
253
254         if [ $(( $firstip + $num_addrs - 1 )) -gt 254 ]; then
255             die "make_public_addresses: last octet > 254 - change PUBLIC_IP_OFFSET"
256         fi
257
258         local n
259         for n in $NETWORKS_PUBLIC ; do
260             local dev="${n#*,}" # Strip address, comma
261             dev="${dev%,*}" # Strip comma, interface
262             echo -ne "${n%.*}.${firstip},${num_addrs},${dev} "
263         done
264         echo
265 }
266
267 networks_post_config_hook ()
268 {
269     local n
270     for n in $NETWORKS ; do
271         local ip_mask="${n%%,*}"
272         local mask="${ip_mask#*/}"
273
274         [ "$mask" = "24" ] || \
275             die "Network maskbits other than 24 unsupported in \"$n\""
276     done
277
278     [ -z "$IPBASE" -a -z "$IPNET0" -a -z "$IPNET1" -a -z "$IPNET2" ] || \
279         die "Configuration variables IPBASE, IPNET0/1/2 unsupported - please use NETWORKS"
280
281     # Convenience variables
282     set -- $NETWORKS
283     NETWORK_PRIVATE="$1" ; shift
284     local t="${NETWORK_PRIVATE%%,*}"
285     NETWORK_PRIVATE_PREFIX="${t%.*}"
286     NETWORKS_PUBLIC="$*"
287 }
288
289 register_hook post_config_hooks networks_post_config_hook
290
291 defconf NETWORK_TEMPLATE "|network_template" \
292         "<file>" "libvirt template fragment for networks"
293
294 network_template ()
295 {
296     local netname dev ip mask mac opts
297     while read netname dev ip mask mac opts ; do
298         cat <<EOF
299     <interface type='network'>
300       <mac address='${mac}'/>
301       <model type='@@NICMODEL@@'/>
302       <source network='${netname}'/>
303     </interface>
304 EOF
305     done <"$network_map"
306 }
307
308
309 # the nodes will get IPs starting at this number 
310 # the TSM server will get $FIRSTIP, then the first node will get
311 # the next IP etc
312 # so if the private network is 10.0.0.0/24,eth0 and FIRSTIP is 20 then
313 # you will get nodes like this:
314 #     tsmserver   10.0.0.20
315 #     1st node    10.0.0.21
316 #     2nd node    10.0.0.22
317 # etc etc
318 defconf FIRSTIP "20" \
319         "<n>" "final octet for the 1st IP of the cluster"
320
321 # Public addresses managed by CTDB.
322 defconf PUBLIC_IP_OFFSET 100 \
323         "<n>" "offset from FIRSTIP of public IP addresses"
324
325 defconf PUBLIC_ADDRESSES "|make_public_addresses" \
326         "<cmd>" "template for public address entry in nas.conf"
327
328 # a caching web proxy that can get to the install server from the
329 # nodes. If you don't have one on the local network then look in
330 # host_setup/etc/squid for an example setup you can install on the kvm
331 # host. The web proxy must cache large objects, and have room for
332 # several G of cache You can choose to have no web proxy at all, in
333 # which case set it to the empty string, and hope you have a fast
334 # network connection to the install server
335 defconf WEBPROXY "" \
336         "<url>" "URL of a caching web proxy"
337
338 defconf KVMHOST "10.0.0.1" \
339         "<ip>" "KVM host - provides things like NTP, iSCSI targets, ..."
340
341 defconf KDC_NAME "example-ad" \
342         "<name>" "prefix of the name of the KDC"
343
344 ######################################################################
345
346 # RHEL
347
348 rhel_print_iso ()
349 {
350     # Uses: RHEL_VERSION, RHEL_ARCH
351     # Prints: a value for ISO
352
353     local datever
354
355     case "$RHEL_VERSION" in
356         (5.1) datever="20071017.0";;
357         (5.2) datever="20080430.0";;
358         (5.3) datever="20090106.0";;
359         (5.4) datever="20090819.0";;
360         (5.5) datever="20100322.0";;
361         (5.6) datever="20110106.0";;
362         (5.7) datever="20110711.5";;
363         (5.8) datever="20120202.0";;
364         (6.0) datever="20100922.1";;
365         (6.1) datever="20110510.1";;
366         (6.2) datever="20111117.0";;
367         (6.3) datever="20120613.2";;
368         (6.4) datever="20130130.0";;
369         (6.5) datever="20131111.0";;
370         (7.0) datever="20140507.0";;
371         (*) die "Unknown RHEL_VERSION in rhel_print_iso" ;;
372     esac
373
374     case "$RHEL_VERSION" in
375         (5.*) echo "RHEL${RHEL_VERSION}-Server-${datever}-${RHEL_ARCH}-DVD.iso"  ;;
376         (6.*) echo "RHEL${RHEL_VERSION}-${datever}-Server-${RHEL_ARCH}-DVD1.iso" ;;
377         (7.*) echo "RHEL-${RHEL_VERSION}-${datever}-Server-${RHEL_ARCH}-dvd1.iso" ;;
378     esac
379 }
380
381 # yum repo infrastructure
382 _YUM_TEMPLATE="$installdir/templates/RHEL.repo" # Private - used below!
383 rhel_gen_yum_repos ()
384 {
385     echo "# Generated by autocluster."
386
387     for repo ; do
388 # Repo IDs can not contain slashes, so replace slashes with dashes.
389 cat <<EOF
390 [${repo//\//-}]
391 name=${repo}
392 baseurl=@@INSTALL_SERVER@@/${repo}
393 enabled=1
394 gpgcheck=0
395
396 EOF
397     done
398
399 cat <<EOF
400 @@@_YUM_TEMPLATE@@@
401 EOF
402 }
403
404 get_kvm_path ()
405 {
406     local t
407
408     if t=$(which qemu-kvm 2>/dev/null) ; then
409         echo "$t"
410     elif t=$(which kvm 2>/dev/null) ; then
411         echo "$t"
412     elif [ -x "/usr/libexec/qemu-kvm" ] ; then
413         echo "/usr/libexec/qemu-kvm"
414     else
415         die "Could not find KVM executable"
416     fi
417
418 }
419
420 rhel_get_install_kernel_options ()
421 {
422     case "$RHEL_VERSION" in
423         (7.*) echo "ks=hd:LABEL=KICKSTART inst.stage2=hd:LABEL=RHEL-${RHEL_VERSION}\\\\x20Server.${RHEL_ARCH}" ;;
424         (*) echo "ks=floppy" ;;
425     esac
426 }
427
428 rhel_get_install_ks_device_xml ()
429 {
430     if [ ${RHEL_VERSION%%.*} -le 6 ] ; then
431         cat <<EOF
432     <disk type='file' device='floppy'>
433       <source file='@@PWD@@/tmp/floppy.img'/>
434       <target dev='fda'/>
435       <readonly/>
436     </disk>
437 EOF
438     else
439         cat <<EOF
440     <disk type='file' device='disk'>
441       <source file='@@PWD@@/tmp/floppy.img'/>
442       <target dev='@@SYSTEM_DISK_PREFIX@@b' bus='@@SYSTEM_DISK_TYPE@@'/>
443       <driver name='qemu' type='raw'/>
444     </disk>
445 EOF
446     fi
447 }
448
449 rhel_get_multipath_magic ()
450 {
451     if [ ${RHEL_VERSION%%.*} -le 6 ] ; then
452         cat <<EOF
453  udev_dir                /dev
454  getuid_callout          "$SHARED_DISK_MULTIPATH_CALLOUT"
455 EOF
456     fi
457 }
458
459 rhel_post_config_hook ()
460 {
461     if [ "$ISO" = "@uto" ] ; then
462         ISO=$(rhel_print_iso) || exit $?
463     fi
464
465     if [ "$SYSTEM_DISK_MOUNTS" = "@uto" ] ; then
466         SYSTEM_DISK_MOUNTS=$(system_disk_mounts) || exit $?
467     fi
468
469     if [ "$MEM" = "@uto" ] ; then
470         MEM=$(rhel_default_mem) || exit $?
471     fi
472
473     if [ "$SYSTEM_DISK_PREFIX" = "@uto" ] ; then
474         SYSTEM_DISK_PREFIX=$(rhel_disk_prefix $SYSTEM_DISK_TYPE) || exit $?
475     fi
476
477     if [ "$KVM" = "@uto" ] ; then
478         KVM=$(get_kvm_path) || exit $?
479     fi
480
481     if [ "$INSTALL_KERNEL_OPTIONS" = "@uto" ] ; then
482         INSTALL_KERNEL_OPTIONS=$(rhel_get_install_kernel_options) || exit $?
483     fi
484
485     if [ "$INSTALL_KS_DEVICE_TEMPLATE" = "@uto" ] ; then
486         INSTALL_KS_DEVICE_TEMPLATE=$(rhel_get_install_ks_device_xml) || exit $?
487     fi
488
489     if [ "$RHEL_MULTIPATH_MAGIC" = "@uto" ] ; then
490         RHEL_MULTIPATH_MAGIC=$(rhel_get_multipath_magic) || exit $?
491     fi
492 }
493
494 register_hook post_config_hooks rhel_post_config_hook
495
496 defconf RHEL_ARCH "x86_64" \
497         "<arch>" "The RHEL operating system architecture to configure"
498
499 defconf RHEL_VERSION "6.2" \
500         "<version>" "version of Red Hat Enterprise Linux to configure"
501
502 defconf RHEL_MULTIPATH_MAGIC "@uto"
503
504 defconf ISO_DIR "/virtual/ISO" \
505         "<dir>" "directory for ISO images, prepended to $ISO if not absolute"
506
507 defconf ISO "@uto" \
508         "<file>" "ISO image for base image creation"
509
510 # the install server where we will get local packages from
511 defconf INSTALL_SERVER "http://10.0.0.1/mediasets" \
512         "<url>" "URL of install server"
513
514 defconf CONFIG_EXTRA_PACKAGES "" \
515         "<packages>" "list of extra packages to install at configuration time"
516
517 # the yum repositories to use. Choose the one appropriate for the
518 # system you are installing
519 defconf YUM_TEMPLATE "$_YUM_TEMPLATE" \
520         "<file>" "location of template for yum repositories"
521
522 defconf INSTALL_KS_DEVICE_TEMPLATE "@uto"
523
524 ##############################
525
526 defconf CREATE_BASE_TIMEOUT 3600 \
527         "<seconds>" "time to wait for base image install before aborting" 
528
529 ##############################
530
531 register_hook hack_nodes_functions hack_nodes_rhel_base
532
533 hack_nodes_rhel_base ()
534 {
535     local node_count_rhel_base=0
536     hack_filter ()
537     {
538         case "$node_type" in
539             rhel_base)
540                 node_count_rhel_base=$(($node_count_rhel_base + 1))
541                 name="${CLUSTER}base${node_count_rhel_base}"
542                 # rhel_base nodes are not part of CTDB cluster
543                 ctdb_node=0
544             esac
545     }
546     hack_all_nodes_with hack_filter
547 }
548
549 create_node_rhel_base ()
550 {
551     local ip_offset="$1"
552     local name="$2"
553     local ctdb_node="$3"
554
555     echo "Creating RHEL base node $name"
556     create_node_COMMON "$name" "$ip_offset" "$type"
557 }
558
559 ##############################
560
561 # Authentication method
562 defconf AUTH_METHOD "files" \
563     "files|winbind" "authentication method"
564
565 ##############################