Prompting for user input during RHEL installation in Anaconda - Tips from BJ Walker, GSS Red Hatter of the Week

Latest response

One of the many versatilities of using a kickstart in Anaconda is it's ability to use the %pre and %post section to customize the system and far as you would like to take it.  One of my favorite features is the ability for Anaconda to switch to a different terminal (TTY) and prompt for user information that can be used to create temporary information files or finish buliding a system.  A configuration like this is extremely helpful if you are providing large subsets of customers with a preconfigured installation media that will need to be customized based on the user's system (i.e. a store number for large retail business, registering to specific channels based on a specific username/password, etc.).  Below is an example of a %post section that I have used in deploying large subsets of systems for use:

%post
# From here the installation has been performed and I request Anaconda to switch to an input terminal
exec < /dev/tty6 > /dev/tty6 2> /dev/tty6
chvt 6

# After the above the screen will have changed to TTY6 and you can now begin prompting for information, in my case RHN username and passwords to register the system and subscribe to a few channels
echo "Please enter your RHN username and press [ENTER]: "
read username
echo "Please enter your RHN password and press [ENTER]: "
read password

# Now that I have the user input for username and password I can register the system from here (grabbing the appropriate entitlement automatically)
rhnreg_ks --username $username --password $password

# Next I request the system to be registered with a few channels (seen here as RHEL 6 channels)
rhn-channel -a --user=$username --password=$password -c rhel-x86_64-server-optional-6
rhn-channel -a --user=$username --password=$password -c rhel-x86_64-server-supplementary-6

# Now that the system has been registered and has a few channels added, I can have the installation go back to the main Anaconda output screen and finish the installation
chvt 1
exec < /dev/tty1 > /dev/tty1 2> /dev/tty1

The above is an example of what can be done using this method, you can prompt for any information neccessary, output specific text to the console for users to review, run scripts, etc.  This is just one of the many things that can be customized and modified using a kickstart installation in RHEL and has been a great resource to me in system deployment.

Responses

Hey all,

Is there a way to do this for creating a local user in the kick start file while taking input?

Never tried it, but you should be able to have it ask twice in the same way above, then compare the two string variables and make sure they match, and then pass one of the variables to passwd --stdin username.