summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2021-01-04 21:22:07 -0800
committerTim Smith <tsmith84@gmail.com>2021-01-04 22:14:55 -0800
commit316669f6afbebcf5af4db2aa1d4ce24293dc3562 (patch)
tree7e21cc4ccca532d9fc674cca7361bd08f306b59e
parent04b3f0b60a7188ec7f41c66ec329e1b28aeb8d1f (diff)
downloadchef-reposdir.tar.gz
Add a new `reposdir` property in the `yum_repository` resourcereposdir
This let's you optionally add/remove repo configs from a non-standard dir. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/provider/yum_repository.rb4
-rw-r--r--lib/chef/resource/yum_repository.rb5
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."