如何使用Ansible添加PPA存储库?

时间:2015-03-28 16:43:21

标签: linux ubuntu ansible

我正在尝试将新存储库添加到服务器,以便我可以通过Ansible安装Java。不幸的是,每当我尝试运行playbook时,由于GPG错误而失败。有人可以解释这里出了什么问题以及我需要做些什么才能解决这个问题?

我正在使用Ansible 1.7.2,目前只连接到localhost。

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

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

当我尝试执行它时,我收到以下错误:

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   

2 个答案:

答案 0 :(得分:1)

哦,这似乎完全是因为我忘记了-s选项!

如果没有这个,它就不会使用sudo。

答案 1 :(得分:1)

将选项validate_certsno

一起使用

- name: Adicionando PPA do php 7.1 apt_repository: validate_certs: no repo: 'ppa:ondrej/php' state: present