我正在使用 Ansible 在我的 Centos 8 机器上安装 Postgresql。这是引发错误的命令:
- name: PostgreSQL | Install PostgreSQL | dnf
dnf:
name: "postgresql{{ postgresql_version_terse }}-server,postgresql{{ postgresql_version_terse }},postgresql{{ postgresql_version_terse }}-contrib"
state: present
environment: "{{ postgresql_env }}"
错误消息如下所示:
fatal: [localhost]: FAILED! => changed=false
failures:
- No package postgresql12-server available.
- No package postgresql12 available.
- No package postgresql12-contrib available.
msg: Failed to install some of the specified packages
rc: 1
results: []
我使用命令检查了已安装的存储库yum -v repolist
并看到了这个:
Repo-id : postgresql
Repo-name : postgresql yum repo
Repo-revision: 1589461611
Repo-updated : Thu 14 May 2020 04:06:52 PM MSK
Repo-pkgs : 257
Repo-size : 225 M
Repo-baseurl : https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-7-x86_64
Repo-expire : 172,800 second(s) (last: Thu 01 Jan 1970 03:00:00 AM MSK)
Repo-filename: /etc/yum.repos.d/postgresql.repo
出于测试目的,我尝试手动安装它:
$ dnf install postgresql12
但它给了我这个错误信息:
Last metadata expiration check: 0:01:19 ago on Fri 15 May 2020 01:41:17 PM MSK.
No match for argument: postgresql12
Error: Unable to find a match: postgresql12
从这个线程来看,正确的命令是这个:
$ dnf --repo postgresql install postgresql12
这有什么问题以及如何使用 Ansible 实现它?