apt-get 失败 "There are problems and -y was used without --force-yes"

apt-get fails with "There are problems and -y was used without --force-yes"

使用 postgres 在 ubuntu 14.04 上安装 postgres 9.4 时,出现以下错误

There are problems and -y was used without --force-yes

这是我的任务:

---
- name: Add postgres repository
  apt_repository: repo='deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main' state=present

- name: ensure apt cache is up to date
  apt: update_cache=yes

- name: ensure packages are installed
  apt: name={{item}}
  with_items:
    - postgresql-9.4

这是如何修复的?

您必须添加存储库密钥。添加 repo 后,添加此步骤:

- name: Add postgres repo key
  apt_key: url=https://www.postgresql.org/media/keys/ACCC4CF8.asc state=present