[ale] Set hostname in RHEL 7 kickstart?

Brian Mathis brian.mathis+ale at betteradmin.com
Thu Apr 30 16:16:39 EDT 2015


Set the hostname by making a tmp file with the 'network' kickstart command
in the %pre script like this:
    echo "network --device=ens192 --hostname=${HOSTNAME}" >
/tmp/ks-network-hostname
then include that file in the kickstart commands section of the file like
this:
    %include /tmp/ks-network-hostname

Overwriting the files like you're doing is a blunt instrument and is sure
to fail at some point (like you're seeing).  Use the kickstart commands as
much as possible so anaconda can do the right thing.  I also treat every
major release as a *major* release, which requires a complete review and
rewrite to adapt to whatever changes were made.


❧ Brian Mathis
@orev


On Thu, Apr 30, 2015 at 2:53 PM, James Sumners <james.sumners at gmail.com>
wrote:

> I have a post script to set network configurations that gets used in all
> of my kickstarts:
>
> ```
> exec 6<&1
> exec > /etc/sysconfig/network
> cat <<HERE_DOC
> NETWORKING=yes
> HOSTNAME=$HOSTNAME
> GATEWAY=$GATEWAY
> HERE_DOC
> exec 1<&6
> ```
>
> Works great with RHEL 5/6, but since RHEL 7 switched to systemd not so
> much (due to hostnamectl [a totally unnecessary change]). According to the
> documentation[1], I should only have to put my hostname in `/etc/hostname`.
> So I added this to my post script:
>
> ```
> cat /etc/redhat-release 1>/dev/null | grep "release 7"
> if [ \$? -eq 0 ]; then
> # RHEL 7
> echo "Enabling RHEL 7 hostname"
> exec 6<&1
> exec > /etc/hostname
> cat <<HERE_DOC
> $HOSTNAME
> HERE_DOC
> exec 1<&6
> fi
> ```
>
> The "Enabling RHEL 7 hostname" doesn't get written to the kickstart post
> log, and the hostname doesn't get written to `/etc/hostname`.
>
> Does anyone have a method for doing this?
>
> [1] --
> https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Migration_Planning_Guide/sect-Red_Hat_Enterprise_Linux-Migration_Planning_Guide-System_Management.html#sect-Red_Hat_Enterprise_Linux-Migration_Planning_Guide-System_Management-Hostname_Definition
>
> --
> James Sumners
> http://james.sumners.info/ (technical profile)
> http://jrfom.com/ (personal site)
> http://haplo.bandcamp.com/ (band page)
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20150430/da0bc09f/attachment.html>


More information about the Ale mailing list