1 # Hey Emacs, this is a -*- shell-script -*- !!!
3 ######################################################################
7 defconf CLUSTERFS_TYPE "gpfs" \
8 "<gpfs|?>" "type of cluster filesystem to use"
10 defconf CLUSTERFS_DEFAULT_MOUNTPOINT "/clusterfs" \
11 "<directory>" "mountpoint for default cluster filesystem"
13 defconf NODES "nas:0-3 rhel_base:4" \
14 "<nodes>" "list of node types to create, with associated IP offsets"
17 "<n>" "number of nodes to build, not including TSM server"
19 # a directory on the host which will be mounted via NFS onto the nodes
20 # as $NFS_MOUNTPOINT, giving a nice common area independent of the
21 # cluster filesystem. This is useful for compiles, RPMs, devel
22 # scripts etc you need to add this to your /etc/exports and run
23 # exportfs -av yourself on the virtualisation host
24 defconf NFSSHARE "10.0.0.1:/home" \
25 "<mnt>" "NFS share to mount on each node"
27 defconf NFS_MOUNTPOINT "/home" \
28 "<dir>" "mount point for NFS share"
30 ######################################################################
32 # Directories and files
34 # these are the default autocluster config options
35 # please override with your own options in your own config file
37 defconf VIRTBASE /virtual \
38 "<path>" "virtual machine directory for this host"
40 # the name of the base RHEL install image that the nodes will be based on
41 # a kvm image called $VIRTBASE/$BASENAME.img will be created
42 # that will form the basis file for the images for each of the nodes
43 defconf BASENAME "ac-base" \
44 "<file>" "filename for cluster base image"
46 defconf BASE_PER_NODE_TYPE "no" \
47 "<yes|no>" "Use per-node-type base images"
49 defconf DISK_FOLLOW_SYMLINKS "no" \
50 "<yes|no>" "If disk images use symlinks then follow them to overwrite"
52 ######################################################################
56 defconf VIRSH "virsh -c qemu:///system" \
57 "<cmd>" "how to invoke virsh"
60 "<file>" "location of KVM executable"
62 defconf KVMLOG "/var/log/kvm" \
63 "<dir>" "directory for serial logs"
65 defconf NODE_TEMPLATE "$installdir/templates/node.xml" \
66 "<file>" "libvirt template for nodes"
68 defconf INSTALL_TEMPLATE "$installdir/templates/install.xml" \
69 "<file>" "libvirt template for initial install"
71 defconf INSTALL_KERNEL_OPTIONS "@uto" \
72 "<options>" "installer kernel command-line options"
74 defconf BOOT_TEMPLATE "$installdir/templates/bootbase.xml" \
75 "<file>" "libvirt template for \"bootbase\" command"
77 defconf BASE_TEMPLATES "$installdir/base" \
78 "<dir>" "directory containing base templates"
80 defconf BASE_FORMAT "qcow2" \
81 "<fmt>" "format to use for the qemu base images"
83 defconf SYSTEM_DISK_TYPE "ide" \
84 "scsi|ide|virtio" "type of disks to use in nodes"
89 (scsi|iscsi) echo "sd" ;;
92 case "$RHEL_VERSION" in
95 (*) die "Unknown RHEL_VERSION in rhel_disk_prefix" ;;
98 (*) die "Unknown disk type \"$1\" in rhel_disk_prefix" ;;
103 defconf SYSTEM_DISK_PREFIX "@uto" \
104 "sd|hd|vd" "system disk device prefix"
106 defconf SYSTEM_DISK_CACHE "writeback" \
107 "default|none|writeback|writethrough" "system disk cache type"
109 defconf SYSTEM_DISK_FORMAT "qcow2" \
110 "qcow2|raw|reflink|mmclone|none" "system disk image format"
112 defconf SYSTEM_DISK_ACCESS_METHOD "@uto" \
113 "loopback|guestfish|guestmount" "how to setup up disk images"
115 system_disk_access_method_hook ()
117 if [ "$SYSTEM_DISK_ACCESS_METHOD" = "@uto" ] ; then
118 if [ "$SYSTEM_DISK_FORMAT" = "qcow2" ] ; then
119 if which guestmount >/dev/null 2>&1 ; then
120 SYSTEM_DISK_ACCESS_METHOD="guestmount"
121 elif which guestfish >/dev/null 2>&1 ; then
122 SYSTEM_DISK_ACCESS_METHOD="guestfish"
123 elif which qemu-nbd nbd-client >/dev/null 2>&1 ; then
124 SYSTEM_DISK_ACCESS_METHOD="loopback"
126 die "Can't determine SYSTEM_DISK_ACCESS_METHOD. Need guestfish or qemu-nbd + nbd-client."
129 SYSTEM_DISK_ACCESS_METHOD="loopback"
134 register_hook post_config_hooks system_disk_access_method_hook
136 system_disk_mounts ()
138 # We could call a function using call_func(). However, we want
139 # the options listed in the documentation for
140 # SYSTEM_DISK_ACCESS_METHOD, so they need to be hardcoded... so
141 # we might as well hardcode this function (for now).
142 case "$SYSTEM_DISK_ACCESS_METHOD" in
144 case "$RHEL_VERSION" in
145 (5.*) echo "/:32256" ;;
146 ([67].*) echo "/:1048576" ;;
147 (*) die "Unknown RHEL_VERSION in system_disk_mounts" ;;
150 (guestfish|guestmount) : ;;
151 (*) die "Unknown SYSTEM_DISK_ACCESS_METHOD in system_disk_mounts" ;;
155 defconf SYSTEM_DISK_MOUNTS "@uto" \
156 "<list>" "list of mountpoints and offsets/devices for mount_disk()"
158 ######################################################################
162 # what timezone to put the nodes in
163 # leave this empty to base the timezone on the zone that
165 defconf TIMEZONE "" \
166 "<tz>" "timezone for each node"
168 # how much disk space to use on each node
169 # note that it will only use what is actually occupied,
170 # so start this larger than you think you'll need
171 defconf DISKSIZE "20G" \
172 "<n>G" "maximum disk size for each node"
174 defconf ROOTSIZE 15000 \
175 "<n>" "size of root partition in MB"
177 defconf SWAPSIZE 2000 \
178 "<n>" "size of swap partition in MB"
182 case "$RHEL_VERSION" in
183 (5.*) echo "262144" ;;
184 ([67].*) echo "512000" ;;
185 (*) die "Unknown RHEL_VERSION in rhel_default_mem" ;;
190 "<n>" "memory allocated for each node"
192 defconf NICMODEL "e1000" \
193 "<module>" "choice of KVM network adapter"
195 defconf ROOTPASSWORD "password" \
196 "<string>" "initial root password for each node"
199 "<n>" "number of virtual CPUs per node"
201 # Some machines need "clocksource=jiffies"
202 defconf EXTRA_KERNEL_OPTIONS "" \
203 "<string>" "extra kernel options for nodes"
205 defconf HOSTNAME_HACKING_FUNCTION "" \
206 "<string>" "function to modify node hostnames, see the code for details"
208 defconf HOSTS_STATIC_ENTRIES "/dev/null" \
209 "<file>" "a file containing extra static entries to add to /etc/hosts"
211 ######################################################################
215 defconf DOMAIN "EXAMPLE.COM" \
216 "<dom>" "Windows(TM) domain name for each node"
218 defconf WORKGROUP "EXAMPLE" \
219 "<grp>" "Windows(TM) workgroup for node"
221 # DNS name server. Usually set this to the
222 # kvm host, then setup DNS on the kvm host to direct
223 # queries for the windows domain name to the w2003 server
224 defconf NAMESERVER "10.0.0.1" \
225 "<ip>" "DNS server for each node"
227 defconf DNSSEARCH "$DOMAIN" \
228 "<dom>" "extra domains for DNS search list"
231 # * First network is private and contains the CTDB node addresses.
232 # * Items look like: net/bits,dev[,nat|bridge=host_iface][,gw=gateway_ip]
234 # * Right now autocluster only supports 24 bit networks. This will
235 # be improved in the future.
236 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" \
237 "<list>" "description of IP networks"
239 make_public_addresses()
241 local firstip="${1:-$[${FIRSTIP} + ${PUBLIC_IP_OFFSET}]}"
242 local num_addrs="${2:-${NUMNODES}}"
244 if [ $(( $firstip + $num_addrs - 1 )) -gt 254 ]; then
245 die "make_public_addresses: last octet > 254 - change PUBLIC_IP_OFFSET"
249 for n in $NETWORKS_PUBLIC ; do
250 local dev="${n#*,}" # Strip address, comma
251 dev="${dev%,*}" # Strip comma, interface
252 echo -ne "${n%.*}.${firstip},${num_addrs},${dev} "
257 networks_post_config_hook ()
260 for n in $NETWORKS ; do
261 local ip_mask="${n%%,*}"
262 local mask="${ip_mask#*/}"
264 [ "$mask" = "24" ] || \
265 die "Network maskbits other than 24 unsupported in \"$n\""
268 [ -z "$IPBASE" -a -z "$IPNET0" -a -z "$IPNET1" -a -z "$IPNET2" ] || \
269 die "Configuration variables IPBASE, IPNET0/1/2 unsupported - please use NETWORKS"
271 # Convenience variables
273 NETWORK_PRIVATE="$1" ; shift
274 local t="${NETWORK_PRIVATE%%,*}"
275 NETWORK_PRIVATE_PREFIX="${t%.*}"
279 register_hook post_config_hooks networks_post_config_hook
281 defconf NETWORK_TEMPLATE "|network_template" \
282 "<file>" "libvirt template fragment for networks"
286 local netname dev ip mask mac opts
287 while read netname dev ip mask mac opts ; do
289 <interface type='network'>
290 <mac address='${mac}'/>
291 <model type='@@NICMODEL@@'/>
292 <source network='${netname}'/>
299 # the nodes will get IPs starting at this number
300 # the TSM server will get $FIRSTIP, then the first node will get
302 # so if the private network is 10.0.0.0/24,eth0 and FIRSTIP is 20 then
303 # you will get nodes like this:
304 # tsmserver 10.0.0.20
308 defconf FIRSTIP "20" \
309 "<n>" "final octet for the 1st IP of the cluster"
311 # Public addresses managed by CTDB.
312 defconf PUBLIC_IP_OFFSET 100 \
313 "<n>" "offset from FIRSTIP of public IP addresses"
315 defconf PUBLIC_ADDRESSES "|make_public_addresses" \
316 "<cmd>" "template for public address entry in nas.conf"
318 # a caching web proxy that can get to the install server from the
319 # nodes. If you don't have one on the local network then look in
320 # host_setup/etc/squid for an example setup you can install on the kvm
321 # host. The web proxy must cache large objects, and have room for
322 # several G of cache You can choose to have no web proxy at all, in
323 # which case set it to the empty string, and hope you have a fast
324 # network connection to the install server
325 defconf WEBPROXY "" \
326 "<url>" "URL of a caching web proxy"
328 defconf KVMHOST "10.0.0.1" \
329 "<ip>" "KVM host - provides things like NTP, iSCSI targets, ..."
331 defconf KDC_NAME "example-ad" \
332 "<name>" "prefix of the name of the KDC"
334 ######################################################################
340 # Uses: RHEL_VERSION, RHEL_ARCH
341 # Prints: a value for ISO
345 case "$RHEL_VERSION" in
346 (5.1) datever="20071017.0";;
347 (5.2) datever="20080430.0";;
348 (5.3) datever="20090106.0";;
349 (5.4) datever="20090819.0";;
350 (5.5) datever="20100322.0";;
351 (5.6) datever="20110106.0";;
352 (5.7) datever="20110711.5";;
353 (5.8) datever="20120202.0";;
354 (6.0) datever="20100922.1";;
355 (6.1) datever="20110510.1";;
356 (6.2) datever="20111117.0";;
357 (6.3) datever="20120613.2";;
358 (6.4) datever="20130130.0";;
359 (6.5) datever="20131111.0";;
360 (7.0) datever="20140507.0";;
361 (*) die "Unknown RHEL_VERSION in rhel_print_iso" ;;
364 case "$RHEL_VERSION" in
365 (5.*) echo "RHEL${RHEL_VERSION}-Server-${datever}-${RHEL_ARCH}-DVD.iso" ;;
366 (6.*) echo "RHEL${RHEL_VERSION}-${datever}-Server-${RHEL_ARCH}-DVD1.iso" ;;
367 (7.*) echo "RHEL-${RHEL_VERSION}-${datever}-Server-${RHEL_ARCH}-dvd1.iso" ;;
371 # yum repo infrastructure
372 _YUM_TEMPLATE="$installdir/templates/RHEL.repo" # Private - used below!
373 rhel_gen_yum_repos ()
375 echo "# Generated by autocluster."
378 # Repo IDs can not contain slashes, so replace slashes with dashes.
382 baseurl=@@INSTALL_SERVER@@/${repo}
398 if t=$(which qemu-kvm 2>/dev/null) ; then
400 elif t=$(which kvm 2>/dev/null) ; then
402 elif [ -x "/usr/libexec/qemu-kvm" ] ; then
403 echo "/usr/libexec/qemu-kvm"
405 die "Could not find KVM executable"
410 rhel_get_install_kernel_options ()
412 case "$RHEL_VERSION" in
413 (7.*) echo "ks=hd:LABEL=KICKSTART inst.stage2=hd:LABEL=RHEL-${RHEL_VERSION}\\\\x20Server.${RHEL_ARCH}" ;;
414 (*) echo "ks=floppy" ;;
418 rhel_get_install_ks_device_xml ()
420 if [ ${RHEL_VERSION%%.*} -le 6 ] ; then
422 <disk type='file' device='floppy'>
423 <source file='@@PWD@@/tmp/floppy.img'/>
430 <disk type='file' device='disk'>
431 <source file='@@PWD@@/tmp/floppy.img'/>
432 <target dev='@@SYSTEM_DISK_PREFIX@@b' bus='@@SYSTEM_DISK_TYPE@@'/>
433 <driver name='qemu' type='raw'/>
439 rhel_get_multipath_magic ()
441 if [ ${RHEL_VERSION%%.*} -le 6 ] ; then
444 getuid_callout "$SHARED_DISK_MULTIPATH_CALLOUT"
449 rhel_post_config_hook ()
451 if [ "$ISO" = "@uto" ] ; then
452 ISO=$(rhel_print_iso) || exit $?
455 if [ "$SYSTEM_DISK_MOUNTS" = "@uto" ] ; then
456 SYSTEM_DISK_MOUNTS=$(system_disk_mounts) || exit $?
459 if [ "$MEM" = "@uto" ] ; then
460 MEM=$(rhel_default_mem) || exit $?
463 if [ "$SYSTEM_DISK_PREFIX" = "@uto" ] ; then
464 SYSTEM_DISK_PREFIX=$(rhel_disk_prefix $SYSTEM_DISK_TYPE) || exit $?
467 if [ "$KVM" = "@uto" ] ; then
468 KVM=$(get_kvm_path) || exit $?
471 if [ "$INSTALL_KERNEL_OPTIONS" = "@uto" ] ; then
472 INSTALL_KERNEL_OPTIONS=$(rhel_get_install_kernel_options) || exit $?
475 if [ "$INSTALL_KS_DEVICE_TEMPLATE" = "@uto" ] ; then
476 INSTALL_KS_DEVICE_TEMPLATE=$(rhel_get_install_ks_device_xml) || exit $?
479 if [ "$RHEL_MULTIPATH_MAGIC" = "@uto" ] ; then
480 RHEL_MULTIPATH_MAGIC=$(rhel_get_multipath_magic) || exit $?
484 register_hook post_config_hooks rhel_post_config_hook
486 defconf RHEL_ARCH "x86_64" \
487 "<arch>" "The RHEL operating system architecture to configure"
489 defconf RHEL_VERSION "6.2" \
490 "<version>" "version of Red Hat Enterprise Linux to configure"
492 defconf RHEL_MULTIPATH_MAGIC "@uto"
494 defconf ISO_DIR "/virtual/ISO" \
495 "<dir>" "directory for ISO images, prepended to $ISO if not absolute"
498 "<file>" "ISO image for base image creation"
500 # the install server where we will get local packages from
501 defconf INSTALL_SERVER "http://10.0.0.1/mediasets" \
502 "<url>" "URL of install server"
504 defconf CONFIG_EXTRA_PACKAGES "" \
505 "<packages>" "list of extra packages to install at configuration time"
507 # the yum repositories to use. Choose the one appropriate for the
508 # system you are installing
509 defconf YUM_TEMPLATE "$_YUM_TEMPLATE" \
510 "<file>" "location of template for yum repositories"
512 defconf INSTALL_KS_DEVICE_TEMPLATE "@uto"
514 ##############################
516 defconf CREATE_BASE_TIMEOUT 3600 \
517 "<seconds>" "time to wait for base image install before aborting"
519 ##############################
521 register_hook hack_nodes_functions hack_nodes_rhel_base
523 hack_nodes_rhel_base ()
525 local node_count_rhel_base=0
530 node_count_rhel_base=$(($node_count_rhel_base + 1))
531 name="${CLUSTER}base${node_count_rhel_base}"
532 # rhel_base nodes are not part of CTDB cluster
536 hack_all_nodes_with hack_filter
539 create_node_rhel_base ()
545 echo "Creating RHEL base node $name"
546 create_node_COMMON "$name" "$ip_offset" "$type"
549 ##############################
551 # Authentication method
552 defconf AUTH_METHOD "files" \
553 "files|winbind" "authentication method"
555 ##############################