我正在尝试使用Ansible从自定义存储库安装MariaDB(或任何软件),但我不确定如何使用yum/yum_repository模块导入.repo文件。
Ansible
这是我的playbook:
-
hosts: all
become: true
remote_user: root
tasks:
-
name: set system timezone
timezone:
name: America/Toronto
-
name: add custom repository
yum_repository:
name: centos_o
description: custom repositories
baseurl: http://example.net/mirror/centos_o.repo
-
name: ensure mariadb is installed
yum:
name: mariadb-server-5.5.*
state: installed
我已经尝试了所有的include
、metalink
、baseurl
和mirrorlist
,但都没有成功。而且我还缺少GPG密钥步骤,但是我甚至无法正确添加仓库。
centos_o.repo文件如下:
# JENKINS
[jenkins]
name=CentOS-$releasever - JENKINS
baseurl=http://example.net/mirror/jenkins/
enabled=0
gpgcheck=1
# MariaDB 5.5
[mariadb]
name=CentOS-$releasever - MariaDB
baseurl=http://example.net/mirror/mariadb/yum/5.5/centos$releasever-amd64/
enabled=0
gpgcheck=1
# MariaDB 10.0
[mariadb]
name=CentOS-$releasever - MariaDB
baseurl=http://example.net/mirror/mariadb/yum/10.0/centos$releasever-amd64/
enabled=0
gpgcheck=1
Shell
这是我正在尝试转换为Ansible的Shell脚本版本:
yum clean all
yum-config-manager --add-repo=http://example.net/mirror/centos_o.repo
yum-config-manager --enable mariadb
rpm --import http://example.net/mirror/mariadb/RPM-GPG-KEY-MariaDB
如果有所不同,我正在CentOS盒子上使用Vagrant的Ansible local provisioner运行此操作。
centos_o.repo
文件的存在来完成,还有更好的方法吗? - rink.attendant.6yum-config-manager
有一个--list-repo
或类似的功能,这样你就可以用这种方式查看情况了。我没有 CentOS 系统来尝试,因此不能确定。 - mdaniel