[Spacewalk-list] Spacewalk Kickstart wizard variables

Jon Miller jonebird at gmail.com
Thu Jun 6 21:43:00 UTC 2013


Assuming both your pre & post scripts are ran in a "nochroot" environment,
then you can use a temporary file location under /tmp. I'll use a few of
your variables as examples and let you fill in the rest:

%pre script excerpt:
cat <<EOF > /tmp/custom_vars
hostname=$hostname2  # spelling correct?
ip=$ip
token=$token
rack=$rack
EOF

That is called a "here-document" and you can find more details about it in
your local bash(1) manpage.
Later in your %post script, you can source it via the "." operator or
keyword "source":
source /tmp/custom_vars
echo "Relearned that my IP is $ip"

-- Jon Miller



On Thu, Jun 6, 2013 at 12:51 PM, Corey Hemminger <
corey.hemminger at nativex.com> wrote:

> How do I re-source them in the %post script? I'm fairly new to kickstart
> and have limited bash scripting experience. Most of my scripts I have
> pieced together from pieces I've found across the internet.
>
> Thanks,
> Corey
>
> >If your pre script is already working the way you'd like it to, I'd
> suggest just writing out the answers is a "varname=$varname" format that
> you can later re-source in the %post >section.
> >
> >-- Jon Miller
> >
> >
> >On Thu, Jun 6, 2013 at 12:11 PM, Corey Hemminger <
> corey.hemminger at nativex.com> wrote:
> >
> > I have a pre script for kickstart that I'd like to set variables for
> > cobbler templating of the scripts that are based on user input and can
> > also be used in the post scripts for things like hostname and
> > networking. Here is a copy of the script below. How can I set a
> > variable in the pre script that can be called and used in the post
> > script. I've learned that the "kickstart details > variables" Aren't
> > editable during the kickstart process.
> >
> > This is for a bare metal install and I want to be able to get a few
> > inputs at the beginning then run unattended. I did originally have all
> > this in the post install but then the install doesn't finish if
> > someone walks away until they come back and add the inputs and the
> > script continues with the final configuration and post install update.
> >
> > curTTY=`tty`
> > exec < \$curTTY > \$curTTY 2> \$curTTY
> >
> > echo
> > echo -n "Starting Pre Install Script"
> >
> > echo
> > echo -n "Configure the Server"
> > while [ x"$answer" != "xy" ] && [ x"$answer" != "xY" ]; do
> >         echo
> >         echo -n "enter hostname: "; read hostname2
> >         echo -n "enter ip adress: "; read ip
> >         echo -n "enter netmask: "; read netmask
> >         echo -n "enter default gateway: "; read gw
> >         echo -n "enter domain name to join pc to ie. example.com: ";
> > read domain
> >         echo -n "enter user account to join domain: "; read user
> >         echo -n "enter user password to join domain: "; read pass
> >         echo -n "enter token number for cassandra node, leave blank to
> > allow auto bisect of most loaded token range during autobootstrap: ";
> > read token
> >         echo -n "enter datacenter for cassandra node location: "; read dc
> >         echo -n "enter rack for cassandra node location: "; read rack
> >         echo
> >
> >         echo You entered:
> >         echo -e "\thostname:            $hostname2"
> >         echo -e "\tip address:          $ip"
> >         echo -e "\tnetmask:             $netmask"
> >         echo -e "\tdefault gateway:     $gw"
> >         echo -e "\tdomain:              $domain"
> >         echo -e "\tAD account:          $user"
> >         echo -e "\tAD password:         $pass"
> >         echo -e "\tcassandra token:     $token"
> >         echo -e "\tcassandra DC:        $dc"
> >         echo -e "\tcassandra rack:      $rack"
> >         echo
> >         echo -n "Double check passwords are correct or else Domain
> > join will fail and will be required to be done manually after reboot"
> >         echo
> >         echo -n "Is this correct? [y/n] "; read answer done
> >
> > echo
> > echo -n "Setting Host Name."
> >
> > echo "network --device eth0 --bootproto static \
> >        --ip=${ip} --netmask=${netmask} \
> >        --gateway=${gw} \
> >        --hostname=${hostname2} \
> >        --onboot=yes --noipv6 \
> >        --nameserver=${dns1}" > /tmp/network
> >
> >
> > Thanks,
> > Corey
>
> _______________________________________________
> Spacewalk-list mailing list
> Spacewalk-list at redhat.com
> https://www.redhat.com/mailman/listinfo/spacewalk-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/spacewalk-list/attachments/20130606/e951249e/attachment.htm>


More information about the Spacewalk-list mailing list