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