Skip to content

Instantly share code, notes, and snippets.

#!/usr/local/bin/ruby
require 'AWS'
require 'yaml'
class SnapshotManagement
# initalize class, optional override path to yml file
# * options [String] :path ('')
#
def initialize(params = {})
# Create 4 volumes and attach them to hdb
%w[sdi sdj sdk sdl].each do |dev|
volume = AWS.volumes.new :device => "/dev/#{dev}", :size => 5, :availability_zone => hdb.availability_zone
volume.server = hdb
volume.save
end
# -*- coding: utf-8 -*-
require 'rubygems'
require 'aws-sdk'
## アクセスIDとシークレットアクセスキーを指定します
ACCESS_KEY = 'SET UP YOUR ACCESS KEY'
SECRET_KEY = 'SET UP YOUR SECRET KEY'
## 引数チェック
unless ARGV.size == 4
@actionjack
actionjack / gist:6636642
Created September 20, 2013 12:20
AWS-SDK and Fog differences
snapshot_ids.each do |snapshot_id|
AWS.config(:access_key_id => 'AAAAAAAAAAAAAAAAAA', :secret_access_key => 'aaaaaaaaaaaaaaaaaaaa', :region => 'eu-west-1')
ec2 = AWS::EC2.new
current_snap1 = ec2.snapshots[snapshot_id].status
current_snap = Fog::Compute.new({:provider => 'AWS', :region => 'eu-west-1'}).snapshots.all('snapshot-id' => snapshot_id)
p "Snapshot id is #{snapshot_id}"
p current_snap1
p ec2.snapshots[snapshot_id].progress
@actionjack
actionjack / gist:6931942
Created October 11, 2013 09:19
Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type with puppetlabs / puppetlabs-postgresql module
test.pp:
$db = 'postgresql_test_db'
class { 'postgresql::server': }
postgresql::server::db { $db:
user => $db,
password => postgresql_password($db, $db),}
When executed:
## Server configuration for nginx to host Atlassian Jira / Jetbrain TeamCity or any other Tomcat web application
#
# author cedric.walter, www.waltercedric.com
# to be saved for ex in /etc/nginx/sites-available/example
server {
listen 80;
server_name jira.example.com;
access_log off;
location / {
description "Mailcatcher"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
pre-start script
bash << "EOF"
mkdir -p /var/log/mailcatcher
description "Mailcatcher"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
pre-start script
bash << "EOF"
mkdir -p /var/log/mailcatcher
description "Tomcat Server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
# run as non privileged user
# add user with this command:
## adduser --system --ingroup www-data --home /opt/apache-tomcat apache-tomcat
description "Tomcat Server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
# run as non privileged user
# add user with this command:
## adduser --system --ingroup www-data --home /opt/apache-tomcat apache-tomcat