2012-11-04 68 views
0

我看了at similar questions但沒有人提到我應該如何解決這個問題。我想寫一個快速和骯髒的腳本,這將幫助我引導新鮮的Fedora安裝Puppet爲我想嘗試的某些東西。從細讀這裏的問題。我有一些示例代碼可以滿足我的需求。通過Python API安裝Yum Repos的PGP密鑰

[[email protected] ~]# 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) <[email protected]>" 
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密鑰必須正確簽署。任何人之前做過?

回答

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()