Reformed the attributes to use the newer better methods, added compat_resources

This commit is contained in:
Eric Renfro 2017-02-06 15:25:29 -05:00
parent 993c8e48b8
commit 2fb94f3ade
No known key found for this signature in database
GPG key ID: 9A949323CBE78F97
6 changed files with 45 additions and 47 deletions

View file

@ -2,5 +2,9 @@ source "https://supermarket.chef.io"
metadata
cookbook "yum-epel", ">= 2.1.1"
group :integration do
cookbook "compat_resource", '>= 12.16.3'
cookbook "yum-epel", ">= 2.1.1"
end

View file

@ -1 +1,5 @@
default['yum-zabbix']['repositories'] = %w(zabbix zabbix-non-supported)
default['yum-zabbix']['repos'] = %w(
zabbix
zabbix-non-supported
)

View file

@ -1,9 +1,14 @@
default['yum']['zabbix-non-supported']['repositoryid'] = 'zabbix-non-supported'
default['yum']['zabbix-non-supported']['description'] = 'Zabbix Official Repository - $basearch'
case node['platform']
when 'amazon'
default['yum']['zabbix-non-supported']['baseurl'] = "http://repo.zabbix.com/non-supported/rhel/6/$basearch/"
default['yum']['zabbix-non-supported']['gpgkey'] = 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX'
else
default['yum']['zabbix-non-supported']['baseurl'] = "http://repo.zabbix.com/non-supported/rhel/#{node['platform_version'].to_i}/$basearch/"
default['yum']['zabbix-non-supported']['gpgkey'] = 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX'
end
default['yum']['zabbix-non-supported']['gpgcheck'] = true
default['yum']['zabbix-non-supported']['enabled'] = false
default['yum']['zabbix-non-supported']['managed'] = false
default['yum']['zabbix-non-supported']['gpgkey'] = 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX'
default['yum']['zabbix-non-supported']['gpgcheck'] = true
default['yum']['zabbix-non-supported']['description'] = 'Zabbix Official Repository - $basearch'
default['yum']['zabbix-non-supported']['baseurl'] = "http://repo.zabbix.com/non-supported/rhel/#{node['platform_version'].to_i}/$basearch/"

View file

@ -1,11 +1,19 @@
default['yum']['zabbix']['repositoryid'] = 'zabbix'
default['yum']['zabbix']['description'] = 'Zabbix Official Repository - $basearch'
default['yum']['zabbix']['release_repo'] = '3.0'
case node['platform']
when 'amazon'
default['yum']['zabbix']['baseurl'] = "http://repo.zabbix.com/zabbix/#{node['yum']['zabbix']['release_repo']}/rhel/6/$basearch/"
default['yum']['zabbix']['gpgkey'] = 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX'
else
default['yum']['zabbix']['baseurl'] = "http://repo.zabbix.com/zabbix/#{node['yum']['zabbix']['release_repo']}/rhel/#{node['platform_version'].to_i}/$basearch/"
if node['yum']['zabbix']['release_repo'].to_f > 3.0
default['yum']['zabbix']['gpgkey'] = 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-A14FE591'
else
default['yum']['zabbix']['gpgkey'] = 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX'
end
end
default['yum']['zabbix']['enabled'] = true
default['yum']['zabbix']['managed'] = true
default['yum']['zabbix']['gpgkey'] = 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX'
default['yum']['zabbix']['gpgcheck'] = true
default['yum']['zabbix']['release_repo'] = '3.0'
default['yum']['zabbix']['description'] = 'Zabbix Official Repository - $basearch'
default['yum']['zabbix']['baseurl'] = "http://repo.zabbix.com/zabbix/#{node['yum']['zabbix']['release_repo']}/rhel/#{node['platform_version'].to_i}/$basearch/"
default['yum']['zabbix']['make_cache'] = true

View file

