[ale] Set hostname in RHEL 7 kickstart?

James Sumners james.sumners at gmail.com
Thu Apr 30 14:53:16 EDT 2015


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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20150430/6509e1f5/attachment.html>


More information about the Ale mailing list