Skip to content

Instantly share code, notes, and snippets.

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

Yukihiko SAWANOBORI sawanoboly

🤷‍♂️
🙃
View GitHub Profile
@sawanoboly
sawanoboly / Pry_Console
Last active August 29, 2015 13:57
Chefの`shell_out`と`shell_out!`、違いと使い分け ref: http://qiita.com/sawanoboly/items/43bc9e15739355f9c533
> result = shell_out!('ps | grep hogehgoe')
Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of ps | grep hogehgoe ----
STDOUT:
STDERR:
---- End output of ps | grep hogehgoe ----
Ran ps | grep hogehgoe returned 1
from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.2.0/lib/mixlib/shellout.rb:251:in `invalid!'
@sawanoboly
sawanoboly / apt-get_with_grub-pc.sh
Created March 28, 2014 09:43
apt-get -y upgrade without a grub-pc config prompt.
apt-get -y update
apt-get -y install debconf-utils
cat <<EOL | debconf-set-selections
grub-pc grub-pc/install_devices multiselect /dev/vda
grub-pc grub-pc/install_devices_empty boolean false
EOL
apt-get -y upgrade
@sawanoboly
sawanoboly / Rakefile
Created March 5, 2014 08:22
Rakefile for vagrant_with_chefzero_example
task :default => 'upload'
$stdin.sync = true
desc 'upload chef-repos to chefzero vm'
task :upload do
system('knife cookbook upload --all')
system('knife upload environments/ ')
system('knife upload roles/ ')
end
@sawanoboly
sawanoboly / 0.8.12_smartos.patch
Last active April 7, 2017 20:11
fail2ban for SmartOS patch
diff --git a/config/action.d/ipfilter.conf b/config/action.d/ipfilter.conf
index 61420e3..091c92d 100644
--- a/config/action.d/ipfilter.conf
+++ b/config/action.d/ipfilter.conf
@@ -13,14 +13,14 @@
# Values: CMD
#
# enable IPF if not already enabled
-actionstart = /sbin/ipf -E
+actionstart = /usr/sbin/ipf -E
@sawanoboly
sawanoboly / app.rb
Last active December 31, 2015 17:39
Settingslogicを使ってconfig.yml, config.local.yml運用してみる ref: http://qiita.com/sawanoboly/items/1d776006ed24513e1b55
require 'settingslogic'
class EnvSettings < Settingslogic
source File.expand_path('../config.yml', __FILE__)
end
if File.exist?(File.expand_path('../config.local.yml', __FILE__))
class EnvLocalSettings < Settingslogic
source File.expand_path('../config.local.yml', __FILE__)
end
@sawanoboly
sawanoboly / .travis.yml
Last active December 31, 2015 17:29
Circle CIで複数Rubyバージョンを平行してテストする ref: http://qiita.com/sawanoboly/items/bd7c12258fe9f29646d5
rvm:
- 2.0.0
- 1.9.3
@sawanoboly
sawanoboly / .travis.yml
Last active December 31, 2015 09:59
Travis-CIのビルドをherokuから繰り返し実行する ref: http://qiita.com/sawanoboly/items/7f275e20fb6a643a3553
script: "./test.sh"
@sawanoboly
sawanoboly / file0.txt
Last active December 31, 2015 02:49
CurlでGithub(Private)のrawが使えなくなったので対案 ref: http://qiita.com/sawanoboly/items/39abb46bc93b94b7ef87
curl -s -f -L -u 'LOGIN_NAME/token:API_TOKEN' https://raw.github.com/ORG_NAME/REPO_NAME/master/README.md
@sawanoboly
sawanoboly / client.rb
Created December 4, 2013 08:09
chef-client log to syslog (chef-client '~> 11.4')
require 'syslog-logger'
Logger::Syslog.class_eval do
attr_accessor :sync, :formatter, :close
def write(msg)
data = msg.match(/(\[.+?\]) ([\w]+):(.*)$/)
self.send(data[2].downcase.to_sym, data[3])
end
end
@sawanoboly
sawanoboly / solo_with_chef_eventdispatcher.rb
Last active December 29, 2015 23:58
Sample: Chef::EventDispatch::Irchandler
class Chef::EventDispatch::Irchandler
require 'carrier-pigeon'
def initialize
@ohai = Ohai::System.new
@ohai._require_plugin('os')
@ohai._require_plugin('hostname')
end
def method_missing(*args)
line = [@ohai.fqdn, args].flatten.join(':')