Re: Custom ISO with Kickstart and Local Repos

2018-02-23 Thread Andrew Simpson
so all you're trying to do is add some packages and a kickstart file?

I don't use any external tools.  I add in the new packages into a directory
at the top level of the disc image and modify the Packages directory if I
need to.  then I run createrepo on each "package" directory

createrepo --update -d -g comps.xml ${repo}  trying to remember this, so
verify it's correct.  if you want to use the comps/groups file, use the -g
option, otherwise ignore it.

In my kickstart, I add in the additional package directories as new repos
for yum to find the packages.  after adding ANY rpms, you will need to
re-run createrepo on each folder and add them as repos in the ks file IF
you want anaconda to be able to install them.  otherwise, you can mount in
the post and run rpm commands directly on each command.

to get additional data off of the disc, you will also need to ensure you
"mount" the disc/source somewhere the kickstart can access the data and
your anaconda/isolinux options must be set correctly, so you have to get
inst.ks and inst.stage2 setup properly.

inst.stage2=hd:LABEL=${DRIVELABEL} inst.loglevel=debug lang=en_US.UTF-8
keymap=us inst.ks=cdrom:/dev/cdrom:/ks/${ksname}.ks

NOTE:  inst.stage2 uses a label designation.  this LABEL value MUST be
exact.  When you generate your iso, usb drive, whatever, it MUST have the
label exactly matching the DRIVELABEL value or it won't install.  Also, you
can use inst.upgrade to point to an upgraded anaconda Product.img file
which can contain rebrading/anaconda customizations.



Here's a kickstart snippet that covers a lot of ground:

