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
define :generate_ssh_keys, :user_account => nil do | |
username = params[:user_account] | |
raise ":user_account should be provided." if username.nil? | |
Chef::Log.debug("generate ssh skys for #{username}.") | |
execute "generate ssh skys for #{username}." do | |
user username | |
creates "/home/#{username}/.ssh/id_rsa.pub" |
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
#!/bin/bash | |
echo $AWS_ACCOUNT >> /tmp/cred.txt | |
echo $AWS_ACCESS_KEY_ID >> /tmp/cred.txt | |
echo $AWS_SECRET_ACCESS_KEY >> /tmp/cred.txt |
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
seed_hosts = rightscale_server_collection "seed_hosts" do | |
tags ["cassandra:seed_host=true"] | |
mandatory_tags ["server:private_ip_0"] | |
empty_ok false | |
action :nothing | |
end | |
seed_hosts.run_action(:load) | |
seed_ips = Array.new |
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
#!/usr/bin/env python | |
import boto | |
s3 = boto.connect_s3() | |
b = s3.lookup('BUCKET_NAME_HERE') | |
[x.change_storage_class('REDUCED_REDUNDANCY') for x in b.get_all_keys()] |
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
#!/usr/bin/env ruby | |
require 'highline/import' | |
attr = ask "attribute: " | |
desc = ask "description: " | |
recipes = ask "recipes: " | |
type = ask ("type: ") { |q| q.default = "string" } | |
disp = ask ("display_name: ") { |q| q.default = attr } | |
required = ask ("required: ") { |q| q.default = "required" } |
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
bash "download_rpm" do | |
code <<-EOM | |
export STORAGE_ACCOUNT_ID="#{node[:smartfox][:storage_account_id]}" | |
export STORAGE_ACCOUNT_SECRET="#{node[:smartfox][:storage_account_secret]}" | |
/opt/rightscale/sandbox/bin/ros_util get -c "#{node[:smartfox][:bucket]}" -s "#{node[:smartfox][:file]}" -C "#{node[:smartfox][:provider]}" -d "#{Chef::Config[:file_cache_path]}/#{node[:smartfox][:file].split('/').last}" | |
EOM | |
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
log "PUBLIC IP: #{node[:cloud][:public_ips][0]}\n" | |
log "PRIVATE IP: #{node[:cloud][:private_ips[0]}\n" |
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
# Obtain information about Jenkins master by querying for its tags | |
r = rightscale_server_collection "master_server" do | |
tags "jenkins:master=true" | |
mandatory_tags "jenkins:active=true" | |
action :nothing | |
end | |
r.run_action(:load) | |
master_ip = "" | |
master_port = "" |
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
#!/usr/bin/env python | |
import boto | |
s3 = boto.connect_s3() | |
bucket = s3.get_bucket("bucket") | |
rs = bucket.list(prefix="key/prefix/here") | |
result = bucket.delete_keys([key.name for key in rs]) |
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
# In Chef, when a resource is defined all its variables are evaluated during | |
# compile time and the execution of the resource takes place in converge phase. | |
# So if the value of a particular attribute is changed in converge | |
# (and not in compile) the resource will be executed with the old value. | |
# Example problem: | |
# Let's consider this situation where there are two steps involved in a recipe | |
# Step 1 is a Ruby block that changes a node attribute. Rubyblocks get executed | |
# in converge phase | |
# Step 2 is a Chef resource that makes use of the node attribute that was |
OlderNewer