This repository has been archived by the owner on Aug 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
root
committed
Aug 24, 2013
1 parent
00bd849
commit 4f54754
Showing
6 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Description | ||
=========== | ||
|
||
Updates Amazon Web Service's Route 53 (DNS) service. | ||
|
||
Requirements | ||
============ | ||
|
||
An Amazon Web Services account and a Route 53 zone. | ||
|
||
Usage | ||
===== | ||
|
||
```ruby | ||
include_recipe "route53" | ||
|
||
route53_record "create a record" do | ||
name "test" | ||
value "16.8.4.2" | ||
type "A" | ||
|
||
zone_id node[:route53][:zone_id] | ||
aws_access_key_id node[:route53][:aws_access_key_id] | ||
aws_secret_access_key node[:route53][:aws_secret_access_key] | ||
|
||
action :create | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "route53", | ||
"description": "Installs/Configures route53", | ||
"long_description": "Description\n===========\n\nUpdates Amazon Web Service's Route 53 (DNS) service.\n\nRequirements\n============\n\nAn Amazon Web Services account and a Route 53 zone.\n\nUsage\n=====\n\n```ruby\ninclude_recipe \"route53\"\n\nroute53_record \"create a record\" do\n name \"test\"\n value \"16.8.4.2\"\n type \"A\"\n\n zone_id node[:route53][:zone_id]\n aws_access_key_id node[:route53][:aws_access_key_id]\n aws_secret_access_key node[:route53][:aws_secret_access_key]\n\n action :create\nend\n```\n", | ||
"maintainer": "Heavy Water Ops, LLC.", | ||
"maintainer_email": "support@hw-ops.com", | ||
"license": "Apache 2.0", | ||
"platforms": { | ||
}, | ||
"dependencies": { | ||
}, | ||
"recommendations": { | ||
}, | ||
"suggestions": { | ||
}, | ||
"conflicting": { | ||
}, | ||
"providing": { | ||
}, | ||
"replacing": { | ||
}, | ||
"attributes": { | ||
}, | ||
"groupings": { | ||
}, | ||
"recipes": { | ||
}, | ||
"version": "0.3.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name "route53" | ||
maintainer "Heavy Water Ops, LLC." | ||
maintainer_email "support@hw-ops.com" | ||
license "Apache 2.0" | ||
description "Installs/Configures route53" | ||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) | ||
version "0.3.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
action :create do | ||
require "fog" | ||
require "nokogiri" | ||
|
||
def name | ||
@name ||= new_resource.name + "." | ||
end | ||
|
||
def value | ||
@value ||= new_resource.value | ||
end | ||
|
||
def type | ||
@type ||= new_resource.type | ||
end | ||
|
||
def ttl | ||
@ttl ||= new_resource.ttl | ||
end | ||
|
||
def zone | ||
@zone ||= Fog::DNS.new({ :provider => "aws", | ||
:aws_access_key_id => new_resource.aws_access_key_id, | ||
:aws_secret_access_key => new_resource.aws_secret_access_key } | ||
).zones.get( new_resource.zone_id ) | ||
end | ||
|
||
def create | ||
begin | ||
zone.records.create({ :name => name, | ||
:value => value, | ||
:type => type, | ||
:ttl => ttl }) | ||
rescue Excon::Errors::BadRequest => e | ||
Chef::Log.info Nokogiri::XML( e.response.body ).xpath( "//xmlns:Message" ).text | ||
end | ||
end | ||
|
||
record = zone.records.get(name, type) | ||
|
||
if record.nil? | ||
create | ||
Chef::Log.info "Record created: #{name}" | ||
elsif value != record.value.first | ||
record.destroy | ||
create | ||
Chef::Log.info "Record modified: #{name}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# | ||
# Cookbook Name:: route53 | ||
# Recipe:: default | ||
# | ||
# Copyright 2011, Heavy Water Software Inc. | ||
# | ||
# 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. | ||
# | ||
|
||
xml = package "libxml2-dev" do | ||
action :nothing | ||
end | ||
xml.run_action( :install ) | ||
|
||
xslt = package "libxslt1-dev" do | ||
action :nothing | ||
end | ||
xslt.run_action( :install ) | ||
|
||
fog = gem_package "fog" do | ||
action :nothing | ||
end | ||
fog.run_action( :install ) | ||
|
||
require 'rubygems' | ||
Gem.clear_paths |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
actions :create | ||
|
||
attribute :name, :kind_of => String | ||
attribute :value, :kind_of => String | ||
attribute :type, :kind_of => String | ||
attribute :ttl, :kind_of => Integer, :default => 3600 | ||
attribute :zone_id, :kind_of => String | ||
attribute :aws_access_key_id, :kind_of => String | ||
attribute :aws_secret_access_key, :kind_of => String |