Skip to content

Commit

Permalink
First pass, time for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
mattray authored and jtimberman committed Apr 20, 2011
1 parent 2571ddd commit 003b329
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 46 deletions.
105 changes: 62 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
Description
===========

Configures various YUM components on Red Hat-like systems. Also includes a LWRP.
Configures various YUM components on Red Hat-like systems. Includes LWRP for managing repositories and their GPG keys.

Based on the work done by Eric Wolfe and Charles Duffy on the yumrepo cookbook. http://github.com/atomic-penguin/cookbooks/tree/yumrepo/yumrepo

Requirements
============
RHEL or CentOS 5.x or newer. It has not been tested on other platforms or earlier versions. RHEL 6 support is untested (testing and patches are welcome).
RHEL, CentOS or Scientific Linux 5.x or newer. It has not been tested on other platforms or earlier versions. RHEL 6 support is untested (testing and patches are welcome).

Recipes
=======
Expand All @@ -14,10 +16,44 @@ default
-------
The default recipe runs `yum update` during the Compile Phase of the Chef run to ensure that the system's package cache is updated with the latest. It is recommended that this recipe appear first in a node's run list (directly or through a role) to ensure that when installing packages, Chef will be able to download the latest version available on the remote YUM repository.

yum
---
Manages the configuration of the `/etc/yum.conf` via attributes.

Resources/Providers
===================

This LWRP provides an easy way to manage additional YUM repositories.
key
---
This LWRP handles importing GPG keys for YUM repositories. Keys can be imported by the `url` parameter or placed in `/etc/pki/rpm-gpg/` by a recipe and then installed with the LWRP without passing the URL.

# Actions
- :add: installs the GPG key into `/etc/pki/rpm-gpg/`
- :remove: removes the GPG key from `/etc/pki/rpm-gpg/`

# Attribute Parameters

- key: name attribute. The name of the GPG key to install.
- url: if the key needs to be downloaded, the URL providing the download.

# Example

``` ruby
# add the Zenoss GPG key
yum_key "RPM-GPG-KEY-zenoss" do
url "http://dev.zenoss.com/yum/RPM-GPG-KEY-zenoss"
action :add
end

# remove Zenoss GPG key
yum_key "RPM-GPG-KEY-zenoss" do
action :remove
end
```

repository
----------
This LWRP provides an easy way to manage additional YUM repositories. GPG keys can be managed with the `key` LWRP.

# Actions

Expand All @@ -27,60 +63,43 @@ This LWRP provides an easy way to manage additional YUM repositories.
# Attribute Parameters

- repo_name: name attribute. The name of the channel to discover
- uri: the base of the Debian distribution
- distribution: this is usually your release's codename...ie something like `karmic`, `lucid` or `maverick`
- components: package groupings..when it doubt use `main`
- deb_src: whether or not to add the repository as a source repo as well
- key_server: the GPG keyserver where the key for the repo should be retrieved
- key: if a `key_server` is provided, this is assumed to be the fingerprint, otherwise it is the URI to the GPG key for the repo
- name. The description of the repository
- url: The URL providing the packages
- mirrorlist: Default is `false`, if `true` the `url` is considered a list of mirrors
- key: Optional, the name of the GPG key file installed by the `key` LWRP.
- enabled: Default is `1`, set to `0` if the repository is disabled.
- type: Optional, alternate type of repository
- bootstrapurl: Optional, bootstrapurl

# Example

# add the Zenoss repo
apt_repository "zenoss" do
uri "http://dev.zenoss.org/deb"
components ["main","stable"]
action :add
end

# add the Nginx PPA; grab key from keyserver
apt_repository "nginx-php" do
uri "http://ppa.launchpad.net/nginx/php5/ubuntu"
distribution node['lsb']['codename']
components ["main"]
keyserver "keyserver.ubuntu.com"
key "C300EE8C"
action :add
end

# add the Cloudkick Repo
apt_repository "cloudkick" do
uri "http://packages.cloudkick.com/ubuntu"
distribution node['lsb']['codename']
components ["main"]
key "http://packages.cloudkick.com/cloudkick.packages.key"
action :add
end

# remove Zenoss repo
apt_repository "zenoss" do
action :remove
end
``` ruby
# add the Zenoss repository
yum_repository "zenoss" do
name "Zenoss Stable repo"
url "http://dev.zenoss.com/yum/stable/"
key "RPM-GPG-KEY-zenoss"
action :add
end

# remove Zenoss repo
yum_repository "zenoss" do
action :remove
end
```

Usage
=====

Put `recipe[yum]` first in the run list to ensure `yum update` is run before other recipes.
Put `recipe[yum]` first in the run list to ensure `yum update` is run before other recipes. You can manage GPG keys either with cookbook_file in a recipe if you want to package it with a cookbook or use the `url` parameter of the `key` LWRP.

License and Author
==================

Author:: Eric G. Wolfe
Author:: Matt Ray (<[email protected]>)
Copyright:: 2010-2011
Author:: Matt Ray (<[email protected]>)
Copyright:: 2011 Opscode, Inc.
Contributor:: Tippr, Inc.
Copyright:: 2011

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
11 changes: 11 additions & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.1"
recipe "yum", "Runs 'yum update' during compile phase"
recipe "yum::yum", "manages yum configuration"

%w{ redhat centos scientific }.each do |os|
supports os, ">= 5"
end

attribute "yum/exclude",
:display_name => "yum.conf exclude",
:description => "List of packages to exclude from updates or installs. This should be a space separated list. Shell globs using wildcards (eg. * and ?) are allowed.",
:required => "optional"

attribute "yum/installonlypkgs",
:display_name => "yum.conf installonlypkgs",
:description => "List of packages that should only ever be installed, never updated. Kernels in particular fall into this category. Defaults to kernel, kernel-smp, kernel-bigmem, kernel-enterprise, kernel-debug, kernel-unsupported.",
:required => "optional"
7 changes: 4 additions & 3 deletions providers/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@
action :add do
unless ::File.exists?("/etc/yum.repos.d/#{new_resource.repo_name}.repo")
Chef::Log.info "Adding #{new_resource.repo_name} repository to /etc/yum.repos.d/#{new_resource.repo_name}.repo"
#import the gpg key
#import the gpg key. If it needs to be downloaded or imported from a cookbook
#that can be done in the calling recipe
if new_resource.key then
yumkey new_resource.key
yum_key new_resource.key
end
#get the metadata
execute "yum -q makecache" do
action :nothing
end
#write out the file
template "/etc/yum.repos.d/#{new_resource.repo_name}.repo" do
source "generic.repo.erb"
source "repo.erb"
variables({
:repo_name => new_resource.repo_name,
:name => new_resouce.name,
Expand Down

0 comments on commit 003b329

Please sign in to comment.