Skip to content

Instantly share code, notes, and snippets.

@Maniacal
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Maniacal/6b02ba33b0580530a631 to your computer and use it in GitHub Desktop.
Save Maniacal/6b02ba33b0580530a631 to your computer and use it in GitHub Desktop.
vagrant@member-1-ubuntu-1404:~$ cat /tmp/kitchen/nodes/member-0.json
{
"id": "member-0",
"automatic": {
"ipaddress": "192.168.50.100"
},
"default": {
"pds_cassandra": {
"cluster_name": "ds-ts-cassandra"
}
},
"normal": {
"tags": [
"seed_node"
]
}
}
##### .kitchen.yml
---
driver:
name: vagrant
synced_folders:
- ["test/local_files", "/tmp/local_files", "create: true"]
customize:
memory: 1024
provisioner:
name: chef_zero
platforms:
- name: ubuntu-14.04
suites:
<% 3.times do |x| %>
- name: member-<%= x %>
run_list:
- recipe[apt]
- recipe[pds_cassandra_test]
- recipe[pds_cassandra]
attributes:
<% if x == 0 %>
tags:
- seed_node
<% end %>
pds_cassandra:
download_url: "file:///tmp/local_files/%{package}"
driver:
network:
- ['private_network', {ip: "192.168.50.10<%= x %>"}]
<% end %>
####### libraries/cassandra.rb
require 'set'
# Module to hold helper methods for Cassandra setup
module PdsCassandra
def cassandra_seeds
nodes = search(
#:node, "pds_cassandra_cluster_name:#{node['pds_cassandra']['cluster_name']} AND tags:'seed_node'"
:node, "pds_cassandra_cluster_name:#{node['pds_cassandra']['cluster_name']}"
)
seeds = Set.new
nodes.each do |data|
seeds.merge([data['ipaddress']])
end
seeds.merge([node['ipaddress']]) if node['tags'].include?('seed_node')
seeds.to_a
end
Chef::Resource::Template.send :include, self
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment