summaryrefslogtreecommitdiffstats
path: root/config.d/00base.defconf
blob: cfbc06ea51ee53957779feb213bd346ee06607c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
# Hey Emacs, this is a -*- shell-script -*- !!!

######################################################################

# Cluster

defconf CLUSTERFS_TYPE "gpfs" \
	"<gpfs|?>" "type of cluster filesystem to use"

defconf CLUSTERFS_DEFAULT_MOUNTPOINT "/clusterfs" \
	"<directory>" "mountpoint for default cluster filesystem"

defconf NODES "nas:0-3 rhel_base:4" \
	"<nodes>" "list of node types to create, with associated IP offsets"

# a directory on the host which will be mounted via NFS onto the nodes
# as $NFS_MOUNTPOINT, giving a nice common area independent of the
# cluster filesystem.  This is useful for compiles, RPMs, devel
# scripts etc you need to add this to your /etc/exports and run
# exportfs -av yourself on the virtualisation host
defconf NFSSHARE "@uto" \
	"<mnt>" "NFS share to mount on each node"

defconf NFS_MOUNTPOINT "/home" \
	"<dir>" "mount point for NFS share"

######################################################################

# Directories and files

# these are the default autocluster config options
# please override with your own options in your own config file

defconf VIRTBASE /virtual \
	"<path>" "virtual machine directory for this host"

# the name of the base RHEL install image that the nodes will be based on
# a kvm image called $VIRTBASE/$BASENAME.img will be created
# that will form the basis file for the images for each of the nodes
defconf BASENAME "ac-base" \
	"<file>" "filename for cluster base image"

defconf BASE_PER_NODE_TYPE "no" \
	"<yes|no>" "Use per-node-type base images"

defconf DISK_FOLLOW_SYMLINKS "no" \
	"<yes|no>" "If disk images use symlinks then follow them to overwrite"

######################################################################

# Virtualisation

defconf VIRSH "virsh -c qemu:///system" \
	"<cmd>" "how to invoke virsh"

defconf KVM "@uto" \
	"<file>"  "location of KVM executable"

defconf KVMLOG "/var/log/kvm" \
	"<dir>" "directory for serial logs"

defconf NODE_TEMPLATE "$installdir/templates/node.xml" \
	"<file>" "libvirt template for nodes"

defconf INSTALL_TEMPLATE "$installdir/templates/install.xml" \
	"<file>" "libvirt template for initial install"

defconf INSTALL_KERNEL_OPTIONS "@uto" \
	"<options>" "installer kernel command-line options"

defconf BOOT_TEMPLATE "$installdir/templates/bootbase.xml" \
	"<file>" "libvirt template for \"bootbase\" command"

defconf BASE_TEMPLATES "$installdir/base" \
	"<dir>" "directory containing base templates"

defconf BASE_FORMAT "qcow2" \
	"<fmt>" "format to use for the qemu base images"

defconf SYSTEM_DISK_TYPE "virtio" \
	"scsi|ide|virtio" "type of disks to use in nodes"

rhel_disk_prefix ()
{
    case "$1" in
	(scsi|iscsi) echo "sd" ;;
	(virtio)     echo "vd" ;;
	ide)
	    case "$RHEL_VERSION" in
		(5.*) echo "hd" ;;
		([67].*) echo "sd" ;;
		(*) die "Unknown RHEL_VERSION in rhel_disk_prefix" ;;
	    esac
	    ;;
	(*) die "Unknown disk type \"$1\" in rhel_disk_prefix" ;;
	    
    esac
}

defconf SYSTEM_DISK_PREFIX "@uto" \
	"sd|hd|vd" "system disk device prefix"

defconf SYSTEM_DISK_CACHE "writeback" \
	"default|none|writeback|writethrough" "system disk cache type"

defconf SYSTEM_DISK_FORMAT "qcow2" \
	"qcow2|raw|reflink|mmclone|none" "system disk image format"

defconf SYSTEM_DISK_ACCESS_METHOD "@uto" \
	"loopback|guestfish|guestmount" "how to setup up disk images"

system_disk_access_method_hook ()
{
    if [ "$SYSTEM_DISK_ACCESS_METHOD" = "@uto" ] ; then
	if [ "$SYSTEM_DISK_FORMAT" = "qcow2" ] ; then
	    if which guestmount >/dev/null 2>&1 ; then
		SYSTEM_DISK_ACCESS_METHOD="guestmount"
	    elif which guestfish >/dev/null 2>&1 ; then
		SYSTEM_DISK_ACCESS_METHOD="guestfish"
	    elif which qemu-nbd nbd-client >/dev/null 2>&1 ; then
		SYSTEM_DISK_ACCESS_METHOD="loopback"
	    else
		die "Can't determine SYSTEM_DISK_ACCESS_METHOD.  Need guestfish or qemu-nbd + nbd-client."
	    fi
	else
	    SYSTEM_DISK_ACCESS_METHOD="loopback"
	fi
    fi
}

