From 7dd6bae394a246f67218213421a92642f6987408 Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Mon, 18 Jul 2016 22:02:38 -0400 Subject: [PATCH] Initial commit --- Berksfile | 7 ++ Berksfile.lock | 14 ++++ CHANGELOG.md | 5 ++ README.md | 106 +++++++++++++++++++++++++++++++ attributes/default.rb | 1 + attributes/nux-dextop-testing.rb | 15 +++++ attributes/nux-dextop.rb | 15 +++++ metadata.rb | 15 +++++ recipes/default.rb | 51 +++++++++++++++ 9 files changed, 229 insertions(+) create mode 100644 Berksfile create mode 100644 Berksfile.lock create mode 100644 CHANGELOG.md create mode 100644 README.md create mode 100644 attributes/default.rb create mode 100644 attributes/nux-dextop-testing.rb create mode 100644 attributes/nux-dextop.rb create mode 100644 metadata.rb create mode 100644 recipes/default.rb diff --git a/Berksfile b/Berksfile new file mode 100644 index 0000000..db75d7b --- /dev/null +++ b/Berksfile @@ -0,0 +1,7 @@ +source "https://supermarket.chef.io" + +metadata + +cookbook "yum", "~> 3.10.0" +cookbook "yum-epel", "~> 0.6.6" + diff --git a/Berksfile.lock b/Berksfile.lock new file mode 100644 index 0000000..0c5944b --- /dev/null +++ b/Berksfile.lock @@ -0,0 +1,14 @@ +DEPENDENCIES + yum (~> 3.10.0) + yum-epel (~> 0.6.6) + yum-nux + path: . + metadata: true + +GRAPH + yum (3.10.0) + yum-epel (0.6.6) + yum (~> 3.10.0) + yum-nux (0.1.0) + yum (>= 3.2.0) + yum-epel (>= 0.0.0) diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..64191dd --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# yum-nux Cookbook CHANGELOG +This file is used to list changes made in each version of the yum-nux cookbook. + +## v0.1.0 +initial release diff --git a/README.md b/README.md new file mode 100644 index 0000000..9913c77 --- /dev/null +++ b/README.md @@ -0,0 +1,106 @@ +# yum-nux Cookbook + +The yum-nux cookbook takes over management of the default repositoryids that ship with CentOS systems. It allows attribute manipulation of `nux-dextop`, `nux-dextop-testing` + +## Requirements +### Platforms +- RHEL/CentOS and derivatives + +### Chef +- Chef 11+ + +### Cookbooks +- yum version 3.2.0 or higher +- yum-epel + +## Attributes +The following attributes are set by default + +```ruby +default['yum']['nux-dextop']['repositoryid'] = 'nux-dextop' +default['yum']['nux-dextop']['enabled'] = true +default['yum']['nux-dextop']['managed'] = true +default['yum']['nux-dextop']['gpgkey'] = 'http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro' +default['yum']['nux-dextop']['gpgcheck'] = true +default['yum']['nux-dextop']['description'] = 'Nux Desktop Community Packages for Enterprise Linux 6 - $basearch' +default['yum']['nux-dextop']['baseurl'] = 'http://li.nux.ro/download/nux/dextop/el6/$basearch/ http://mirror.li.nux.ro/li.nux.ro/nux/dextop/el6/$basearch/' +``` + +```ruby +default['yum']['nux-dextop-testing']['repositoryid'] = 'nux-dextop-testing' +default['yum']['nux-dextop-testing']['enabled'] = false +default['yum']['nux-dextop-testing']['managed'] = false +default['yum']['nux-dextop-testing']['gpgkey'] = 'http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro' +default['yum']['nux-dextop-testing']['gpgcheck'] = true +default['yum']['nux-dextop-testing']['description'] = 'Nux Desktop Testing Packages for Enterprise Linux 6 - $basearch' +default['yum']['nux-dextop-testing']['baseurl'] = 'http://li.nux.ro/download/nux/dextop-testing/el6/$basearch/' +``` + +## Recipes +- default - Walks through node attributes and feeds a yum_resource +- parameters. The following is an example a resource generated by the +- recipe during compilation. + +```ruby + yum_repository 'nux-dextop' do + baseurl 'http://li.nux.ro/download/nux/dextop/el6/$basearch/ http://mirror.li.nux.ro/li.nux.ro/nux/dextop/el6/$basearch/' + description 'Nux Desktop Community Packages for Enterprise Linux 6 - $basearch' + enabled true + gpgcheck true + gpgkey 'http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro' + end +``` + +## Usage Example +To disable the `nux-dextop` repository through a Role or Environment definition + +``` +default_attributes( + 'yum' => { + 'nux-dextop' => { + 'enabled' => false + } + } +) +``` + +Uncommonly used repositoryids are not managed by default. This is speeds up integration testing pipelines by avoiding yum-cache builds that nobody cares about. To enable the `nux-dextop-testing` repository with a wrapper cookbook, place the following in a recipe: + +``` +node.default['yum']['nux-dextop-tesing']['managed'] = true +node.default['yum']['nux-dextop-tesing']['enabled'] = true +include_recipe 'yum-nux' +``` + +## More Examples +Point the base and debuginfo repositories at an internally hosted server. + +``` +node.default['yum']['nux-dextop']['enabled'] = true +node.default['yum']['nux-dextop']['baseurl'] = 'https://internal.example.com/centos/6/os/x86_64' +node.default['yum']['nux-dextop']['sslverify'] = false +node.default['yum']['nux-dextop-testing']['enabled'] = true +node.default['yum']['nux-dextop-testing']['baseurl'] = 'https://internal.example.com/centos/6/updates/x86_64' +node.default['yum']['nux-dextop-testing']['sslverify'] = false + +include_recipe 'yum-nux' +``` + +## License & Authors +**Author:** Eric Renfro () + +**Copyright:** 2016, Linux-Help.org. + +``` +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` diff --git a/attributes/default.rb b/attributes/default.rb new file mode 100644 index 0000000..ba295d1 --- /dev/null +++ b/attributes/default.rb @@ -0,0 +1 @@ +default['yum-nux']['repositories'] = %w(nux-dextop nux-dextop-testing) diff --git a/attributes/nux-dextop-testing.rb b/attributes/nux-dextop-testing.rb new file mode 100644 index 0000000..6345c78 --- /dev/null +++ b/attributes/nux-dextop-testing.rb @@ -0,0 +1,15 @@ +default['yum']['nux-dextop-testing']['repositoryid'] = 'nux-dextop-testing' +default['yum']['nux-dextop-testing']['enabled'] = false +default['yum']['nux-dextop-testing']['managed'] = false +default['yum']['nux-dextop-testing']['gpgkey'] = 'http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro' +default['yum']['nux-dextop-testing']['gpgcheck'] = true + +case node['platform_version'].to_i +when 6 + default['yum']['nux-dextop-testing']['description'] = 'Nux Desktop Testing Packages for Enterprise Linux 6 - $basearch' + default['yum']['nux-dextop-testing']['baseurl'] = 'http://li.nux.ro/download/nux/dextop-testing/el6/$basearch/' +when 7 + default['yum']['nux-dextop-testing']['description'] = 'Nux Desktop Testing Packages for Enterprise Linux 7 - $basearch' + default['yum']['nux-dextop-testing']['baseurl'] = 'http://li.nux.ro/download/nux/dextop-testing/el7/$basearch/' +end + diff --git a/attributes/nux-dextop.rb b/attributes/nux-dextop.rb new file mode 100644 index 0000000..e60872b --- /dev/null +++ b/attributes/nux-dextop.rb @@ -0,0 +1,15 @@ +default['yum']['nux-dextop']['repositoryid'] = 'nux-dextop' +default['yum']['nux-dextop']['enabled'] = true +default['yum']['nux-dextop']['managed'] = true +default['yum']['nux-dextop']['gpgkey'] = 'http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro' +default['yum']['nux-dextop']['gpgcheck'] = true + +case node['platform_version'].to_i +when 6 + default['yum']['nux-dextop']['description'] = 'Nux Desktop Community Packages for Enterprise Linux 6 - $basearch' + default['yum']['nux-dextop']['baseurl'] = 'http://li.nux.ro/download/nux/dextop/el6/$basearch/ http://mirror.li.nux.ro/li.nux.ro/nux/dextop/el6/$basearch/' +when 7 + default['yum']['nux-dextop']['description'] = 'Nux Desktop Community Packages for Enterprise Linux 7 - $basearch' + default['yum']['nux-dextop']['baseurl'] = 'http://li.nux.ro/download/nux/dextop/el7/$basearch/ http://mirror.li.nux.ro/li.nux.ro/nux/dextop/el7/$basearch/' +end + diff --git a/metadata.rb b/metadata.rb new file mode 100644 index 0000000..d9619de --- /dev/null +++ b/metadata.rb @@ -0,0 +1,15 @@ +name 'yum-nux' +maintainer 'Eric Renfro' +maintainer_email 'psi-jack@linux-help.org' +license 'Apache 2.0' +description 'Installs and configures the NUX Community Desktop Yum Repository' +long_description '' +version '0.1.0' + +%w{ centos redhat oracle scientific }.each do |os| + supports os, '>= 6.0.0' +end + +depends 'yum', '>= 3.2' +depends 'yum-epel', '>= 0.0.0' + diff --git a/recipes/default.rb b/recipes/default.rb new file mode 100644 index 0000000..d3fd47a --- /dev/null +++ b/recipes/default.rb @@ -0,0 +1,51 @@ +# +# Author:: Eric Renfro () +# Recipe:: yum-nux::default +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +node['yum-nux']['repositories'].each do |repo| + next unless node['yum'][repo]['managed'] + include_recipe 'yum-epel' unless run_context.loaded_recipe?('yum-epel') + + 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 + end +end