@ -4,14 +4,15 @@ maintainer_email 'psi-jack@linux-help.org'
license 'Apache 2.0'
description 'Installs and configures the Zabbix Yum Repository'
long_description ''
version '1.0.0'
version '1.0.1'
issues_url 'https://git.linux-help.org/Linux-Help/cookbook-yum-zabbix/issues'
source_url 'https://git.linux-help.org/Linux-Help/cookbook-yum-zabbix'
%w{ centos redhat oracle scientific }.each do |os|
%w{amazon centos redhat oracle scientific}.each do |os|
supports os, '>= 6.0.0'
end
depends 'compat_resource', '>= 12.16.3'
depends 'yum-epel', '>= 2.1.1'
chef_version '>= 12.1'

View file

@ -14,38 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
node['yum-zabbix']['repositories'].each do |repo|
next unless node['yum'][repo]['managed']
include_recipe 'yum-epel' unless run_context.loaded_recipe?('yum-epel')
node['yum-zabbix']['repos'].each do |repo|
next unless node['yum'][repo]['managed']
yum_repository repo do
description node['yum'][repo]['description'] unless node['yum'][repo]['description'].nil?
baseurl node['yum'][repo]['baseurl'] unless node['yum'][repo]['baseurl'].nil?
mirrorlist node['yum'][repo]['mirrorlist'] unless node['yum'][repo]['mirrorlist'].nil?
gpgcheck node['yum'][repo]['gpgcheck'] unless node['yum'][repo]['gpgcheck'].nil?
gpgkey node['yum'][repo]['gpgkey'] unless node['yum'][repo]['gpgkey'].nil?
enabled node['yum'][repo]['enabled'] unless node['yum'][repo]['enabled'].nil?
cost node['yum'][repo]['cost'] unless node['yum'][repo]['cost'].nil?
exclude node['yum'][repo]['exclude'] unless node['yum'][repo]['exclude'].nil?
enablegroups node['yum'][repo]['enablegroups'] unless node['yum'][repo]['enablegroups'].nil?
failovermethod node['yum'][repo]['failovermethod'] unless node['yum'][repo]['failovermethod'].nil?
http_caching node['yum'][repo]['http_caching'] unless node['yum'][repo]['http_caching'].nil?
include_config node['yum'][repo]['include_config'] unless node['yum'][repo]['include_config'].nil?
includepkgs node['yum'][repo]['includepkgs'] unless node['yum'][repo]['includepkgs'].nil?
keepalive node['yum'][repo]['keepalive'] unless node['yum'][repo]['keepalive'].nil?
max_retries node['yum'][repo]['max_retries'] unless node['yum'][repo]['max_retries'].nil?
metadata_expire node['yum'][repo]['metadata_expire'] unless node['yum'][repo]['metadata_expire'].nil?
mirror_expire node['yum'][repo]['mirror_expire'] unless node['yum'][repo]['mirror_expire'].nil?
priority node['yum'][repo]['priority'] unless node['yum'][repo]['priority'].nil?
proxy node['yum'][repo]['proxy'] unless node['yum'][repo]['proxy'].nil?
proxy_username node['yum'][repo]['proxy_username'] unless node['yum'][repo]['proxy_username'].nil?
proxy_password node['yum'][repo]['proxy_password'] unless node['yum'][repo]['proxy_password'].nil?
repositoryid node['yum'][repo]['repositoryid'] unless node['yum'][repo]['repositoryid'].nil?
sslcacert node['yum'][repo]['sslcacert'] unless node['yum'][repo]['sslcacert'].nil?
sslclientcert node['yum'][repo]['sslclientcert'] unless node['yum'][repo]['sslclientcert'].nil?
sslclientkey node['yum'][repo]['sslclientkey'] unless node['yum'][repo]['sslclientkey'].nil?
sslverify node['yum'][repo]['sslverify'] unless node['yum'][repo]['sslverify'].nil?
timeout node['yum'][repo]['timeout'] unless node['yum'][repo]['timeout'].nil?
action :create
node['yum'][repo].each do |config, value|
send(config.to_sym, value) unless value.nil? || config == 'managed' || config == 'release_repo'
end
end
end