简体   繁体   English

工头-用本地镜像替换仓库

[英]Foreman - replacing repo with local mirrors

We use foreman (v1.14.1) for provisioning and we have a working CentOS 7 installation media for the base OS. 我们使用foreman(v1.14.1)进行配置,并且拥有适用于基本OS的有效CentOS 7安装介质。 When installing it does install the default repos in /etc/yum.repos.d with online mirrors but I want to replace this with our local mirrors. 安装时,确实使用在线镜像在/etc/yum.repos.d中安装了默认存储库,但是我想用我们的本地镜像替换它。

I ran accross this workflow (from 2012) It uses the following snippet to iterate over all the media of the current host os and set write out a repo definition. 我遇到了这个工作流程(从2012年开始),它使用以下代码片段迭代当前主机操作系统的所有媒体,并设置写出一个repo定义。

<% @host.os.media.each do |media| -%>
[<%= media.name.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '') %>]
name=<%= media.name %>
baseurl=<%= @host.os.medium_uri @host, media.path %>
enabled=1
gpgcheck=0
<% end -%>

I have set several Installation media for this OS, each one of them having a specific repo URI (Base, Updates, Plus, Extras...). 我为此操作系统设置了几种安装媒体,其中每个都有一个特定的仓库URI(基本,更新,加号,附加...)。

The snippet is called in the %post install section of the kickstart but when I want to build the host I get the following error: 在kickstart的%post安装部分中调用了该代码段,但是当我要构建主机时,出现以下错误:

Failure parsing Kickstart default: The snippet 'FF_repos' threw an error: 
undefined method 'media' for Operatingsystem::Jail (Redhat).

I understand that "@host.os.media.each" is not correct for iterating over the different medias, but how could I do it ? 我知道“ @ host.os.media.each”不适用于在不同媒体上进行迭代,但是我该怎么做呢? Any help appreciated :) 任何帮助表示赞赏:)

Couldn't get this to work so I have simply changed my snippet "FF_repos" to directly bake the repos definition into corresponding repo files on disk. 无法使用此功能,因此我仅更改了代码段“ FF_repos”即可将存储库定义直接烘焙到磁盘上相应的存储库文件中。

I added the following in the %post section then to remove default repos and leave our. 我在%post部分中添加了以下内容,然后删除了默认存储库并离开了我们。

rm -f /etc/yum.repos.d/*
<%= snippet("FF_repos") %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM