Ansible-Playbook 无法安装 MongoDB

Ansible-Playbook unable to install MongoDB

我有一个 ansible-playbook 文件,用于将一堆软件包安装到 Ubuntu VM (22.04) 上,包括 MongoDB。但是,当我 运行 它时,我收到以下错误:

fatal: [myserver]: FAILED! => {"cache_update_time": 1651714552, "cache_updated": true, "changed": false, "msg": "'/usr/bin/apt-get -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" install 'mongodb-org'' failed: E: Unable to correct problems, you have held broken packages.\n", "rc": 100, "stderr": "E: Unable to correct problems, you have held broken packages.\n", "stderr_lines": ["E: Unable to correct problems, you have held broken packages."], "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nSome packages could not be installed. This may mean that you have\nrequested an impossible situation or if you are using the unstable\ndistribution that some required packages have not yet been created\nor been moved out of Incoming.\nThe following information may help to resolve the situation:\n\nThe following packages have unmet dependencies:\n mongodb-org-mongos : Depends: libssl1.1 (>= 1.1.1) but it is not installable\n mongodb-org-server : Depends: libssl1.1 (>= 1.1.1) but it is not installable\n mongodb-org-shell : Depends: libssl1.1 (>= 1.1.1) but it is not installable\n", "stdout_lines": ["Reading package lists...", "Building dependency tree...", "Reading state information...", "Some packages could not be installed. This may mean that you have", "requested an impossible situation or if you are using the unstable", "distribution that some required packages have not yet been created", "or been moved out of Incoming.", "The following information may help to resolve the situation:", "", "The following packages have unmet dependencies:", " mongodb-org-mongos : Depends: libssl1.1 (>= 1.1.1) but it is not installable", " mongodb-org-server : Depends: libssl1.1 (>= 1.1.1) but it is not installable", " mongodb-org-shell : Depends: libssl1.1 (>= 1.1.1) but it is not installable"]}

这些是负责 ansible-playbook 中 MongoDB 的任务:

---
- hosts: myserver
  become: true
  remote_user: admin
  vars_files:
     - default.yml

  tasks:
    - name: "Install aptitude"
      apt:
        name: aptitude
        state: latest
        update_cache: true

    - name: "Import MongoDB public key"
      apt_key:
         url: "https://www.mongodb.org/static/pgp/server-5.0.asc"
         state: present

    - name: "Add MongoDB repository"
      apt_repository:
         filename: '/etc/apt/sources.list.d/mongodb-org-5.0.list'
         repo: "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse"
         state: present
         update_cache: yes

    - name: "Install MongoDB"
      apt: 
         name: mongodb-org
         state: present
         update_cache: yes

需要注意的是,ansible-playbook 是在“Install MongoDB”任务中失败的。之前的任务执行的很好。

关于如何解决这个问题有什么想法吗?

好吧,经过一些激烈的谷歌搜索后,我遇到的问题似乎与 OS 有关,我的虚拟机是 运行 - Ubuntu 22.04.

关于同一问题的 MongoDB team member post on a community forum 基本上说,由于 22.04 是相当新的,MongoDB 团队还没有发布兼容包。在撰写本文时,他的 post 已经 8 天了。 MongoDB 团队成员还建议不要尝试将针对不同 OS 版本的不同包合并在一起。

所以,真的,看来我唯一的选择就是恢复到早期的 OS 版本。

希望这对遇到同样问题的其他人有所帮助!