From 4d20303a192c50345a2aec5f6767fffe9644ff57 Mon Sep 17 00:00:00 2001 From: Etienne Grignon Date: Tue, 19 Aug 2014 16:29:23 -0700 Subject: [PATCH 1/2] adding multiple repository setup via attributes --- CHANGELOG.md | 4 ++++ README.md | 13 +++++++++++++ attributes/default.rb | 2 ++ metadata.rb | 2 +- recipes/default.rb | 30 ++++++++++++++++++++++-------- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99c338f..72a3afc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## head +## 0.2.0 (08/19/2014) + +added multiple repositories setup via attributes hash + ## 0.1.1 (08/11/2014) * remove unused reference to `intu_metadata` namespace diff --git a/README.md b/README.md index ebcbaeb..1ff26ea 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,19 @@ Platform: `node['yum_s3_iam']['repo_bucket']` - Default value: 'http://our-bucket-name.s3.amazonaws.com' +## Multiple repositories setup +node['repo_default'] = false # Will not setup the default repository +node['repositories'] = { + "repo_name1": { + "repo_description": "...", + "repo_bucket": ".." + }, + "repo_name2": { + "repo_description": "...", + "repo_bucket": ".." + } +} + # Recipes ## default Installs `yum-s3-iam` package and configures a yum repo with S3/IAM support. diff --git a/attributes/default.rb b/attributes/default.rb index 9b00ca4..7a11a33 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -2,3 +2,5 @@ default['yum_s3_iam']['repo_name'] = 'our repo' default['yum_s3_iam']['repo_description'] = 'our package repo' default['yum_s3_iam']['repo_bucket'] = 'http://our-bucket-name.s3.amazonaws.com/' +default['yum_s3_iam']['repo_default'] = true +default['yum_s3_iam']['repositories'] = {} diff --git a/metadata.rb b/metadata.rb index c9b2020..bcedf79 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license "Apache 2.0" description "Installs/Configures the yum-s3-iam plugin" long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "0.1.1" +version "0.2.0" %w{ centos rhel }.each do |os| supports os diff --git a/recipes/default.rb b/recipes/default.rb index 62b9fb7..f836ad2 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -2,12 +2,26 @@ version node['yum_s3_iam']['version'] end -template File.join('/', 'etc', 'yum.repos.d', "#{node['yum_s3_iam']['repo_name']}.repo") do - owner 'root' - group 'root' - mode '0644' - source 's3-iam.repo.erb' - variables :repo_name => node['yum_s3_iam']['repo_name'], - :repo_description => node['yum_s3_iam']['repo_description'], - :repo_bucket => node['yum_s3_iam']['repo_bucket'] +if ['yum_s3_iam']['repo_default'] + template File.join('/', 'etc', 'yum.repos.d', "#{node['yum_s3_iam']['repo_name']}.repo") do + owner 'root' + group 'root' + mode '0644' + source 's3-iam.repo.erb' + variables :repo_name => node['yum_s3_iam']['repo_name'], + :repo_description => node['yum_s3_iam']['repo_description'], + :repo_bucket => node['yum_s3_iam']['repo_bucket'] + end +end + +node['yum_s3_iam']['repositories'].each do |repo_name,config| + template File.join('/', 'etc', 'yum.repos.d', "#{repo_name}.repo") do + owner 'root' + group 'root' + mode '0644' + source 's3-iam.repo.erb' + variables :repo_name => repo_name, + :repo_description => config['repo_description'], + :repo_bucket => config['repo_bucket'] + end end From 29bcf49df893275039c2ca1217b2133c90d6808c Mon Sep 17 00:00:00 2001 From: Etienne Grignon Date: Tue, 19 Aug 2014 17:03:00 -0700 Subject: [PATCH 2/2] fixing node attribute conditional --- recipes/default.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/default.rb b/recipes/default.rb index f836ad2..40a45ca 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -2,7 +2,7 @@ version node['yum_s3_iam']['version'] end -if ['yum_s3_iam']['repo_default'] +if node['yum_s3_iam']['repo_default'] template File.join('/', 'etc', 'yum.repos.d', "#{node['yum_s3_iam']['repo_name']}.repo") do owner 'root' group 'root'