Rewrite autocluster in Python
[autocluster.git] / config.d / 00base.defconf
index 3632add9aebfeebe6fc7ceab1279b48a1cdaca68..5b78545702313125b8f8f462f15c00f4b98a4722 100644 (file)
@@ -4,18 +4,21 @@
 
 # Cluster
 
-defconf NODES "sofs_front:0-3 rhel_base:4" \
-       "<nodes>" "list of node types to create, with associated IP offsets"
+defconf CLUSTERFS_TYPE "gpfs" \
+       "<gpfs|?>" "type of cluster filesystem to use"
+
+defconf CLUSTERFS_DEFAULT_MOUNTPOINT "/clusterfs" \
+       "<directory>" "mountpoint for default cluster filesystem"
 
-defconf NUMNODES "" \
-       "<n>" "number of nodes to build, not including TSM server"
+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 "10.0.0.1:/home" \
+defconf NFSSHARE "@uto" \
        "<mnt>" "NFS share to mount on each node"
 
 defconf NFS_MOUNTPOINT "/home" \
@@ -62,6 +65,9 @@ defconf NODE_TEMPLATE "$installdir/templates/node.xml" \
 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"
 
@@ -71,7 +77,7 @@ defconf BASE_TEMPLATES "$installdir/base" \
 defconf BASE_FORMAT "qcow2" \
        "<fmt>" "format to use for the qemu base images"
 
-defconf SYSTEM_DISK_TYPE "ide" \
+defconf SYSTEM_DISK_TYPE "virtio" \
        "scsi|ide|virtio" "type of disks to use in nodes"
 
 rhel_disk_prefix ()
@@ -82,7 +88,7 @@ rhel_disk_prefix ()
        ide)
            case "$RHEL_VERSION" in
                (5.*) echo "hd" ;;
-               (6.*) echo "sd" ;;
+               ([67].*) echo "sd" ;;
                (*) die "Unknown RHEL_VERSION in rhel_disk_prefix" ;;
            esac
            ;;
@@ -113,7 +119,6 @@ system_disk_access_method_hook ()
                SYSTEM_DISK_ACCESS_METHOD="guestfish"
            elif which qemu-nbd nbd-client >/dev/null 2>&1 ; then
                SYSTEM_DISK_ACCESS_METHOD="loopback"
-               ISO=$(rhel_print_iso)
            else
                die "Can't determine SYSTEM_DISK_ACCESS_METHOD.  Need guestfish or qemu-nbd + nbd-client."
            fi
@@ -135,11 +140,11 @@ system_disk_mounts ()
        loopback)
            case "$RHEL_VERSION" in
                (5.*) echo "/:32256" ;;
-               (6.*) echo "/:1048576" ;;
+               ([67].*) echo "/:1048576" ;;
                (*) die "Unknown RHEL_VERSION in system_disk_mounts" ;;
            esac
            ;;
-       (guestfish|guestmount) echo "/:/dev/vda1" ;;
+       (guestfish|guestmount) : ;;
        (*) die "Unknown SYSTEM_DISK_ACCESS_METHOD in system_disk_mounts" ;;
     esac
 }
@@ -157,9 +162,6 @@ defconf SYSTEM_DISK_MOUNTS "@uto" \
 defconf TIMEZONE "" \
        "<tz>" "timezone for each node"
 
-defconf KEYBOARD "us" \
-       "<kbd>" "keyboard layout 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
@@ -176,7 +178,7 @@ rhel_default_mem ()
 {
     case "$RHEL_VERSION" in
        (5.*) echo "262144" ;;
-       (6.*) echo "512000" ;;
+       ([67].*) echo "512000" ;;
        (*) die "Unknown RHEL_VERSION in rhel_default_mem" ;;
     esac
 }
@@ -190,9 +192,6 @@ defconf NICMODEL "e1000" \
 defconf ROOTPASSWORD "password" \
        "<string>" "initial root password for each node"
 
-defconf KS_LANGUAGE "${LANG:-en_US.UTF-8}" \
-       "<locale>" "locale for installer to use"
-
 defconf NUMCPUS 2 \
        "<n>" "number of virtual CPUs per node"
 
@@ -216,34 +215,90 @@ defconf DOMAIN "EXAMPLE.COM" \
 defconf WORKGROUP "EXAMPLE" \
        "<grp>" "Windows(TM) workgroup for node"
 
-# DNS name server. Usually set this to the
-# kvm host, then setup DNS on the kvm host to direct 
-# queries for the windows domain name to the w2003 server
-defconf NAMESERVER "10.0.0.1" \
+defconf NAMESERVER "@uto" \
        "<ip>" "DNS server for each node"
 
 defconf DNSSEARCH "$DOMAIN" \
        "<dom>" "extra domains for DNS search list"
 
-# set the first two octets of the IPs we will use
-# the 3rd and 4th octets are controlled by the node setup scripts
-defconf IPBASE "10.0" \
-       "<n>.<n>" "first 2 octets of IP for each node"
+# 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
 
-defconf IPNET0 "0" \
-       "<n>" "3rd octet of IP for each node for network 0"
+       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
+}
 
-defconf IPNET1 "1" \
-       "<n>" "3rd octet of IP for each node for network 1"
+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="$*"
+}
 
-defconf IPNET2 "2" \
-       "<n>" "3rd octet of IP for each node for network 2"
+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 IPBASE is 10.0, IPNET0 is 0 and FIRSTIP is 20 then
+# 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
@@ -257,7 +312,7 @@ 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 gpfs-nas.conf"
+       "<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
@@ -269,8 +324,8 @@ defconf PUBLIC_ADDRESSES "|make_public_addresses" \
 defconf WEBPROXY "" \
        "<url>" "URL of a caching web proxy"
 
