From 316669f6afbebcf5af4db2aa1d4ce24293dc3562 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Mon, 4 Jan 2021 21:22:07 -0800 Subject: Add a new `reposdir` property in the `yum_repository` resource This let's you optionally add/remove repo configs from a non-standard dir. Signed-off-by: Tim Smith --- lib/chef/provider/yum_repository.rb | 4 ++-- lib/chef/resource/yum_repository.rb | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/chef/provider/yum_repository.rb b/lib/chef/provider/yum_repository.rb index 956d5ae64c..b0dfe20f1b 100644 --- a/lib/chef/provider/yum_repository.rb +++ b/lib/chef/provider/yum_repository.rb @@ -33,7 +33,7 @@ class Chef def load_current_resource; end action :create do - declare_resource(:template, "/etc/yum.repos.d/#{new_resource.repositoryid}.repo") do + declare_resource(:template, ::File.join(new_resource.reposdir, "#{new_resource.repositoryid}.repo")) do if template_available?(new_resource.source) source new_resource.source else @@ -81,7 +81,7 @@ class Chef only_if "yum repolist all | grep -P '^#{new_resource.repositoryid}([ \t]|$)'" end - declare_resource(:file, "/etc/yum.repos.d/#{new_resource.repositoryid}.repo") do + declare_resource(:file, ::File.join(new_resource.reposdir, "#{new_resource.repositoryid}.repo")) do action :delete notifies :create, "ruby_block[package-cache-reload-#{new_resource.repositoryid}]", :immediately end diff --git a/lib/chef/resource/yum_repository.rb b/lib/chef/resource/yum_repository.rb index 94d1a284fc..b5ad2688eb 100644 --- a/lib/chef/resource/yum_repository.rb +++ b/lib/chef/resource/yum_repository.rb @@ -50,6 +50,11 @@ class Chef # http://linux.die.net/man/5/yum.conf as well as # http://dnf.readthedocs.io/en/latest/conf_ref.html + property :reposdir, String, + description: "The directory where the Yum repository files should be stored", + default: "/etc/yum.repos.d/", + introduced: "16.9" + property :baseurl, [String, Array], description: "URL to the directory where the Yum repository's `repodata` directory lives. Can be an `http://`, `https://` or a `ftp://` URLs. You can specify multiple URLs in one `baseurl` statement." -- cgit v1.2.1