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"
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"
24 defconf NFS_MOUNTPOINT "/home" \
25 "<dir>" "mount point for NFS share"
27 ######################################################################
29 # Directories and files
31 # these are the default autocluster config options
32 # please override with your own options in your own config file
34 defconf VIRTBASE /virtual \
35 "<path>" "virtual machine directory for this host"
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"
43 defconf BASE_PER_NODE_TYPE "no" \
44 "<yes|no>" "Use per-node-type base images"
46 defconf DISK_FOLLOW_SYMLINKS "no" \
47 "<yes|no>" "If disk images use symlinks then follow them to overwrite"
49 ######################################################################
53 defconf VIRSH "virsh -c qemu:///system" \
54 "<cmd>" "how to invoke virsh"
57 "<file>" "location of KVM executable"
59 defconf KVMLOG "/var/log/kvm" \
60 "<dir>" "directory for serial logs"
62 defconf NODE_TEMPLATE "$installdir/templates/node.xml" \
63 "<file>" "libvirt template for nodes"
65 defconf INSTALL_TEMPLATE "$installdir/templates/install.xml" \
66 "<file>" "libvirt template for initial install"
68 defconf INSTALL_KERNEL_OPTIONS "@uto" \
69 "<options>" "installer kernel command-line options"
71 defconf BOOT_TEMPLATE "$installdir/templates/bootbase.xml" \
72 "<file>" "libvirt template for \"bootbase\" command"
74 defconf BASE_TEMPLATES "$installdir/base" \
75 "<dir>" "directory containing base templates"
77 defconf BASE_FORMAT "qcow2" \
78 "<fmt>" "format to use for the qemu base images"
80 defconf SYSTEM_DISK_TYPE "ide" \
81 "scsi|ide|virtio" "type of disks to use in nodes"
86 (scsi|iscsi) echo "sd" ;;
89 case "$RHEL_VERSION" in
92 (*) die "Unknown RHEL_VERSION in rhel_disk_prefix" ;;
95 (*) die "Unknown disk type \"$1\" in rhel_disk_prefix" ;;
100 defconf SYSTEM_DISK_PREFIX "@uto" \
101 "sd|hd|vd" "system disk device prefix"
103 defconf SYSTEM_DISK_CACHE "writeback" \
104 "default|none|writeback|writethrough" "system disk cache type"
106 defconf SYSTEM_DISK_FORMAT "qcow2" \
107 "qcow2|raw|reflink|mmclone|none" "system disk image format"
109 defconf SYSTEM_DISK_ACCESS_METHOD "@uto" \
110 "loopback|guestfish|guestmount" "how to setup up disk images"
112 system_disk_access_method_hook ()
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"
123 die "Can't determine SYSTEM_DISK_ACCESS_METHOD. Need guestfish or qemu-nbd + nbd-client."
126 SYSTEM_DISK_ACCESS_METHOD="loopback"
131 register_hook post_config_hooks system_disk_access_method_hook
133 system_disk_mounts ()
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
141 case "$RHEL_VERSION" in
142 (5.*) echo "/:32256" ;;
143 ([67].*) echo "/:1048576" ;;
144 (*) die "Unknown RHEL_VERSION in system_disk_mounts" ;;
147 (guestfish|guestmount) : ;;
148 (*) die "Unknown SYSTEM_DISK_ACCESS_METHOD in system_disk_mounts" ;;
152 defconf SYSTEM_DISK_MOUNTS "@uto" \
153 "<list>" "list of mountpoints and offsets/devices for mount_disk()"
155 ######################################################################
159 # what timezone to put the nodes in
160 # leave this empty to base the timezone on the zone that
162 defconf TIMEZONE "" \
163 "<tz>" "timezone for each node"
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"
171 defconf ROOTSIZE 15000 \
172 "<n>" "size of root partition in MB"
174 defconf SWAPSIZE 2000 \
175 "<n>" "size of swap partition in MB"
179 case "$RHEL_VERSION" in
180 (5.*) echo "262144" ;;
181 ([67].*) echo "512000" ;;
182 (*) die "Unknown RHEL_VERSION in rhel_default_mem" ;;
187 "<n>" "memory allocated for each node"
189 defconf NICMODEL "e1000" \
190 "<module>" "choice of KVM network adapter"
192 defconf ROOTPASSWORD "password" \
193 "<string>" "initial root password for each node"
196 "<n>" "number of virtual CPUs per node"
198 # Some machines need "clocksource=jiffies"
199 defconf EXTRA_KERNEL_OPTIONS "" \
200 "<string>" "extra kernel options for nodes"
202 defconf HOSTNAME_HACKING_FUNCTION "" \
203 "<string>" "function to modify node hostnames, see the code for details"
205 defconf HOSTS_STATIC_ENTRIES "/dev/null" \
206 "<file>" "a file containing extra static entries to add to /etc/hosts"
208 ######################################################################
212 defconf DOMAIN "EXAMPLE.COM" \
213 "<dom>" "Windows(TM) domain name for each node"
215 defconf WORKGROUP "EXAMPLE" \
216 "<grp>" "Windows(TM) workgroup for node"
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"
224 defconf DNSSEARCH "$DOMAIN" \
225 "<dom>" "extra domains for DNS search list"
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]
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"
236 make_public_addresses()
238 local firstip="${1:-$[${FIRSTIP} + ${PUBLIC_IP_OFFSET}]}"
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
247 if [ "$4" = "1" ] ; then
248 num_addrs=$(($num_addrs + 1))
251 for_each_node _count_ctdb_nodes
254 if [ $(( $firstip + $num_addrs - 1 )) -gt 254 ]; then
255 die "make_public_addresses: last octet > 254 - change PUBLIC_IP_OFFSET"
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} "
267 networks_post_config_hook ()
270 for n in $NETWORKS ; do
271 local ip_mask="${n%%,*}"
272 local mask="${ip_mask#*/}"
274 [ "$mask" = "24" ] || \
275 die "Network maskbits other than 24 unsupported in \"$n\""
278 [ -z "$IPBASE" -a -z "$IPNET0" -a -z "$IPNET1" -a -z "$IPNET2" ] || \
279 die "Configuration variables IPBASE, IPNET0/1/2 unsupported - please use NETWORKS"
281 # Convenience variables
283 NETWORK_PRIVATE="$1" ; shift
284 local t="${NETWORK_PRIVATE%%,*}"
285 NETWORK_PRIVATE_PREFIX="${t%.*}"
289 register_hook post_config_hooks networks_post_config_hook
291 defconf NETWORK_TEMPLATE "|network_template" \
292 "<file>" "libvirt template fragment for networks"
296 local netname dev ip mask mac opts
297 while read netname dev ip mask mac opts ; do
299 <interface type='network'>
300 <mac address='${mac}'/>
301 <model type='@@NICMODEL@@'/>
302 <source network='${netname}'/>
309 # the nodes will get IPs starting at this number
310 # the TSM server will get $FIRSTIP, then the first node will get
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
318 defconf FIRSTIP "20" \
319 "<n>" "final octet for the 1st IP of the cluster"
321 # Public addresses managed by CTDB.
322 defconf PUBLIC_IP_OFFSET 100 \
323 "<n>" "offset from FIRSTIP of public IP addresses"
325 defconf PUBLIC_ADDRESSES "|make_public_addresses" \
326 "<cmd>" "template for public address entry in nas.conf"
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"
338 defconf KVMHOST "10.0.0.1" \
339 "<ip>" "KVM host - provides things like NTP, iSCSI targets, ..."
341 defconf KDC_NAME "example-ad" \
342 "<name>" "prefix of the name of the KDC"
344 ######################################################################
350 # Uses: RHEL_VERSION, RHEL_ARCH
351 # Prints: a value for ISO
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" ;;
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" ;;
381 # yum repo infrastructure
382 _YUM_TEMPLATE="$installdir/templates/RHEL.repo" # Private - used below!
383 rhel_gen_yum_repos ()
385 echo "# Generated by autocluster."
388 # Repo IDs can not contain slashes, so replace slashes with dashes.
392 baseurl=@@INSTALL_SERVER@@/${repo}
408 if t=$(which qemu-kvm 2>/dev/null) ; then
410 elif t=$(which kvm 2>/dev/null) ; then
412 elif [ -x "/usr/libexec/qemu-kvm" ] ; then
413 echo "/usr/libexec/qemu-kvm"
415 die "Could not find KVM executable"
420 rhel_get_install_kernel_options ()
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" ;;
428 rhel_get_install_ks_device_xml ()
430 if [ ${RHEL_VERSION%%.*} -le 6 ] ; then
432 <disk type='file' device='floppy'>
433 <source file='@@PWD@@/tmp/floppy.img'/>
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'/>
449 rhel_get_multipath_magic ()
451 if [ ${RHEL_VERSION%%.*} -le 6 ] ; then
454 getuid_callout "$SHARED_DISK_MULTIPATH_CALLOUT"
459 rhel_post_config_hook ()
461 if [ "$ISO" = "@uto" ] ; then
462 ISO=$(rhel_print_iso) || exit $?
465 if [ "$SYSTEM_DISK_MOUNTS" = "@uto" ] ; then
466 SYSTEM_DISK_MOUNTS=$(system_disk_mounts) || exit $?
469 if [ "$MEM" = "@uto" ] ; then
470 MEM=$(rhel_default_mem) || exit $?
473 if [ "$SYSTEM_DISK_PREFIX" = "@uto" ] ; then
474 SYSTEM_DISK_PREFIX=$(rhel_disk_prefix $SYSTEM_DISK_TYPE) || exit $?
477 if [ "$KVM" = "@uto" ] ; then
478 KVM=$(get_kvm_path) || exit $?
481 if [ "$INSTALL_KERNEL_OPTIONS" = "@uto" ] ; then
482 INSTALL_KERNEL_OPTIONS=$(rhel_get_install_kernel_options) || exit $?
485 if [ "$INSTALL_KS_DEVICE_TEMPLATE" = "@uto" ] ; then
486 INSTALL_KS_DEVICE_TEMPLATE=$(rhel_get_install_ks_device_xml) || exit $?
489 if [ "$RHEL_MULTIPATH_MAGIC" = "@uto" ] ; then
490 RHEL_MULTIPATH_MAGIC=$(rhel_get_multipath_magic) || exit $?
494 register_hook post_config_hooks rhel_post_config_hook
496 defconf RHEL_ARCH "x86_64" \
497 "<arch>" "The RHEL operating system architecture to configure"
499 defconf RHEL_VERSION "6.2" \
500 "<version>" "version of Red Hat Enterprise Linux to configure"
502 defconf RHEL_MULTIPATH_MAGIC "@uto"
504 defconf ISO_DIR "/virtual/ISO" \
505 "<dir>" "directory for ISO images, prepended to $ISO if not absolute"
508 "<file>" "ISO image for base image creation"
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"
514 defconf CONFIG_EXTRA_PACKAGES "" \
515 "<packages>" "list of extra packages to install at configuration time"
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"
522 defconf INSTALL_KS_DEVICE_TEMPLATE "@uto"
524 ##############################
526 defconf CREATE_BASE_TIMEOUT 3600 \
527 "<seconds>" "time to wait for base image install before aborting"
529 ##############################
531 register_hook hack_nodes_functions hack_nodes_rhel_base
533 hack_nodes_rhel_base ()
535 local node_count_rhel_base=0
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
546 hack_all_nodes_with hack_filter
549 create_node_rhel_base ()
555 echo "Creating RHEL base node $name"
556 create_node_COMMON "$name" "$ip_offset" "$type"
559 ##############################
561 # Authentication method
562 defconf AUTH_METHOD "files" \
563 "files|winbind" "authentication method"
565 ##############################