register_hook post_config_hooks system_disk_access_method_hook

system_disk_mounts ()
{
    # We could call a function using call_func().  However, we want
    # the options listed in the documentation for
    # SYSTEM_DISK_ACCESS_METHOD, so they need to be hardcoded...  so
    # we might as well hardcode this function (for now).
    case "$SYSTEM_DISK_ACCESS_METHOD" in
	loopback)
	    case "$RHEL_VERSION" in
		(5.*) echo "/:32256" ;;
		([67].*) echo "/:1048576" ;;
		(*) die "Unknown RHEL_VERSION in system_disk_mounts" ;;
	    esac
	    ;;
	(guestfish|guestmount) : ;;
	(*) die "Unknown SYSTEM_DISK_ACCESS_METHOD in system_disk_mounts" ;;
    esac
}

defconf SYSTEM_DISK_MOUNTS "@uto" \
	"<list>" "list of mountpoints and offsets/devices for mount_disk()"

######################################################################

# Node

# what timezone to put the nodes in
# leave this empty to base the timezone on the zone that
# this host is in
defconf TIMEZONE "" \
	"<tz>" "timezone for each node"

# how much disk space to use on each node
# note that it will only use what is actually occupied,
# so start this larger than you think you'll need
defconf DISKSIZE "20G" \
	"<n>G" "maximum disk size for each node"

defconf ROOTSIZE 15000 \
	"<n>" "size of root partition in MB"

defconf SWAPSIZE 2000 \
	"<n>" "size of swap partition in MB"

rhel_default_mem ()
{
    case "$RHEL_VERSION" in
	(5.*) echo "262144" ;;
	([67].*) echo "512000" ;;
	(*) die "Unknown RHEL_VERSION in rhel_default_mem" ;;
    esac
}

defconf MEM "@uto" \
	"<n>" "memory allocated for each node"

defconf NICMODEL "e1000" \
	"<module>" "choice of KVM network adapter"

defconf ROOTPASSWORD "password" \
	"<string>" "initial root password for each node"

defconf NUMCPUS 2 \
	"<n>" "number of virtual CPUs per node"

# Some machines need "clocksource=jiffies"
defconf	EXTRA_KERNEL_OPTIONS "" \
	"<string>" "extra kernel options for nodes"

defconf HOSTNAME_HACKING_FUNCTION "" \
	"<string>" "function to modify node hostnames, see the code for details"

defconf HOSTS_STATIC_ENTRIES "/dev/null" \
	"<file>" "a file containing extra static entries to add to /etc/hosts"

######################################################################

# Networking

defconf DOMAIN "EXAMPLE.COM" \
	"<dom>" "Windows(TM) domain name for each node"

defconf WORKGROUP "EXAMPLE" \
	"<grp>" "Windows(TM) workgroup for node"

defconf NAMESERVER "@uto" \
	"<ip>" "DNS server for each node"

defconf DNSSEARCH "$DOMAIN" \
	"<dom>" "extra domains for DNS search list"

# Networks:
# * First network is private and contains the CTDB node addresses.
# * Items look like: net/bits,dev[,nat|bridge=host_iface][,gw=gateway_ip]

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" \
	"<list>" "description of IP networks"

defconf NETWORK_STACK "ipv4" \
	"ipv4|dual|ipv6" "Configure IPv4/IPv6 stacks"

make_public_addresses()
{
	local firstip="${1:-$[${FIRSTIP} + ${PUBLIC_IP_OFFSET}]}"
	local num_addrs="$2"

	# By default the number of addresses on each public network is
	# the same as the number of nodes
	if [ -z "$num_addrs" ] ; then
	    num_addrs=0
	    _count_ctdb_nodes ()
	    {
		if [ "$4" = "1" ] ; then
		    num_addrs=$(($num_addrs + 1))
		fi
	    }
	    for_each_node _count_ctdb_nodes
	fi

	if [ $(( $firstip + $num_addrs - 1 )) -gt 254 ]; then
	    die "make_public_addresses: last octet > 254 - change PUBLIC_IP_OFFSET"
	fi

	local n
	for n in $NETWORKS_PUBLIC ; do
	    local dev="${n#*,}" # Strip address, comma
	    dev="${dev%,*}" # Strip comma, interface
	    echo -ne "${n%.*}.${firstip},${num_addrs},${dev} "
	done
	echo
}

