我看过at similar questions,但没有人提到我应该如何处理这个问题。我想写一个快速而肮脏的脚本,这将帮助我在新的Fedora安装上引导Puppet我想尝试的一些东西。从这里仔细阅读问题。我根据自己的需要修改了一些示例代码。
[root@srv ~]# python puppet-bootstrap.py
[ 11/03/2012 02:16:47 PM ] begin bootstrap install for puppet client
[ 11/03/2012 02:16:47 PM ] package not found on system, installing
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 1aca3465: NOKEY
Public key for ruby-1.9.3.286-18.fc17.x86_64.rpm is not installed
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-x86_64
Importing GPG key 0x1ACA3465:
Userid : "Fedora (17) <fedora@fedoraproject.org>"
Fingerprint: cac4 3fb7 74a4 a673 d81c 5de7 50e9 4c99 1aca 3465
Package : fedora-release-17-1.noarch (@fedora)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-x86_64
Traceback (most recent call last):
File "puppet-bootstrap.py", line 17, in <module>
yb.processTransaction()
File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 6053, in processTransaction
self._checkSignatures(pkgs,callback)
File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 6096, in _checkSignatures
self.getKeyForPackage(po, self._askForGPGKeyImport)
File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 5798, in getKeyForPackage
raise Errors.YumBaseError, _("Didn't install any keys")
yum.Errors.YumBaseError: Didn't install any keys
那么我如何通过YUM Python API编写一个简短的小代码来接受PGP密钥呢?有问题的发行版几乎不受影响,因此在此脚本的情况下必须正确签署PGP密钥。有人这么做过吗?
答案 0 :(得分:1)
请添加
yb.conf.assumeyes = True
适当时。例如,您的代码应如下所示:
#!/usr/bin/python
import yum
yb = yum.YumBase()
yb.conf.installroot = "/ipportvm/gittest/rootfs_testrootfs"
yb.conf.assumeyes = True
yb.conf.yumvar['releasever'] = '6'
for i in ("openssh-server", "plymouth", "rsyslog", "acpid", "ntp", "epel-release"):
yb.install(name=i)
yb.resolveDeps()
yb.buildTransaction()
yb.processTransaction()