LoginSignup
6
6

More than 5 years have passed since last update.

mitamaeが俺の求めていたさいつよのプロビジョニングツールじゃないかというはなし

Last updated at Posted at 2017-12-22

俺です。

さーばーちゃんたちのプロビジョニングがつらい季節になりました。
脳筋->chef->ansible->itamae->脳筋と輪廻転生を繰り返しています。

しょーもない理由で結局脳筋に戻ってしまっているのですが
やっぱりシェルコマンド並べて手順なり脳筋スクリプト作るのはしんどいので
使い捨て利用でいける、それなりに回せてgolangバイナリのようなポイーで導入できるカジュアルなプロビジョニングツールないかなーって探してたら
あるじゃないですかー mruby製itamae mitamaeが!!

最高アンドさいつよの予感がしたので使ってみます。

しょーもない俺のプロビジョニングツール死亡履歴

2012 - 2017ぐらい.

  • 脳筋時代: tmux synchronize-panes 最高だけど度重なるッターン!!がつらくて死んだ
  • chef: 猿だからchef-clientのバージョン管理できてなくて死んだ.chef-zeroさいつよだった
  • ansible: おせえしmysqlモジュールなど使おうとするとtargetにlibraryいれなきゃだしループ構造とかyamlで表現って無理があるよねってかwindows moduleがps1叩いてるだけだしエラーハンドリングできてないのがわかって辛くなって死んだ
  • itamae: itamae local最高。でもinstallだるい.カジュアルに動かしたいだけでrbenvするのもなあって思って死んだ

とまあなさけない俺の死亡履歴はどうでもいいので使ってみましょー

対象package:version

mitamae: v1.5.2

インストール

github.comのreleasesから直接持ってきてますが、俺俺repoか俺俺S3に置いときましょう。

$ wget https://github.com/itamae-kitchen/mitamae/releases/download/v1.5.2/mitamae-x86_64-linux                           

recipeを書く

ディレクトリ/ファイル構成

current
|- recipe.rb
|- templates/tmp/unko.erb

recipe.rb

よくつかいそうなresourceを書き連ねてみます。

# mitamae saikou recipe
%w[
mlocate
tree
htop
git
sysstat
dstat
nginx
gcc
].each do |pkg|
  package "#{pkg}" do
    action :install
  end
end

execute "mlocate"

service "nginx" do
  action [:start,:enable]
end

directory "/tmp/filetouch"

file "/tmp/filetouch/unko" do
  owner "root"
  mode "0600"
  content "moresou"
end

%w[
taro
jiro
saburo
panda
].each do |user|
  user "#{user}" do
    action :create
  end
end

template "/tmp/unko" do
  owner "root"
  group "root"
  mode "0644"
  source "templates/tmp/unko.erb"
  variables(buriburibichaa: "ブリブリビチャァ")
end

templates/tmp/unko.erb

変数使えるはずー

uwaaaaaa...... <%= @buriburibichaa %>

実行

$  sudo ./mitamae-x86_64-linux local recipe.rb                                                                            [15:24:49]
[sudo] password for ore:
 INFO : Starting MItamae...
 INFO : Recipe: /home/ore/recipe.rb
 INFO :   package[tree] installed will change from 'false' to 'true'
 INFO :   package[htop] installed will change from 'false' to 'true'
 INFO :   package[git] installed will change from 'false' to 'true'
 INFO :   package[sysstat] installed will change from 'false' to 'true'
 INFO :   package[dstat] installed will change from 'false' to 'true'
 INFO :   package[nginx] installed will change from 'false' to 'true'
 INFO :   package[gcc] installed will change from 'false' to 'true'
 INFO :   execute[updatedb] executed will change from 'false' to 'true'
 INFO :   service[nginx] running will change from 'false' to 'true'
 INFO :   service[nginx] enabled will change from 'false' to 'true'
 INFO :   directory[/tmp/filetouch] exist will change from 'false' to 'true'
 INFO :   file[/tmp/filetouch/unko] exist will change from 'false' to 'true'
 INFO :   file[/tmp/filetouch/unko] mode will be '0600'
 INFO :   file[/tmp/filetouch/unko] owner will be 'root'
 INFO :   diff:
 INFO :   --- /dev/null 2017-12-22 07:01:40.926087713 +0000
 INFO :   +++ /tmp/1513956356.6784  2017-12-22 15:25:56.676661319 +0000
 INFO :   @@ -0,0 +1 @@
 INFO :   +moresou
 INFO :   \ No newline at end of file
 INFO :   template[/tmp/unko] exist will change from 'false' to 'true'
 INFO :   template[/tmp/unko] mode will be '0644'
 INFO :   template[/tmp/unko] owner will be 'root'
 INFO :   template[/tmp/unko] group will be 'root'
 INFO :   diff:
 INFO :   --- /dev/null 2017-12-22 07:01:40.926087713 +0000
 INFO :   +++ /tmp/1513956356.686   2017-12-22 15:25:56.684661006 +0000
 INFO :   @@ -0,0 +1 @@
 INFO :   +uwaaaaaa...... ブリブリビチャァ

漏れてしまったようです。

$  cat /tmp/unko                                                                                                         
uwaaaaaa...... ブリブリビチャァ

さーてためている脳筋工程を移植しよう。

最高!

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6