networks_post_config_hook ()
{
    [ -z "$IPBASE" -a -z "$IPNET0" -a -z "$IPNET1" -a -z "$IPNET2" ] || \
	die "Configuration variables IPBASE, IPNET0/1/2 unsupported - please use NETWORKS"

    # Convenience variables
    set -- $NETWORKS
    NETWORK_PRIVATE="$1" ; shift
    local t="${NETWORK_PRIVATE%%,*}"
    NETWORK_PRIVATE_PREFIX="${t%.*}"
    NETWORKS_PUBLIC="$*"
}

register_hook post_config_hooks networks_post_config_hook

defconf NETWORK_TEMPLATE "|network_template" \
	"<file>" "libvirt template fragment for networks"

network_template ()
{
    local netname dev ip ipv6 mac opts
    while read netname dev ip ipv6 mac opts ; do
	cat <<EOF
    <interface type='network'>
      <mac address='${mac}'/>
      <model type='@@NICMODEL@@'/>
      <source network='${netname}'/>
    </interface>
EOF
    done <"$network_map"
}


# the nodes will get IPs starting at this number 
# the TSM server will get $FIRSTIP, then the first node will get
# the next IP etc
# so if the private network is 10.0.0.0/24,eth0 and FIRSTIP is 20 then
# you will get nodes like this:
#     tsmserver   10.0.0.20
#     1st node    10.0.0.21
#     2nd node    10.0.0.22
# etc etc
defconf FIRSTIP "20" \
	"<n>" "final octet for the 1st IP of the cluster"

# Public addresses managed by CTDB.
defconf PUBLIC_IP_OFFSET 100 \
	"<n>" "offset from FIRSTIP of public IP addresses"

defconf PUBLIC_ADDRESSES "|make_public_addresses" \
	"<cmd>" "template for public address entry in nas.conf"

# a caching web proxy that can get to the install server from the
# nodes. If you don't have one on the local network then look in
# host_setup/etc/squid for an example setup you can install on the kvm
# host. The web proxy must cache large objects, and have room for
# several G of cache You can choose to have no web proxy at all, in
# which case set it to the empty string, and hope you have a fast
# network connection to the install server
defconf WEBPROXY "" \
	"<url>" "URL of a caching web proxy"

defconf KVMHOST "10.0.0.1" \
	"<ip>" "KVM host - provides things like NTP, iSCSI targets, ..."

defconf KDC_NAME "example-ad" \
	"<name>" "prefix of the name of the KDC"

######################################################################

# RHEL

rhel_print_iso ()
{
    # Uses: RHEL_VERSION, RHEL_ARCH
    # Prints: a value for ISO

    local datever

    case "$RHEL_VERSION" in
	(5.1) datever="20071017.0";;
	(5.2) datever="20080430.0";;
	(5.3) datever="20090106.0";;
	(5.4) datever="20090819.0";;
	(5.5) datever="20100322.0";;
	(5.6) datever="20110106.0";;
	(5.7) datever="20110711.5";;
	(5.8) datever="20120202.0";;
	(6.0) datever="20100922.1";;
	(6.1) datever="20110510.1";;
	(6.2) datever="20111117.0";;
	(6.3) datever="20120613.2";;
	(6.4) datever="20130130.0";;
	(6.5) datever="20131111.0";;
	(6.6) datever="20140926.0";;
	(6.7) datever="20150702.0";;
	(7.0) datever="20140507.0";;
	(7.1) datever="20150219.1";;
	(*) die "Unknown RHEL_VERSION in rhel_print_iso" ;;
    esac

    case "$RHEL_VERSION" in
	(5.*) echo "RHEL${RHEL_VERSION}-Server-${datever}-${RHEL_ARCH}-DVD.iso"  ;;
	(6.[0-5]) echo "RHEL${RHEL_VERSION}-${datever}-Server-${RHEL_ARCH}-DVD1.iso" ;;
	([67].*) echo "RHEL-${RHEL_VERSION}-${datever}-Server-${RHEL_ARCH}-dvd1.iso" ;;
    esac
}