"""

#PRE Section

  ksDeviceSource=$(sed 's/ /\n/g' /proc/cmdline | grep '^inst.ks='|cut
-f1 -d:|cut -f2 -d'=')
  if (grep -q "ks=hd:LABEL" /proc/cmdline)
  then
ksDeviceName=$(sed 's/ /\n/g' /proc/cmdline | grep '^inst.ks='|cut
-f2 -d":" | cut -f2 -d"=")
ksDeviceBaseName=`blkid -L $ksDeviceName`
ksDeviceBaseName=`basename $ksDeviceBaseName`
  else
#using a normal dev name, not a LABEL
ksDeviceName=$(sed 's/ /\n/g' /proc/cmdline | grep '^inst.ks='|cut
-f2 -d":")
ksDeviceBaseName=`basename $ksDeviceName`
  fi

  if [[ -z "${repo}" ]]; then
#Are we using a usb drive?
if [[ "${ksDeviceName}" == "hd" ]]; then
   repo="hd"
else
  # If no repo was specified, then we must be installing from disc
  repo="cdrom"
fi
  fi

  # Variable for the repo line:
  srcLoc="/tmp"
  # Mount the source repo
  mkdir -p /tmp/source
  repotype=$(echo "${repo}" | cut -d: -f1)
  if [[ "${repotype}" == "nfs" ]]; then
source=$(echo "${repo}" | cut -d: -f2-)
mount -t nfs -o nolock "${source}" /tmp/source
  elif [[ "${repotype}" == "cdrom" ]]; then
echo "cdrom" >> /tmp/pre.ks
# Re-bind the existing mount otherwise we'll get errors with some devices
### WARNING:  RHEL 7 anaconda now mounts to /run/install/repo.
/mnt/stage2 is gone.
###  it's possible that we no longer need to do this mount, but
hey, then we'd have to change A LOT!
mount --bind /run/install/repo /tmp/source
  elif [[ "${repotype}" == "hd" ]]; then
   echo "harddrive --partition=$ksDeviceBaseName --dir=/" >> /tmp/pre.ks
# Re-bind the existing mount otherwise we'll get errors with some devices
# I am not sure if we need to do the next mount with USB/HD.
# NOTE:  the next line will not work if we expand to multiple iso(s).
tmpDIR=$(mktemp -d)
mount -L $ksDeviceName $tmpDIR
mount -o loop $tmpDIR/imagename*.iso /tmp/source
srcLoc="/tmp"
#mount --bind /tmp/source /mnt/source
  fi


  #set the repos here.
cat << EOF > /tmp/repos.ks
repo --name="ELRepo" --baseurl=file://$srcLoc/source/ELRepo --cost=41
repo --name="EPEL" --baseurl=file://$srcLoc/source/EPEL --cost=40
repo --name="Extras" --baseurl=file://$srcLoc/source/Extras  --cost=50

repo --name="Custom" --baseurl=file://$srcLoc/source/Custom --cost=50


repo --name="Optional" --baseurl=file://$srcLoc/source/Optional --cost=35
repo --name="Supplementary"
--baseurl=file://$srcLoc/source/Supplementary --cost=36
repo --name="Workstation" --baseurl=file://$srcLoc/source/Workstation
--cost=33
repo --name="Packages" --baseurl=file://$srcLoc/source/Packages --cost=30
EOF

## End Pre Section 

Post section##

# This is the First Post script,
  # copy things that are needed in chrooted Posts to where they can be found.
  source /tmp/cmdline  #you won't use these three lines probably
  cp -p /tmp/cmdline /mnt/sysimage/tmp/cmdline
  cp -p /tmp/cmdline /mnt/sysimage/root/cmdline


  # Re-mount the source for the post-scripting
  {{ m.export_cmdline() }}  #This is a JINJA operator, you would need
to add in the mount command here if not using JINJA

  ksDeviceSource=$(sed 's/ /\n/g' /proc/cmdline | grep '^ks='|cut -f1
-d:|cut -f2 -d'=')

  if (grep -q "ks=hd:LABEL" /proc/cmdline)
  then
ksDeviceName=$(sed 's/ /\n/g' /proc/cmdline | grep '^ks='|cut -f2
-d":" | cut -f2 -d"=")

Re: Custom ISO with Kickstart and Local Repos

2018-02-22 Thread Vinícius Ferrão
Firas, thank you.

That’s appears to be exactly what I need.

I’ll be doing some test tomorrow and report back.

V.

> On 22 Feb 2018, at 22:40, Firas Alshafei  wrote:
> 
> V,
> 
> If you're adding rpms then you'll need to update the repo to actually include 
> them. I'm not familiar with Lorax so I can't really help there, but if your 
> end goal is  a standard RHEL dvd with extra packages that you want to define 
> in your kickstart configuration then it should just require createrepo and 
> genisoimage.
> 
> My use case is fairly vanilla kickstart you might have to modify to suit your 
> workflow.
> - isolinux and efi use the inst.ks and inst.stage2 to point to kickstart file 
> and installation source respectively.
> - kickstart file and pre/post/conf scripts in DVD/kickstart directory 
> structure
> - Packages in the default DVD/Packages and additional packages in 
> /DVD/Packages-Extra
> - I delete all uneeded packages to reduce DVD size, just feed the rpm -qa 
> output on an installed system to yumdownloader
> 
> Here's a script stub - I do something similar in-house to get our DVDs 
> created for air-gapped environments (it's a pain).
> Hope this helps 
> 
> #!/bin/bash
> #===
> # Title: create-iso
> #
> # Description  : Generate kickstart dvd
> #
> # Author   : Firas AlShafei
> #
> # Last Revised : 11/04/2015
> #
> #===
> 
> # Assume following path structure
> #
> # working-directory
> # |
> # ---> creat-iso.sh
> # |
> # ---> media (DVD media + kickstart + additional packages)
> 
> # Path variables
> scriptPath=$(dirname "$(readlink -f "$0")")
> isoPath=${scriptPath}
> releaseName="my-awesome-dvd.iso"
> 
> # Move repo group info
> mv ${scriptPath}/media/repodata/*-comps-Server.x86_64.xml 
> ${scriptPath}/media/repodata/comps-Server.x86_64.xml
> 
> # Create repo
> cd ${scriptPath}/media
> createrepo --quiet --pretty --update --groupfile 
> repodata/comps-Server.x86_64.xml .
> 
> # Make ISO file
> echo "== Generate DVD Image"
> echo "= ${isoPath}/${releaseName}.iso"
> genisoimage -r -T -J -V ${releaseName} \
> -quiet\
> -o ${isoPath}/${releaseName}.iso  \
> -no-emul-boot \
> -boot-load-size 4 \
> -boot-info-table  \
> -b isolinux/isolinux.bin  \
> -c isolinux/boot.cat  \
> -eltorito-alt-boot\
> -no-emul-boot \
> -b images/efiboot.img \
> ${scriptPath}/media/
> 
>
>   
>  
> 
> Firas AlShafei
> Senior Lead Engineer
> Enterprise Software
> ABB
> 
> -Original Message-
> From: kickstart-list-boun...@redhat.com 
> [mailto:kickstart-list-boun...@redhat.com] On Behalf Of Vinícius Ferrão
> Sent: Thursday, February 22, 2018 3:47 PM
> To: kickstart-list@redhat.com
> Subject: Custom ISO with Kickstart and Local Repos
> 
> CAUTION: This email originated from outside of the organization. Do not click 
> links or open attachments unless you recognize the sender and know the 
> content is safe.
> 
> 
> Hello,
> 
> I’m trying to create a custom ISO with a Kickstart file to achieve a complete 
> offline installation.
> 
> I was able to create the Kickstart file as usual, since I use it for PXE 
> installs for at least 10 years, but the major problem now is building the ISO 
> with the necessary files.
> 
> I’ve came across a tool named Lorax, but I was not able to create a custom 
> ISO from DVD’s. It only works when point to mirrors, and this is a time 
> consuming task. Another problem is that Lorax does not seems to care about 
> the /usr/share/lorax/product folder to create a custom Anaconda with the 
> embedded kickstart file on /usr/share/anaconda/interactive-defaults.ks.
> 
> The small ISO generated by Lorax lacks local repositories and I was unable to 
> find the appropriate documentation on how to build this scenario. So it 
> generates a boot only install that must be done over the Internet.
> 
> At this moment I’m running Lorax on a CentOS install, I’ve got RHEL licenses 
> too, but to keep it simple I just went with CentOS. I think this is 
> irrelevant information but it’s just for the sake of completion.
> 
> With genisoimage I was able to add the custom product.img file, that I’ve 
> generated by hand with cpio, on the ISO but I was not able to solve the local 
> repos problem. There are packages that I would like to add to the install 
> media, like Ansible, but they are available only on the Extras repository and 
> I’m unsure on how to do this. Just wondering if createrepo and yumdownloader 
> are necessary...
> 
> Any help is greatly appreciated.
> 
> Thanks,
> V.
> 
> 
> 

Re: Custom ISO with Kickstart and Local Repos

2018-02-22 Thread Vinícius Ferrão
Hi,

> On 22 Feb 2018, at 19:11, Arun SAG  wrote:
> 
> Hello,
> 
> On Thu, Feb 22, 2018 at 1:46 PM, Vinícius Ferrão
>  wrote:
>> 
>> The small ISO generated by Lorax lacks local repositories and I was unable 
>> to find the appropriate documentation on how to build this scenario. So it 
>> generates a boot only install that must be done over the Internet.
> 
> Have you tried using pungi? Pungi takes in a kickstart file as input
> and generates an install media. I would give you an example but my old
> pungi composes are based on < pungi-4.

Well… pungi-3.12 is available for CentOS. So I guess I’m on < 4 too.

> Pungi creates install media, livemedia-creator creates live media,
> what type of media are you trying to create?

I would like to create and ISO of CentOS with the "Server with GUI” environment 
group and Ansible, which is available on Extras repository.

There’s additional branding on the installer and removal of options in Anaconda 
too, for example: I don’t want the package selection screen. This is handled 
with product.img sending a premade /etc/sysconfig/anaconda file with a similar 
content like:

[root@centos7 sysconfig]# cat anaconda 
[SourceSpoke]
visited = 1

[SoftwareSelectionSpoke]
visited = 1

[UserSpoke]
visited = 1

> https://fedoraproject.org/wiki/Remix
> https://www.happyassassin.net/2016/02/15/pungi-4-the-new-generation-of-the-fedora-compose-tools-and-what-it-means-for-qa/
>  
> 

I’m looking at it.

Thanks,
V.

> 
> 
> 
> -- 
> Arun S A G
> http://zer0c00l.in/
> 
> ___
> Kickstart-list mailing list
> Kickstart-list@redhat.com
> https://www.redhat.com/mailman/listinfo/kickstart-list

___
Kickstart-list mailing list
Kickstart-list@redhat.com
https://www.redhat.com/mailman/listinfo/kickstart-list

Re: Custom ISO with Kickstart and Local Repos

2018-02-22 Thread Arun SAG
Hello,

On Thu, Feb 22, 2018 at 1:46 PM, Vinícius Ferrão
 wrote:
>
> The small ISO generated by Lorax lacks local repositories and I was unable to 
> find the appropriate documentation on how to build this scenario. So it 
> generates a boot only install that must be done over the Internet.

Have you tried using pungi? Pungi takes in a kickstart file as input
and generates an install media. I would give you an example but my old
pungi composes are based on < pungi-4.

Pungi creates install media, livemedia-creator creates live media,
what type of media are you trying to create?

https://fedoraproject.org/wiki/Remix
https://www.happyassassin.net/2016/02/15/pungi-4-the-new-generation-of-the-fedora-compose-tools-and-what-it-means-for-qa/



-- 
Arun S A G
http://zer0c00l.in/

___
Kickstart-list mailing list
Kickstart-list@redhat.com
https://www.redhat.com/mailman/listinfo/kickstart-list