7

I'm trying to use Oz to create a CentOS 6.4 virtual machine image and install some packages from EPEL. When it tries to install the epel-release package, I get the error:

Public key for epel-release-6-8.noarch.rpm is not installed

I can pass a custom kickstart file to Oz, so my thinking is to import this key in the post-installation script. What should I put in the %post section so the appropriate key gets imported?

For reference, here's what my Oz template looks like this:

<template>
    <name>centos-6.4</name>
    <os>
        <name>CentOS-6</name>
        <version>4</version>
        <arch>x86_64</arch>
        <install type='iso'>
            <iso>file:///data/isos/CentOS-6.4-x86_64-bin-DVD1.iso</iso>
        </install>
    </os>
    <description>CentOS 6.4 x86_64</description>
    <repositories>
        <repository name='epel-6'>
            <url>http://download.fedoraproject.org/pub/epel/6/$basearch</url>
            <signed>yes</signed>
        </repository>
    </repositories>
    <packages>
        <package name="epel-release" />
        <package name="cloud-utils" />
        <package name="cloud-init" />
    </packages>
    </commands>
</template>

(I could just turn off the check for signed packages, but I'd like to figure out how to do this without turning off that check).

Edit: Here's what my custom kickstart currently looks like:

install
text
key --skip
keyboard us
lang en_US.UTF-8
skipx
network --device eth0 --bootproto dhcp
rootpw %ROOTPW%
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --disabled
timezone --utc America/New_York
bootloader --location=mbr --append="console=tty0 console=ttyS0,115200"
zerombr yes
clearpart --all

part / --fstype ext4 --size=1024 --grow
reboot

%packages
@base

%post
# What do I put here???
Lorin Hochstein
  • 8,077
  • 17
  • 50
  • 56

1 Answers1

5

Method #1

You can do this in the %post section:

echo "configuring epel repository"
rpm -Uvh http://download.fedora.redhat.com/pub/epel/beta/6/x86_64/epel-release-6-5.noarch.rpm

Method #2

I think the more formal way of doing this is like this though in your .ks file:

repo --name=epel --baseurl=http://LOCALEPELMIRROR/.../epel/6/x86_64/
%package
...
epel-release

%post
...
/usr/sbin/rhnreg_ks --activationkey=$ACTIVATIONKEY
rpm --import /usr/share/rhn/RPM-GPG-KEY
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release-2

Method #3

You can also use a heredoc and generate a yum .repo file into the /etc/yum.repos.d/ like so:

%post
cat >/etc/yum.repos.d/your.repo <<EOF
[... INCLUDE REPO CONFIG FILE CONTENTS HERE ...]
EOF

References

slm
  • 363,520
  • 117
  • 767
  • 871