We use foreman (v1.14.1) for provisioning and we have a working CentOS 7 installation media for the base OS. 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.
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.
<% @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...).
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:
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 ? 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.
I added the following in the %post section then to remove default repos and leave our.
rm -f /etc/yum.repos.d/*
<%= snippet("FF_repos") %>