【发布时间】:2018-12-30 08:22:45
【问题描述】:
我正在尝试使用 Ansible 从自定义存储库安装 MariaDB(或任何软件),但我不确定如何使用 yum/yum_repository 模块导入 .repo 文件。
Ansible
这是我的剧本:
-
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 关键步骤,但我什至无法正确添加 repo。
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
外壳
这是我尝试转换为 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 配置器运行它。
【问题讨论】:
标签: ansible yum vagrant-provision