1 # Hey Emacs, this is a -*- shell-script -*- !!!
3 ######################################################################
7 defconf CLUSTER_TYPE "samba" \
8 "samba|ad|build" "Type of cluster, for configuration stage"
10 defconf CLUSTERFS_TYPE "gpfs" \
11 "<gpfs|?>" "type of cluster filesystem to use"
13 defconf CLUSTERFS_DEFAULT_MOUNTPOINT "/clusterfs" \
14 "<directory>" "mountpoint for default cluster filesystem"
16 defconf NODES "sofs_front:0-3 rhel_base:4" \
17 "<nodes>" "list of node types to create, with associated IP offsets"
20 "<n>" "number of nodes to build, not including TSM server"
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"
30 defconf NFS_MOUNTPOINT "/home" \
31 "<dir>" "mount point for NFS share"
33 ######################################################################
35 # Directories and files
37 # these are the default autocluster config options
38 # please override with your own options in your own config file
40 defconf VIRTBASE /virtual \
41 "<path>" "virtual machine directory for this host"
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"
49 defconf BASE_PER_NODE_TYPE "no" \
50 "<yes|no>" "Use per-node-type base images"
52 defconf DISK_FOLLOW_SYMLINKS "no" \
53 "<yes|no>" "If disk images use symlinks then follow them to overwrite"
55 ######################################################################
59 defconf VIRSH "virsh -c qemu:///system" \
60 "<cmd>" "how to invoke virsh"
63 "<file>" "location of KVM executable"
65 defconf KVMLOG "/var/log/kvm" \
66 "<dir>" "directory for serial logs"
68 defconf NODE_TEMPLATE "$installdir/templates/node.xml" \
69 "<file>" "libvirt template for nodes"
71 defconf INSTALL_TEMPLATE "$installdir/templates/install.xml" \
72 "<file>" "libvirt template for initial install"
74 defconf INSTALL_KERNEL_OPTIONS "@uto" \
75 "<options>" "installer kernel command-line options"
77 defconf BOOT_TEMPLATE "$installdir/templates/bootbase.xml" \
78 "<file>" "libvirt template for \"bootbase\" command"
80 defconf BASE_TEMPLATES "$installdir/base" \
81 "<dir>" "directory containing base templates"
83 defconf BASE_FORMAT "qcow2" \
84 "<fmt>" "format to use for the qemu base images"
86 defconf SYSTEM_DISK_TYPE "ide" \
87 "scsi|ide|virtio" "type of disks to use in nodes"
92 (scsi|iscsi) echo "sd" ;;
95 case "$RHEL_VERSION" in
98 (*) die "Unknown RHEL_VERSION in rhel_disk_prefix" ;;
101 (*) die "Unknown disk type \"$1\" in rhel_disk_prefix" ;;
106 defconf SYSTEM_DISK_PREFIX "@uto" \
107 "sd|hd|vd" "system disk device prefix"
109 defconf SYSTEM_DISK_CACHE "writeback" \
110 "default|none|writeback|writethrough" "system disk cache type"
112 defconf SYSTEM_DISK_FORMAT "qcow2" \
113 "qcow2|raw|reflink|mmclone|none" "system disk image format"
115 defconf SYSTEM_DISK_ACCESS_METHOD "@uto" \
116 "loopback|guestfish|guestmount" "how to setup up disk images"
118 system_disk_access_method_hook ()
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"
129 die "Can't determine SYSTEM_DISK_ACCESS_METHOD. Need guestfish or qemu-nbd + nbd-client."
132 SYSTEM_DISK_ACCESS_METHOD="loopback"
137 register_hook post_config_hooks system_disk_access_method_hook
139 system_disk_mounts ()
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
147 case "$RHEL_VERSION" in
148 (5.*) echo "/:32256" ;;
149 ([67].*) echo "/:1048576" ;;
150 (*) die "Unknown RHEL_VERSION in system_disk_mounts" ;;
153 (guestfish|guestmount) : ;;
154 (*) die "Unknown SYSTEM_DISK_ACCESS_METHOD in system_disk_mounts" ;;
158 defconf SYSTEM_DISK_MOUNTS "@uto" \
159 "<list>" "list of mountpoints and offsets/devices for mount_disk()"
161 ######################################################################
165 # what timezone to put the nodes in
166 # leave this empty to base the timezone on the zone that
168 defconf TIMEZONE "" \
169 "<tz>" "timezone for each node"
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"
177 defconf ROOTSIZE 15000 \
178 "<n>" "size of root partition in MB"
180 defconf SWAPSIZE 2000 \
181 "<n>" "size of swap partition in MB"
185 case "$RHEL_VERSION" in
186 (5.*) echo "262144" ;;
187 ([67].*) echo "512000" ;;
188 (*) die "Unknown RHEL_VERSION in rhel_default_mem" ;;
193 "<n>" "memory allocated for each node"
195 defconf NICMODEL "e1000" \
196 "<module>" "choice of KVM network adapter"
198 defconf ROOTPASSWORD "password" \
199 "<string>" "initial root password for each node"
202 "<n>" "number of virtual CPUs per node"
204 # Some machines need "clocksource=jiffies"
205 defconf EXTRA_KERNEL_OPTIONS "" \
206 "<string>" "extra kernel options for nodes"
208 defconf HOSTNAME_HACKING_FUNCTION "" \
209 "<string>" "function to modify node hostnames, see the code for details"
211 defconf HOSTS_STATIC_ENTRIES "/dev/null" \
212 "<file>" "a file containing extra static entries to add to /etc/hosts"
214 ######################################################################
218 defconf DOMAIN "EXAMPLE.COM" \
219 "<dom>" "Windows(TM) domain name for each node"
221 defconf WORKGROUP "EXAMPLE" \
222 "<grp>" "Windows(TM) workgroup for node"
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"
230 defconf DNSSEARCH "$DOMAIN" \
231 "<dom>" "extra domains for DNS search list"
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]
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"
242 has_public_addresses_DEFAULT ()
247 make_public_addresses()
249 local firstip="${1:-$[${FIRSTIP} + ${PUBLIC_IP_OFFSET}]}"
250 local num_addrs="${2:-${NUMNODES}}"
252 if [ $(( $firstip + $num_addrs - 1 )) -gt 254 ]; then
253 die "make_public_addresses: last octet > 254 - change PUBLIC_IP_OFFSET"
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} "
265 networks_post_config_hook ()
268 for n in $NETWORKS ; do
269 local ip_mask="${n%%,*}"
270 local mask="${ip_mask#*/}"
272 [ "$mask" = "24" ] || \
273 die "Network maskbits other than 24 unsupported in \"$n\""
276 [ -z "$IPBASE" -a -z "$IPNET0" -a -z "$IPNET1" -a -z "$IPNET2" ] || \
277 die "Configuration variables IPBASE, IPNET0/1/2 unsupported - please use NETWORKS"
279 # Convenience variables
281 NETWORK_PRIVATE="$1" ; shift
282 local t="${NETWORK_PRIVATE%%,*}"
283 NETWORK_PRIVATE_PREFIX="${t%.*}"
287 register_hook post_config_hooks networks_post_config_hook
289 defconf NETWORK_TEMPLATE "|network_template" \
290 "<file>" "libvirt template fragment for networks"
294 local netname dev ip mask mac opts
295 while read netname dev ip mask mac opts ; do
297 <interface type='network'>
298 <mac address='${mac}'/>
299 <model type='@@NICMODEL@@'/>
300 <source network='${netname}'/>
307 # the nodes will get IPs starting at this number
308 # the TSM server will get $FIRSTIP, then the first node will get
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
316 defconf FIRSTIP "20" \
317 "<n>" "final octet for the 1st IP of the cluster"
319 # Public addresses managed by CTDB.
320 defconf PUBLIC_IP_OFFSET 100 \
321 "<n>" "offset from FIRSTIP of public IP addresses"
323 defconf PUBLIC_ADDRESSES "|make_public_addresses" \
324 "<cmd>" "template for public address entry in nas.conf"
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"
336 defconf KVMHOST "10.0.0.1" \
337 "<ip>" "KVM host - provides things like NTP, iSCSI targets, ..."
339 defconf KDC_NAME "example-ad" \
340 "<name>" "prefix of the name of the KDC"
342 ######################################################################
348 # Uses: RHEL_VERSION, RHEL_ARCH
349 # Prints: a value for ISO
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" ;;
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" ;;
379 # yum repo infrastructure
380 _YUM_TEMPLATE="$installdir/templates/RHEL.repo" # Private - used below!
381 rhel_gen_yum_repos ()
383 echo "# Generated by autocluster."
386 # Repo IDs can not contain slashes, so replace slashes with dashes.
390 baseurl=@@INSTALL_SERVER@@/${repo}
406 if t=$(which qemu-kvm 2>/dev/null) ; then
408 elif t=$(which kvm 2>/dev/null) ; then
410 elif [ -x "/usr/libexec/qemu-kvm" ] ; then
411 echo "/usr/libexec/qemu-kvm"
413 die "Could not find KVM executable"
418 rhel_get_install_kernel_options ()
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" ;;
426 rhel_get_install_ks_device_xml ()
428 if [ ${RHEL_VERSION%%.*} -le 6 ] ; then
430 <disk type='file' device='floppy'>
431 <source file='@@PWD@@/tmp/floppy.img'/>
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'/>
447 rhel_get_multipath_magic ()
449 if [ ${RHEL_VERSION%%.*} -le 6 ] ; then
452 getuid_callout "$SHARED_DISK_MULTIPATH_CALLOUT"
457 rhel_post_config_hook ()
459 if [ "$ISO" = "@uto" ] ; then
460 ISO=$(rhel_print_iso) || exit $?
463 if [ "$SYSTEM_DISK_MOUNTS" = "@uto" ] ; then
464 SYSTEM_DISK_MOUNTS=$(system_disk_mounts) || exit $?
467 if [ "$MEM" = "@uto" ] ; then
468 MEM=$(rhel_default_mem) || exit $?
471 if [ "$SYSTEM_DISK_PREFIX" = "@uto" ] ; then
472 SYSTEM_DISK_PREFIX=$(rhel_disk_prefix $SYSTEM_DISK_TYPE) || exit $?
475 if [ "$KVM" = "@uto" ] ; then
476 KVM=$(get_kvm_path) || exit $?
479 if [ "$INSTALL_KERNEL_OPTIONS" = "@uto" ] ; then
480 INSTALL_KERNEL_OPTIONS=$(rhel_get_install_kernel_options) || exit $?
483 if [ "$INSTALL_KS_DEVICE_TEMPLATE" = "@uto" ] ; then
484 INSTALL_KS_DEVICE_TEMPLATE=$(rhel_get_install_ks_device_xml) || exit $?
487 if [ "$RHEL_MULTIPATH_MAGIC" = "@uto" ] ; then
488 RHEL_MULTIPATH_MAGIC=$(rhel_get_multipath_magic) || exit $?
492 register_hook post_config_hooks rhel_post_config_hook
494 defconf RHEL_ARCH "x86_64" \
495 "<arch>" "The RHEL operating system architecture to configure"
497 defconf RHEL_VERSION "6.2" \
498 "<version>" "version of Red Hat Enterprise Linux to configure"
500 defconf RHEL_MULTIPATH_MAGIC "@uto"
502 defconf ISO_DIR "/virtual/ISO" \
503 "<dir>" "directory for ISO images, prepended to $ISO if not absolute"
506 "<file>" "ISO image for base image creation"
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"
512 defconf CONFIG_EXTRA_PACKAGES "" \
513 "<packages>" "list of extra packages to install at configuration time"
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"
520 defconf INSTALL_KS_DEVICE_TEMPLATE "@uto"
522 ##############################
524 defconf CREATE_BASE_TIMEOUT 3600 \
525 "<seconds>" "time to wait for base image install before aborting"
527 ##############################
529 register_hook hack_nodes_functions hack_nodes_rhel_base
531 hack_nodes_rhel_base ()
533 local node_count_rhel_base=0
538 node_count_rhel_base=$(($node_count_rhel_base + 1))
539 name="${CLUSTER}base${node_count_rhel_base}"
543 hack_all_nodes_with hack_filter
546 create_node_rhel_base ()
552 echo "Creating RHEL base node $name"
553 create_node_COMMON "$name" "$ip_offset" "$type"
556 has_public_addresses_rhel_base ()
561 ##############################
563 # Authentication method
564 defconf AUTH_METHOD "files" \
565 "files|winbind" "authentication method"
567 ##############################