0

我看过类似的问题,但没有人提到我应该如何处理这个问题。我想编写一个快速而肮脏的脚本,帮助我在新的 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 密钥。以前有人做过吗?

4

1 回答 1

1

请加

yb.conf.assumeyes = True

在适当情况下。egyou 代码应该是这样的:

#!/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()
于 2013-07-19T12:49:48.640 回答