[ale] Set hostname in RHEL 7 kickstart?
Brian Mathis
brian.mathis+ale at betteradmin.com
Thu Apr 30 16:56:54 EDT 2015
The --bootproto=dhcp tells anaconda how to configure the network after the
install is complete and you reboot. You typically use DHCP for the PXE
boot, but then for the actual OS you might want a static IP, so the
'network' command is telling anaconda what you want for the final
configuration.
I don't use Satellite, so not sure where it goes, but the 'network' command
is a kickstart command, not something that you run as part of the %pre or
%post scripts. For some reason I also have the network line that sets the
hostname as an additional line, which looks like this:
network --device=ens192 --bootproto=dhcp --ipv6=auto --activate
network --device=ens192 --hostname=${HOSTNAME}"
Also you need to populate the HOSTNAME variable somehow. If that's blank
it obviously won't work.
❧ Brian Mathis
@orev
On Thu, Apr 30, 2015 at 4:45 PM, James Sumners <james.sumners at gmail.com>
wrote:
> Nope. That didn't work.
>
> I'm using Satellite 6 to build and serve the kickstart. So what I did is
> remove my post "blunt instrument" script and added a new pre script:
>
> ```
> network --activate --device=$IFDEVICE --bootproto=static --ip=$IPADDR \
> --netmask=255.255.255.0 --gateway=$GATEWAY --nameserver $DNS1,$DNS2 \
> --hostname=$HOSTNAME --onboot=yes
> ```
>
> The result is that the network script didn't get created at all because
> the "network" tool couldn't be found.
>
> On the "Kickstart Details > Advanced Options" page I have "--bootproto
> dhcp". I suppose that's replaceable since the kickstart should be retrieved
> after it has already booted from the PXE image?
>
> On Thu, Apr 30, 2015 at 4:16 PM, Brian Mathis <
> brian.mathis+ale at betteradmin.com> wrote:
>
>> 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
>>>
>>>
>>
>> _______________________________________________
>> 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
>>
>>
>
>
> --
> 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/a37531a4/attachment.html>
More information about the Ale
mailing list