forked from chef-boneyard/cookbooks
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RACKSPACE] Added a ghetto-dns setup for Rackspace Cloud
- Loading branch information
Showing
4 changed files
with
91 additions
and
3 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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
maintainer "Example Com" | ||
maintainer_email "ops@example.com" | ||
maintainer "Ho-Sheng Hsiao" | ||
maintainer_email "hosh@sparkfly.com" | ||
license "Apache 2.0" | ||
description "Installs/Configures rackspace" | ||
description "Installs/Configures Rackspace Cloud-specific stuff" | ||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) | ||
version "0.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,54 @@ | ||
# | ||
# Cookbook Name:: rackspace | ||
# Recipe:: hosts | ||
# | ||
# Copyright 2010, Sparkfly | ||
# Modified from: http://blog.bitfluent.com/post/196658820/using-chef-server-indexes-as-a-simple-dns | ||
# Copyright 2009, Bitfluent | ||
# | ||
# 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. | ||
# | ||
|
||
global_hosts = {} | ||
hosts = {} | ||
|
||
data_bag('cloud-hosts').each do |host| | ||
n = data_bag_item('cloud-hosts', host) | ||
global_hosts[n['ip']] = host | ||
end | ||
|
||
# NOTE: According to the 0.8 source code, there is a default row limit of 20. If the interface (via Couchdb) is what | ||
# I think it is, then this will turn into a sleeping defect. We should be using djdns or PowerDNS by that point | ||
|
||
# Structure: | ||
# network | ||
# interfaces | ||
# eth1 | ||
# addresses | ||
# locallink | ||
# ipv4 addr | ||
# addr | ||
# netmask | ||
# ... | ||
# ipv6 addr | ||
search(:node, "network_interfaces_eth1_addresses:172.*") do |n| | ||
addresses = n['network']['interfaces']['eth1']['addresses'].map { |addr| addr[0] } | ||
ip = addresses.select { |addr| addr.to_s =~ /172.*/ }.first | ||
hosts[ip] = n | ||
end | ||
|
||
template "/etc/hosts" do | ||
source "hosts.erb" | ||
mode 0644 | ||
variables(:global_hosts => global_hosts, :hosts => hosts) | ||
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,15 @@ | ||
# Ghetto DNS | ||
# Auto-generated by chef for <%= @node[:fqdn] %> | ||
|
||
127.0.0.1 localhost | ||
::1 localhost | ||
|
||
# Site-wide hosts | ||
<% @global_hosts.keys.sort.each do |ip| %> | ||
<%= ip %> <%= @global_hosts[ip] %> | ||
<% end %> | ||
|
||
# Private IP nodes | ||
<% @hosts.keys.sort.each do |ip| %> | ||
<%= ip %> <%= @hosts[ip]["fqdn"] %> <%= (@hosts[ip]["dns_aliases"] || []).sort.join(" ") %> | ||
<% end %> |