# -*-perl-*-

# $Id: Install.plm,v 1.13 2005/07/26 20:43:23 thomas Exp $

# What package to handle install-time configuration

# $Log: Install.plm,v $
# Revision 1.13  2005/07/26 20:43:23  thomas
# raid device changes
#
# Revision 1.12  2005/01/10 15:01:25  thomas
# Moved setinstall bits to AllHosts/Install.plm
#
# Revision 1.11  2004/08/17 20:48:54  thomas
# express ondisk semantics
#
# Revision 1.10  2004/07/22 19:55:56  thomas
# *** empty log message ***
#
# Revision 1.9  2004/07/22 19:53:28  thomas
# *** empty log message ***
#
# Revision 1.8  2004/07/22 19:51:49  thomas
# try to make pxe files based on $target first
#
# Revision 1.7  2004/07/22 19:21:51  thomas
# Add clearinstall() method.
#
# Revision 1.6  2004/07/21 21:03:48  thomas
# grow attribute is a boolean
#
# Revision 1.5  2004/07/02 19:00:13  thomas
# Remove replacement of @@TEST@@
#
# Revision 1.4  2004/04/12 19:41:43  thomas
# variable substitution
#
# Revision 1.3  2004/02/10 16:40:11  thomas
# pre-0.1.5 fork
#
# Revision 1.2  2004/01/15 14:50:34  thomas
# commit before forking 0.1.3
#
# Revision 1.1  2004/01/13 16:48:31  thomas
# catch-up 1/13/04
#

=head1 NAME

What::Node::Install -- configure initial installation

=head1 DESCRIPTION

The B</Install> configuration subtree controls the configuration of
architecture-dependent bootstrap installers for B<what>.  This allows
B<what> configurations to control features such as disk partitioning
that can only be set at the bootstrap install time.  The actual
archetecture-dependent files are written out using the B<what>
B<setinstall> command.

=over

=item PARTITIONS

Nodes in the configuration tree under B</Install/partitions> describe
partitions to be created on the target system(s).  One partition will be
created for each node B</Install/partitions/>I<name>, where I<name> is
an index for the partition.  Each partition may have any or all of the
following attributes:

=over

=item mountpoint

The mount point for the partition, if the partition corresponds to a
file system.

=item size

The size of the file system in bytes.  May be suffixed with any of the
letters k, K, m, M, g, or G to specify kilo-, mega-, or giga- bytes.

=item grow

A boolean to indicate that this partition may grow if additional space
is available on the target device.

=item ondisk

If the partition needs to be created on a specific device, this
attribute specifies the target device.

=item fstype

Specifies the target file system type for this partition.

=item raid_devs

Specifies that this partition should be a raid set.  The value of this
attribute is a comma-separated list of the devices on which the raid
set should be created.

=item raid_level

Specifies the raid level of the raid set (0, 1, or 5).

=item maxsize

Used in conjunction with the B<grow> attribute, this attribute
specifies the maximum size of the partition.

=back

Any partition that contains no B<mountpoint> attribute is assumed to
be a swap partition, and will be identified as such in the target
configuration.

=item IDENTIFYING TARGET SYSTEMS

This section describes how the B<What::Node::Install> module
identifies what host(s) or subnets(s) should have their bootstrap
configurations set.

If the B<targets> attribute of the B</Install> node exists, its value
is a comma-separated list of network addresses in CIDR format.  The
configuration should be applied to all hosts represented by any of the
CIDR networks.

If the B<targets> attribute of the B</Install> node does B<not> exist,
then the B<target> attribute of the root configuration node must
contain a valid hostname, and the configuration applies only to that
host.  The name of the first configuration file encountered on the
command line is automatically placed in B</target>.  Alternatively,
the B</target> can be specified with the B<what> global option B<-t
I<target-name>>.

Likewise, if the B<target_name> attribute of the B</Install> node
exists, its value is the name that should be given in various file
system entries (kickstart, pxe, jumpstart, etc.) for this
configuration.  It is up to the creators of configuration content to
ensure that two differing configurations do not use the same
B<target_name>.  The results of doing so are undefined.  This option
exists to reduce file system clutterage, and its use is optional.

=item KICKSTART

The attributes of the node B</Install/kickstart> control the creation
of kickstart files for kickstart-based systems.

=over

=item protofile

The name of the prototype kickstart file.  There are several
substitutions that will be made to this file.  The default is
ks.cfg.proto.  This file is found in B<protodir> (see next).

=item protodir

The directory from which to read the b<protofile>.  The default is
usually obtained from an architecture-specific kickstart xml file.
This file will be appended with a dash (B<->) and B<use_alternate> if
B</Install/use_alternate> is defined (see below).

=item outdir

The directory into which to put the resulting kickstart files.  The
default is B<protodir> (see above).

=back

=item PXE

This is a low-level configuration used in the creation of
B<pxelinux.cfg> files.  The B</Install/pxe> node contains global
parameters for the pxe configuration.  This includes:

=over

=item default

The I<name> of the default pxe boot target (see
B</Install/pxe/>I<name>, below).

=item prompt

A boolean indicating whether or not to prompt for a target.

=item display

A file on the tftp server to display when booting.

=item timeout

How long to wait before booting the default target.

=item pxedir

The directory in which to output pxe files.  This may be suffixed,
depending on the attribute B</Install/use_alternate> (see below).

=back

B</Install/pxe/>I<name> nodes contain information regarding pxelinux
boot stanzas.  Possible attributes include:

=over

=item kernel

The file on the tftp server to boot as the kernel image

=item append

Information to pass on the kernel command line, including initial ram
disks, kickstart files, etc.

=item localboot

If this attribute is present and no B<kernel> attribute exists, a
B<localboot> pxe stanza will be created.

=back



=head1 MISCELLANEOUS

(Of course.  What else would you expect in a nuts-and-bolts module like this?)

=over

=item /Install/use_alternate

This attribute indicates that an alternate set of installation paths
should be used.  The common (and only) value this variable may take is
b<test>, which indicates that the test install source should be used.

=item /Install/reboot

This boolean attribute specifies whether or not the target computer
should automatically reboot after the bootstrap installation is
complete.

=item /bootstrap_method

This root attribute specifies the bootstrap method that should be used
for this host.  Currently the only method implemented is B<pxe>.

=back



=head1 EXAMPLES

Change the size of the /var/vice/cache partition to 8 GBytes.

<node path="/Install/partitions/var" size="8G" />

Delete a local partition, if present

<delete path="/Install/partitions/local" />

Create a configuration that will apply to all hosts on the 128.105.146.0/23,128.105.148.0/24, and 128.105.149.0/24 networks.

<node path="/Install" targets= "128.105.146.0/23,128.105.148.0/24,12
8.105.149.0/24" />

Reboot after the first stage install.

<node path="/Install" reboot="1" />


=head1 FILES

=over

=item /afs/cs/i386_rh9/install/ks.cfg.proto

The default prototype ks.cfg file for Red Hat installations.  This file
contains several @@B<variable>@@ constructs that get filled in from
configuration data.

=back

=head1 SEE ALSO

B<What::AllHosts::Install>

=cut

package What::Node::Install;

use strict;
use FileHandle;
use Data::Dumper;
use Net::hostent;

use base qw(What::Node);

our %opts = ();

# Set the priority for this module in $::
$::module_priority{'Install'} = 20;

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

1;