# yum repo infrastructure
_YUM_TEMPLATE="$installdir/templates/RHEL.repo" # Private - used below!
rhel_gen_yum_repos ()
{
    echo "# Generated by autocluster."

    for repo ; do
# Repo IDs can not contain slashes, so replace slashes with dashes.
cat <<EOF
[${repo//\//-}]
name=${repo}
baseurl=@@INSTALL_SERVER@@/${repo}
enabled=1
gpgcheck=0

EOF
    done

cat <<EOF
@@@_YUM_TEMPLATE@@@
EOF
}

get_kvm_path ()
{
    local t

    if t=$(which qemu-kvm 2>/dev/null) ; then
	echo "$t"
    elif t=$(which kvm 2>/dev/null) ; then
	echo "$t"
    elif [ -x "/usr/libexec/qemu-kvm" ] ; then
	echo "/usr/libexec/qemu-kvm"
    else
	die "Could not find KVM executable"
    fi

}

rhel_get_install_kernel_options ()
{
    case "$RHEL_VERSION" in
	(7.*) echo "ks=hd:LABEL=KICKSTART inst.stage2=hd:LABEL=RHEL-${RHEL_VERSION}\\\\x20Server.${RHEL_ARCH}" ;;
	(*) echo "ks=floppy" ;;
    esac
}

rhel_get_install_ks_device_xml ()
{
    if [ ${RHEL_VERSION%%.*} -le 6 ] ; then
	cat <<EOF
    <disk type='file' device='floppy'>
      <source file='@@PWD@@/tmp/floppy.img'/>
      <target dev='fda'/>
      <readonly/>
    </disk>
EOF
    else
	cat <<EOF
    <disk type='file' device='disk'>
      <source file='@@PWD@@/tmp/floppy.img'/>
      <target dev='@@SYSTEM_DISK_PREFIX@@b' bus='@@SYSTEM_DISK_TYPE@@'/>
      <driver name='qemu' type='raw'/>
    </disk>
EOF
    fi
}

rhel_get_multipath_magic ()
{
    if [ ${RHEL_VERSION%%.*} -le 6 ] ; then
	cat <<EOF
 udev_dir                /dev
 getuid_callout          "$SHARED_DISK_MULTIPATH_CALLOUT"
EOF
    fi
}

rhel_post_config_hook ()
{
    if [ "$ISO" = "@uto" ] ; then
	ISO=$(rhel_print_iso) || exit $?
    fi

    if [ "$SYSTEM_DISK_MOUNTS" = "@uto" ] ; then
	SYSTEM_DISK_MOUNTS=$(system_disk_mounts) || exit $?
    fi

    if [ "$MEM" = "@uto" ] ; then
	MEM=$(rhel_default_mem) || exit $?
    fi

    if [ "$SYSTEM_DISK_PREFIX" = "@uto" ] ; then
	SYSTEM_DISK_PREFIX=$(rhel_disk_prefix $SYSTEM_DISK_TYPE) || exit $?
    fi

    if [ "$KVM" = "@uto" ] ; then
	KVM=$(get_kvm_path) || exit $?
    fi

    if [ "$INSTALL_KERNEL_OPTIONS" = "@uto" ] ; then
	INSTALL_KERNEL_OPTIONS=$(rhel_get_install_kernel_options) || exit $?
    fi

    if [ "$INSTALL_KS_DEVICE_TEMPLATE" = "@uto" ] ; then
	INSTALL_KS_DEVICE_TEMPLATE=$(rhel_get_install_ks_device_xml) || exit $?
    fi

    if [ "$RHEL_MULTIPATH_MAGIC" = "@uto" ] ; then
	RHEL_MULTIPATH_MAGIC=$(rhel_get_multipath_magic) || exit $?
    fi

    if [ "$NAMESERVER" = "@uto" ] ; then
	NAMESERVER="$KVMHOST"
    fi

    if [ "$INSTALL_SERVER" = "@uto" ] ; then
	INSTALL_SERVER="http://${KVMHOST}/mediasets"
    fi

    if [ "$NFSSHARE" = "@uto" ] ; then
	NFSSHARE="10.0.0.1:/home"
    fi
}

register_hook post_config_hooks rhel_post_config_hook

defconf RHEL_ARCH "x86_64" \
	"<arch>" "The RHEL operating system architecture to configure"

defconf RHEL_VERSION "6.2" \
	"<version>" "version of Red Hat Enterprise Linux to configure"

defconf RHEL_MULTIPATH_MAGIC "@uto"

defconf ISO_DIR "/virtual/ISO" \
	"<dir>" "directory for ISO images, prepended to $ISO if not absolute"

defconf ISO "@uto" \
	"<file>" "ISO image for base image creation"

# the install server where we will get local packages from
defconf INSTALL_SERVER "@uto" \
        "<url>" "URL of install server"

defconf CONFIG_EXTRA_PACKAGES "" \
	"<packages>" "list of extra packages to install at configuration time"

# the yum repositories to use. Choose the one appropriate for the
# system you are installing
defconf YUM_TEMPLATE "$_YUM_TEMPLATE" \
	"<file>" "location of template for yum repositories"

defconf INSTALL_KS_DEVICE_TEMPLATE "@uto"

##############################

defconf CREATE_BASE_TIMEOUT 3600 \
	"<seconds>" "time to wait for base image install before aborting" 

##############################

# Authentication method
defconf AUTH_METHOD "files" \
    "files|winbind" "authentication method"

##############################