Initial release

This commit is contained in:
Eric Renfro 2016-07-18 15:54:05 -04:00
commit 79b7ef5294
8 changed files with 273 additions and 0 deletions

6
Berksfile Normal file
View File

@ -0,0 +1,6 @@
source "https://supermarket.chef.io"
metadata
cookbook "apt", "~> 3.0.0"

14
Berksfile.lock Normal file
View File

@ -0,0 +1,14 @@
DEPENDENCIES
yum (~> 3.10.0)
yum-epel (~> 0.6.6)
yum-zabbix
path: .
metadata: true
GRAPH
yum (3.10.0)
yum-epel (0.6.6)
yum (~> 3.10.0)
yum-zabbix (0.1.0)
yum (>= 3.2.0)
yum-epel (>= 0.0.0)

5
CHANGELOG.md Normal file
View File

@ -0,0 +1,5 @@
# apt-zabbix Cookbook CHANGELOG
This file is used to list changes made in each version of the apt-zabbix cookbook.
## v0.1.0
initial release

110
README.md Normal file
View File

@ -0,0 +1,110 @@
apt-zabbix Cookbook
====================
Installs/Configures apt Zabbix Vendor-Specific Repositories.
This cookbook installs & configures apt Zabbix repositories pe
http://repo.zabbix.com/
Requirements
------------
- Chef 11 or higher
- Ruby 1.9 or higher (preferably from the Chef full-stack-installer)
- Network accessible package repositories
- Debian 7 or newer.
- [apt Cookbook](https://supermarket.chec.io/cookbooks/apt)
Attributes
----------
#### apt-zabbix::default
The following attributes are set by default
```ruby
default['yum']['zabbix']['repositoryid'] = 'zabbix'
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']['description'] = 'Zabbix Official Repository - $basearch'
default['yum']['zabbix']['baseurl'] = 'http://repo.zabbix.com/zabbix/3.0/rhel/6/$basearch'
```
```ruby
default['yum']['zabbix-non-supported']['repositoryid'] = 'zabbix-non-supported'
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 non-supported - $basearch'
default['yum']['zabbix-non-supported']['baseurl'] = 'http://repo.zabbix.com/non-supported/rhel/6/$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 'zabbix' do
baseurl 'http://repo.zabbix.com/zabbix/3.0/rhel/6/$basearch/'
description 'Zabbix Official Repository - $basearch'
enabled true
gpgcheck true
gpgkey 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX'
end
```
## Usage Example
To disable the `zabbix` repository through a Role or Environment definition
```
default_attributes(
'yum' => {
'zabbix' => {
'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 `zabbix-non-supported` repository with a wrapper cookbook, place the following in a recipe:
```
node.default['yum']['zabbix-non-supported']['managed'] = true
node.default['yum']['zabbix-non-supported']['enabled'] = true
include_recipe 'yum-zabbix'
```
## More Examples
Point the base and debuginfo repositories at an internally hosted server.
```
node.default['yum']['zabbix']['enabled'] = true
node.default['yum']['zabbix']['baseurl'] = 'https://internal.example.com/centos/6/os/x86_64'
node.default['yum']['zabbix']['sslverify'] = false
node.default['yum']['zabbix-non-supported']['enabled'] = true
node.default['yum']['zabbix-non-supported']['baseurl'] = 'https://internal.example.com/centos/6/updates/x86_64'
node.default['yum']['zabbix-non-supported']['sslverify'] = false
include_recipe 'yum-zabbix'
```
## License & Authors
**Author:** Eric Renfro (<psi-jack@linux-help.org>)
**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.
```

46
attributes/default.rb Normal file
View File

@ -0,0 +1,46 @@
#
# Cookbook Name:: apt-zabbix
# Attributes:: default
#
# Debian-ish platform support for this cookbook and the Zabbix repository.
# Designed to be a private attribute however it can be overridden in the case
# Zabbix supports additional platforms and this cookbook has not been updated
# yet.
#
# This check was implemented as a result of the repo could be successfully
# installed yet not be valid for a given platform and an Zabbix package could
# be successfully installed as a result of it being available natively on the
# platform it which it was run which results in a false positive for the
# consumer of the cookbook.
#
# The hash key is the codename of the OS/version. If the hash value evaluates
# to true, the OS/version is considered supported.
default['apt-zabbix']['debian']['supported-codenames'] = {
wheezy: true, # Debian 7.x
jessie: true # Debian 8.x
}
default['apt-zabbix']['release_repo'] = '3.0'
codename = node['lsb']['codename']
default['apt-zabbix']['repos'].tap do |repo|
repo['zabbix'].tap do |value|
# Does this cookbook manage the install of the repo?
value['managed'] = true
# Set the repo name
value['repo_name'] = 'zabbix'
# URI of Repo
value['uri'] = "http://repo.zabbix.com/zabbix/#{node['apt-zabbix']['release_repo']}/debian"
# Package distribution of repo
value['distribution'] = codename
# Repo Package Groupings
value['components'] = ['main']
# Cookbook File For Signing Key
value['key'] = 'zabbix-official-repo.key'
# Whether or not to include the repo source repo
value['deb-src'] = false
end
end

View File

@ -0,0 +1,24 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.5 (GNU/Linux)
mQGiBFCNJaYRBAC4nIW8o2NyOIswb82Xn3AYSMUcNZuKB2fMtpu0WxSXIRiX2BwC
YXx8cIEQVYtLRBL5o0JdmoNCjW6jd5fOVem3EmOcPksvzzRWonIgFHf4EI2n1KJc
JXX/nDC+eoh5xW35mRNFN/BEJHxxiRGGbp2MCnApwgrZLhOujaCGAwavGwCgiG4D
wKMZ4xX6Y2Gv3MSuzMIT0bcEAKYn3WohS+udp0yC3FHDj+oxfuHpklu1xuI3y6ha
402aEFahNi3wr316ukgdPAYLbpz76ivoouTJ/U2MqbNLjAspDvlnHXXyqPM5GC6K
jtXPqNrRMUCrwisoAhorGUg/+S5pyXwsWcJ6EKmA80pR9HO+TbsELE5bGe/oc238
t/2oBAC3zcQ46wPvXpMCNFb+ED71qDOlnDYaaAPbjgkvnp+WN6nZFFyevjx180Kw
qWOLnlNP6JOuFW27MP75MDPDpbAAOVENp6qnuW9dxXTN80YpPLKUxrQS8vWPnzkY
WtUfF75pEOACFVTgXIqEgW0E6oww2HJi9zF5fS8IlFHJztNYtbQgWmFiYml4IFNJ
QSA8cGFja2FnZXJAemFiYml4LmNvbT6IYAQTEQIAIAUCUI0lpgIbAwYLCQgHAwIE
FQIIAwQWAgMBAh4BAheAAAoJENE9WOR56l7UhUwAmgIGZ39U6D2w2oIWDD8m7KV3
oI06AJ9EnOxMMlxEjTkt9lEvGhEX1bEh7bkBDQRQjSWmEAQAqx+ecOzBbhqMq5hU
l39cJ6l4aocz6EZ9mSSoF/g+HFz6WYnPAfRaYyfLmZdtF5rGBDD4ysalYG5yD59R
Mv5tNVf/CEx+JAPMhp6JCBkGRaH+xHws4eBPGkea4rGNVP3L3rA7g+c1YXZICGRI
OOH7CIzIZ/w6aFGsPp7xM35ogncAAwUD/3s8Nc1OLDy81DC6rGpxfEURd5pvd/j0
D5Di0WSBEcHXp5nThDz6ro/Vr0/FVIBtT97tmBHX27yBS3PqxxNRIjZ0GSWQqdws
Q8o3YT+RHjBugXn8CzTOvIn+2QNMA8EtGIZPpCblJv8q6MFPi9m7avQxguMqufgg
fAk7377Rt9RqiEkEGBECAAkFAlCNJaYCGwwACgkQ0T1Y5HnqXtQx4wCfcJZINKVq
kQIoV3KTQAIzr6IvbZoAn12XXt4GP89xHuzPDZ86YJVAgnfK
=+200
-----END PGP PUBLIC KEY BLOCK-----

16
metadata.rb Normal file
View File

@ -0,0 +1,16 @@
name 'apt-zabbix'
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'
issues_url 'http://gogs.home.ld/Linux-Help/cookbook-apt-zabbix/issues'
source_url 'http://gogs.home.ld/Linux-Help/cookbook-apt-zabbix'
%w{ debian }.each do |os|
supports os, '>= 5.0'
end
depends 'apt', '>= 3.0'

52
recipes/default.rb Normal file
View File

@ -0,0 +1,52 @@
#
# Author:: Eric Renfro (<psi-jack@linux-help.org>)
# Recipe:: apt-zabbix::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.
# check if platform is supported
platform_family = node['platform_family']
platform = node['platform']
platform_version = node['platform_version']
fail("#{platform_family}/#{platform}/#{platform_version} is not supported by the default recipe") \
unless platform_family?('debian') &&
node['apt-zabbix']['debian']['supported-codenames']
.select { |_version, is_included| is_included }
.keys
.include?(node['lsb']['codename'])
node['apt-zabbix']['repos'].each do |repo, value|
apt_repository repo do
# define all attributes even though we are not using them all so that the
# values can be passed through to override apt repository definitions
# Attribute Sources:
# https://github.com/opscode-cookbooks/apt
# https://github.com/opscode-cookbooks/apt/blob/master/resources/repository.rb
repo_name value['repo_name'] unless value['repo_name'].nil?
uri value['uri'] unless value['uri'].nil?
distribution value['distribution'] unless value['distribution'].nil?
components value['components'] unless value['components'].nil?
arch value['arch'] unless value['arch'].nil?
trusted value['trusted'] unless value['trusted'].nil?
deb_src value['deb-src'] unless value['deb-src'].nil?
keyserver value['keyserver'] unless value['keyserver'].nil?
key value['key'] unless value['key'].nil?
key_proxy value['key_proxy'] unless value['key_proxy'].nil?
cookbook value['cookbook'] unless value['cookbook'].nil?
cache_rebuild value['cache_rebuild'] unless value['cache_rebuild'].nil?
end if value['managed']
end