Skip to content

Instantly share code, notes, and snippets.

View sawanoboly's full-sized avatar
🤷‍♂️
🙃

Yukihiko SAWANOBORI sawanoboly

🤷‍♂️
🙃
View GitHub Profile
@sawanoboly
sawanoboly / add_owner_to_ami.sh
Last active August 29, 2015 14:06
Add ownership for AWS MarketPlace to AMI and snapshot.
#!/bin/bash
set -e
## Exit options not passed.
if [ "$1" == "" ];then
cat <<EOL
Add AWS MarketPlase OwnerID to your AMI and Snapshot.
Usage:
add_owner_to_ami.sh AMI_ID [PROFILE_NAME]
@sawanoboly
sawanoboly / smartos.erb
Last active August 29, 2015 14:05
Knife(Opscode Chef) bootstrap template with omnibus chef for joyent smartos.
bash -c '
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
exists() {
if command -v $1 &>/dev/null
then
return 0
else
return 1
fi
@sawanoboly
sawanoboly / Vagrantfile
Last active January 20, 2021 23:52
VagrantでVM起動時に、追加ディスクを作成してアタッチ - VirtualBox Provider ref: http://qiita.com/sawanoboly/items/cbd056252a130a4b961e
# -- snip --
config.vm.define machine do |config|
config.vm.provider :virtualbox do |vb|
at_disk = 'tmp/name_of_file.vdi'
unless File.exists?(at_disk)
vb.customize ['createhd', '--filename', at_disk, '--size', 5 * 1024]
end
vb.customize ['storageattach', :id, '--storagectl', 'IDE Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', at_disk]
end
@sawanoboly
sawanoboly / fluentd.sample.conf
Last active March 22, 2024 04:29
postfix log status line regexp for fluentd(ruby)
<source>
type tail
# format /(?<time>[\w]+\s+[\d]+\s[\d:]+)\s+(?<host>[\w]+)\s+(?<process>[\w\/]+)\[(?<pid>[\d]+)\]\:\s(?<queue_id>[\w]{11}):\s(?<data>.+)/
format /(?<time>[\w]+\s+[\d]+\s[\d:]+)\s+(?<data>.+)/
time_format %b %d %H:%M:%S
path /var/log/mail.log
pos_file /opt/fluentd/tmp/mail.log.pos2
tag raw.postfix.result
</source>
curl -XPUT http://localhost:9200/_template/main_template?pretty -d ' {
"template" : "logstash-*",
"order" : 10,
"settings" : {
"index.number_of_replicas" : 0
},
"mappings" : {
"_default_" : {
"numeric_detection" : true
} }
@sawanoboly
sawanoboly / joyent.rb
Last active August 29, 2015 14:01
Ohai6のプラグインをOhai7のSyntaxに書き直す ref: http://qiita.com/sawanoboly/items/ca225effa6d28912624d
Ohai.plugin(:Joyent) do
%w{ sm_uuid sm_id sm_image sm_image_id sm_image_ver sm_baseimage sm_baseimage_id sm_baseimage_ver sm_pkgsrc }.each do |info|
provides "joyent/#{info}"
end
provides 'virtualization/guest_id'
depends 'os', 'platform', 'virtualization'
def collect_solaris_guestid
command = '/usr/sbin/zoneadm list -p'
@sawanoboly
sawanoboly / chef-apply_stdout
Last active August 29, 2015 14:00
ChefのCronリソースがPredefined scheduling指定に対応した ref: http://qiita.com/sawanoboly/items/570711f1fd19c504474a
$ chef-client -v
Chef: 11.12.4
$ sudo chef-apply cron.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* cron[at_reboot] action create
- add crontab entry for cron[at_reboot]
@sawanoboly
sawanoboly / file3.txt
Last active August 29, 2015 14:00
serverspecとCapybaraを一緒に使う ref: http://qiita.com/sawanoboly/items/ddfcb5cac037c15a4052
# -- snip --
if c.host != host
c.ssh.close if c.ssh
c.host = host
## ここでCapybara.app_hostを設定しちゃう。
Capybara.app_host = "http://#{host}"
options = Net::SSH::Config.for(c.host)
user = options[:user] || Etc.getlogin
c.ssh = Net::SSH.start(host, user, options)
end
@sawanoboly
sawanoboly / file0.txt
Last active August 29, 2015 14:00
Rubyプロジェクトのコンフィグ読み出しでChamberを使ってみた ref: http://qiita.com/sawanoboly/items/47c799fb7390323564ad
require 'chamber'
env_confs = [
File.expand_path('../../config/environment.yml', __FILE__),
File.expand_path('../../config/environment.local.yml', __FILE__)
]
EnvSettings = Chamber.load files: env_confs
app_confs = [
@sawanoboly
sawanoboly / chef-apply
Last active August 29, 2015 13:59
サービス名が不定のデーモンをChefのlazyで遅延処理する ref: http://qiita.com/sawanoboly/items/b7238b97012f2df486cd
# chef-apply test.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* service[test] action nothing (up to date)
* file[/tmp/hoge] action create
- update content in file /tmp/hoge from 2b795c to 04db98
--- /tmp/hoge 2014-04-15 03:13:48.000000000 +0000
+++ /tmp/.hoge20140415-4288-ulgn9f 2014-04-15 03:15:43.000000000 +0000
@@ -1,2 +1,2 @@
-2014-04-15 03:13:48 +0000
+2014-04-15 03:15:43 +0000