-defconf GATEWAY "10.0.0.1" \
-       "<ip>" "IP gateway for cluster hosts, usually KVM host"
+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"
@@ -298,20 +353,30 @@ rhel_print_iso ()
        (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";;
+       (6.8) datever="20160414.0";;
+       (6.9) datever="20170309.0";;
+       (6.10) datever="20180525.0";;
+       (7.0) datever="20140507.0";;
+       (7.1) datever="20150219.1";;
+       (7.2) datever="20151030.0";;
+       (7.3) datever="20161019.0";;
+       (7.4) datever="20170711.0";;
+       (7.5) datever="20180322.0";;
        (*) 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.*) echo "RHEL${RHEL_VERSION}-${datever}-Server-${RHEL_ARCH}-DVD1.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
 }
 
-rhel_package_list ()
-{
-    cat "$installdir/templates/RHEL${RHEL_VERSION%%.*}.packages"
-}
-
 # yum repo infrastructure
 _YUM_TEMPLATE="$installdir/templates/RHEL.repo" # Private - used below!
 rhel_gen_yum_repos ()
@@ -351,27 +416,90 @@ get_kvm_path ()
 
 }
 
+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)
+       ISO=$(rhel_print_iso) || exit $?
     fi
 
     if [ "$SYSTEM_DISK_MOUNTS" = "@uto" ] ; then
-       SYSTEM_DISK_MOUNTS=$(system_disk_mounts)
+       SYSTEM_DISK_MOUNTS=$(system_disk_mounts) || exit $?
     fi
 
     if [ "$MEM" = "@uto" ] ; then
-       MEM=$(rhel_default_mem)
+       MEM=$(rhel_default_mem) || exit $?
     fi
 
     if [ "$SYSTEM_DISK_PREFIX" = "@uto" ] ; then
-       SYSTEM_DISK_PREFIX=$(rhel_disk_prefix $SYSTEM_DISK_TYPE)
+       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
@@ -382,7 +510,7 @@ defconf RHEL_ARCH "x86_64" \
 defconf RHEL_VERSION "6.2" \
        "<version>" "version of Red Hat Enterprise Linux to configure"
 
-defconf RHEL_PACKAGES "|rhel_package_list"
+defconf RHEL_MULTIPATH_MAGIC "@uto"
 
 defconf ISO_DIR "/virtual/ISO" \
        "<dir>" "directory for ISO images, prepended to $ISO if not absolute"
@@ -390,40 +518,19 @@ defconf ISO_DIR "/virtual/ISO" \
 defconf ISO "@uto" \
        "<file>" "ISO image for base image creation"
 
-defconf KICKSTART "$installdir/templates/gpfs-nas-kickstart.cfg" \
-       "<file>" "choice of kickstart file"
-
 # the install server where we will get local packages from
-defconf INSTALL_SERVER "http://10.0.0.1/mediasets" \
+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"
 
-# any extra packages to install. List one on each line. To force a package
-# not to be installed, list it with a leading - 
-defconf EXTRA_PACKAGES '' \
-       "<list>" "extra packages for kickstart to install"
-
-defconf EXTRA_CHKCONFIGS "" \
-       "<chkconfigs>" "extra chkconfig commands to run in post-install"
-
-defconf INSTALLKEY "--skip" \
-       "<key>" "RHEL install key"
-
-defconf STANDARD_POSTINSTALL "$installdir/templates/basic-postinstall.sh" \
-       "<file>" "standard kickstart postinstall script - change with care"
-
-defconf POSTINSTALL_TEMPLATE "" \
-       "<file>" "extra script to be incorporated into kickstart post-install"
-
-defconf KS_KERNEL_OPTS "rhgb console=tty1 console=ttyS0,19200 nodmraid nompath" \
-       "<opts>" "options passed by kickstart to the kernel"
-
-defconf KS_DONE_MESSAGE "you may safely reboot your system|System halted." \
-       "<string>" "string indicating kickstart install is complete"
+defconf INSTALL_KS_DEVICE_TEMPLATE "@uto"
 
 ##############################
 
@@ -432,60 +539,6 @@ defconf CREATE_BASE_TIMEOUT 3600 \
 
 ##############################
 
-# Note that this is only for RHEL packages available in Kickstart.
-# This is not for packages installed from a local repository!
-_EXTRA_RHEL_PACKAGES=""
-add_extra_package ()
-{
-
-    _EXTRA_RHEL_PACKAGES="${_EXTRA_RHEL_PACKAGES}
-$*"
-}
-
-add_extra_chkconfig ()
-{
-    local package="$1"
-    local state="$2"
-
-    EXTRA_CHKCONFIGS="${EXTRA_CHKCONFIGS}${EXTRA_CHKCONFIGS:+ }${package}:${state}"
-}
-
-##############################
-
-register_hook hack_nodes_functions hack_nodes_rhel_base
-
-hack_nodes_rhel_base ()
-{
-    local node_count_rhel_base=0
-    hack_filter ()
-    {
-       case "$node_type" in
-           rhel_base)
-               node_count_rhel_base=$(($node_count_rhel_base + 1))
-               name="${CLUSTER}base${node_count_rhel_base}"
-               ctdb_node=1
-           esac
-    }
-    hack_all_nodes_with hack_filter
-}
-
-create_node_rhel_base ()
-{
-    local ip_offset="$1"
-    local name="$2"
-    local ctdb_node="$3"
-
-    echo "Creating RHEL base node $name"
-    create_node_COMMON "$name" "$ip_offset" "$type"
-}
-
-has_public_addresses_rhel_base ()
-{
-    true
-}
-
-##############################
-
 # Authentication method
 defconf AUTH_METHOD "files" \
     "files|winbind" "authentication method"