本文介绍了如何使用 Ansible 添加 PPA 存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向服务器添加一个新存储库,以便我可以通过 Ansible 安装 Java.不幸的是,每当我尝试运行剧本时,它都会因为 GPG 错误而失败.有人可以解释这里出了什么问题以及我需要做什么才能解决这个问题吗?

I'm trying to add a new repository to a server so that I can install Java by Ansible. Unfortunately whenever I try to run the playbook it fails because of a GPG error. Can somebody explain what is going wrong here and what I need to do in order to fix this?

我使用的是 Ansible 1.7.2,目前只连接到本地主机.

I'm using Ansible 1.7.2 and currently only connecting to localhost.

我有一个非常简单的 Playbook,如下所示:

I have a very simple Playbook that looks like this:

- hosts: home
  tasks:
   - name: Add repositories
     apt_repository: repo='ppa:webupd8team/java' state=present

当我尝试执行它时,出现以下错误:

When I try to execute it, I get the following error:

sal@bobnit:~/Workspace$ ansible-playbook --ask-sudo-pass basic.yml 
sudo password: 

PLAY [home] ******************************************************************* 

GATHERING FACTS *************************************************************** 
ok: [localhost]

TASK: [Add repositories] ****************************************************** 
failed: [localhost] => {"cmd": "apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 7B2C3B0889BF5709A105D03AC2518248EEA14886", "failed": true, "rc": 2}
stderr: gpg: requesting key EEA14886 from hkp server keyserver.ubuntu.com
gpg: no writable keyring found: eof
gpg: error reading `[stream]': general error
gpg: Total number processed: 0

stdout: Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.HKDOSZnVQP --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d/steam.gpg --keyring /etc/apt/trusted.gpg.d/ubuntu-x-swat_ubuntu_x-updates.gpg --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 7B2C3B0889BF5709A105D03AC2518248EEA14886

msg: gpg: requesting key EEA14886 from hkp server keyserver.ubuntu.com
gpg: no writable keyring found: eof
gpg: error reading `[stream]': general error
gpg: Total number processed: 0

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/sal/basic.retry

localhost                  : ok=1    changed=0    unreachable=0    failed=1   

推荐答案

哦,这好像完全是我忘记了 -s 选项造成的!

Oh, this seems to have been entirely caused by me forgetting the -s option!

没有这个,它就不会使用 sudo.

Without this it wasn't using sudo.

这篇关于如何使用 Ansible 添加 PPA 存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 21:32