Itamae | Definitions で 板前によるパッケージインストール機能にトイレ操作機能を統合し、木とSLと乳牛を調達する #devops #itamae

More than 3 years have passed since last update.


Itamae | Definitions で 板前によるパッケージインストール機能にトイレ操作機能を統合し、木とSLと乳牛を調達する #devops #itamae


概要

プロビジョニングツール Itamae

Definitions を利用して、組み込み機能の package と

resource plugin を利用して作成した toilet を統合した機能を追加します。

追加した機能で、 木( tree )とSL( sl )と乳牛 ( cowsay ) をインストールします

※toilet コマンドについては下記リンク参照

http://www.tecmint.com/20-funny-commands-of-linux-or-linux-is-fun-in-terminal/

※sl コマンドについては下記リンク参照

http://ja.wikipedia.org/wiki/Sl_(UNIX)

※cowsay コマンドについては下記リンク参照

http://ja.wikipedia.org/wiki/Cowsay


前提


試行


仕様


  • package_with_toilet を利用すると、インストールと同時に toilet の機能を利用したログを出力する


レシピを作成

require 'itamae'

require 'itamae/plugin/resource/toilet'

define :package_with_toilet, filters: [] do
name = params[:name]
package name do
action :install
end

filters_value = params[:filters]
toilet name do
filters filters_value
end
end

package_with_toilet 'tree' do
filters ['gay']
end

package_with_toilet 'sl' do
filters ['gay', 'flip']
end

package_with_toilet 'cowsay' do
filters ['gay', 'border']
end


Gemfile を作成

source 'http://your_gem_server:your_port/'

gem 'itamae'
gem 'itamae-plugin-resource-toilet'

# geminabox(private gem server) から itamae-plugin-resource-toilet を install

$ bundle install
$ gem list | grep itamae
itamae (1.0.1)
itamae-plugin-resource-toilet (0.0.1)


実行

※実行前に toilet はインストール済みとする

$ tree -L 1

.
┣ Gemfile
┣ Gemfile.lock
┣ recipe.rb
┗ Vagrantfile

$ sudo bundle exec itamae local recipe.rb
INFO : Starting Itamae...
INFO : Recipe: /home/vagrant/definitions_test/recipe.rb
INFO : package_with_toilet[tree]
INFO : action: run
INFO : package[tree]
INFO : action: install
INFO : installed will change from 'false' to 'true'
INFO : toilet[tree]
INFO : action: run
INFO :
m
mm#mm m mm mmm mmm
# #" " #" # #" #
# # #"""" #""""
"mm # "#mm" "#mm"
INFO : package_with_toilet[sl]
INFO : action: run
INFO : package[sl]
INFO : action: install
INFO : installed will change from 'false' to 'true'
INFO : toilet[sl]
INFO : action: run
INFO :
#""
# mmm
# " #
# m"""
mm" "mmm"
INFO : package_with_toilet[cowsay]
INFO : action: run
INFO : package[cowsay]
INFO : action: install
INFO : installed will change from 'false' to 'true'
INFO : toilet[cowsay]
INFO : action: run
INFO :
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x x
x x
x mmm mmm m m mmm mmm m m x
x #" " #" "# "m m m" # " " # "m m" x
x # # # #m#m# """m m"""# #m# x
x "#mm" "#m#" # # "mmm" "mm"# "# x
x m" x
x "" x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

itamae_definitions.png


tree の動作確認

$ which tree

/usr/bin/tree
$ tree
.
|-- Gemfile
|-- Gemfile.lock
`-- recipe.rb


sl の動作確認

※実際は動きます

$ which sl

/usr/games/sl
$ sl -l
(@@) ( ) (@) ( ) @@ () @ O @ O
( )
(@@@@)
( )

(@@@)
++ +------ ____ _ __________ _________ __________
|| |+-+ | | \@@@@@@@\@@@ | ___ ___ ___ ___ | | ___ ___
/-------/-|| | | | \@@@@@@@\@@@@@_ | |_| |_| |_| |_| | | |_| |_|
+ ======== +-+ | | | | |__________|_______| |_________
_|--O========O~\-+ |__________|_______| |__________|_______| |________
//// \_/ \_/ ==/ (O) (O) (O) (O) (O) (O) (O) (O) (O)
$ sl -a
( ) (@@) ( ) (@) () @@ O @ O @ O
(@@@)
( )
(@@@@)

( )
==== ________ ________________
_D _| |_______/ \__I_I_____===__|_________|
|(_)--- | H\______ H/ | | =|___ ___| lp! _________________
/ | | H | | | | |(O) (O)| _| \_____A
| | | H |__- |__--_-_-----_----| [___] | =| = |
| _ | __ |___H__/__|_____/[][]~\_[]~\__| ][]| | -| -| |
|/ | |-----------I_____I [][] [] D |=======|____|________________________|_
__/ =| o |=-~~\ /~~\ /~~\ /~~\ ____Y___________|__|__________________________|_
|/-=|___|= || || || |_____/~\___/ |_D__D__D_| |_D__D__D_
\_/ \O=====O=====O=====O__/ \_/ / / _/ \_/ \_/ \_/ \_/


cowsay の動作確認

$ which cowsay

/usr/games/cowsay

$ cowsay itamae
________
< itamae >
--------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||

$ cowthink 考える
___________
( 考える )
-----------
o ^__^
o (oo)\_______
(__)\ )\/\
||----w |
|| ||

$ cowsay -e ^^ 目を変える
_________________
< 目を変える >
-----------------
\ ^__^
\ (^^)\_______
(__)\ )\/\
||----w |
|| ||

$ cowsay -T 'N' 舌を出す
______________
< 舌を出す >
--------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
N ||----w |
|| ||

$ cowsay -f tux Tux登場
___________
< Tux登場 >
-----------
\
\
.--.
|o_o |
|:_/ |
// \ \
(| | )
/'\_ _/`\
\___)=(___/

$ cowsay -l | grep -v "^Cow" | sed -e "s% %\n%g" | sed -e "s%\(.*\)%cowsay -f \1 Now I am a \1%" | sh
________________
< Now I am a apt >
----------------
\ (__)
(oo)
/------\/
/ | ||
* /\---/\
~~ ~~
_______________________
< Now I am a beavis.zen >
-----------------------
\ __------~~-,
\ ,' ,
/ \
/ :
| '
| |
| |
| _-- |
_| =-. .-. ||
o|/o/ _. |
/ ~ \ |
(____@) ___~ |
|_===~~~.` |
_______.--~ |
\________ |
\ |
__/-___-- -__
/ _ \
_________________
< Now I am a bong >
-----------------
\
\
^__^
_______/(oo)
/\/( /(__)
| W----|| |~|
|| || |~| ~~
|~| ~
|_| o
|#|/
_+#+_
______________________
< Now I am a bud-frogs >
----------------------
\
\
oO)-. .-(Oo
/__ _\ /_ __\
\ \( | ()~() | )/ /
\__|\ | (-___-) | /|__/
'
'--' ==`-'== '--' '
__________________
< Now I am a bunny >
------------------
\
\ \
\ /\
( )
.( o ).
___________________
< Now I am a calvin >
-------------------
\ .,
\ . .TR d'
\ k,l .R.b .t .Je
\ .P q. a|.b .f .Z%
.b .h .E` # J: 2` .
.,.a .E ,L.M'
?:b `| ..J9!`.,
q,.h.M` `.., ..,""` ..2"`
.M, J8` `: ` 3;
. Jk ...,
`^7"90c.
j, ,! .7"
'`j,.| .n. ...
j, 7'
.r` 4: L `...
..,m. J` ..,|.. J` 7TWi
..JJ,.: % oo ,. ....,
.,E 3 7`g.M: P 41
JT7"
' O. .J,; `` V"7N.
G. ""Q+ .Zu.,!` Z`
.9.. . J&..J! . ,:
7"9a JM"!
.5J. .. ..F`
78a.. ` ..2'

J9Ksaw0"'
.EJ?A...a.
q...g...gi
.m...qa..,y:
.HQFNB&...mm
,Z|,m.a.,dp
.,?f
` ,E?:"^7b
`A| . .F^^7'^4,
.MMMMMMMMMMMQzna,
...f"A.JdT J: Jp,
`JNa..........A....af`
`^^^^^'
`
___________________
< Now I am a cheese >
-------------------
\
\
_____ _________
/
\_/ |
| ||
| ||
| ###
\ /### | |
| 0
\/ 0 | |
/| | |
/ | < |
\ \
| /| | | |
| |
\_______/ | | |
| | | / /
/|| /|||
----------------|
| | | |
*** ***
/___
\ /___\
_________________
< Now I am a cock >
-----------------
\
\ /\/\
\ /
| 0 >>
|___|
__((_<| |
( |
(__________)
| |
| |
/
\ /\
__________________
< Now I am a cower >
------------------
\
\
,__, | |
(oo)
\| |___
(__)
\| | )\_
| |_w |
\
| | || *

Cower....
___________________
< Now I am a daemon >
-------------------
\ , ,
\ /( )`
\ \ \___ / |
/- _ `-/ '
(/
\/ \ \ /\
/ / |
` \
O O ) / |
`-^--'`< '
(_.) _ ) /
`.___/` /
`-----'
/
<----. __ / __ \
<----|====O)))==) \) /====
<----' `--' `.__,' \
| |
\ /
______( (_ /
\______
,' ,-----' |
\
`--{__________) \/
____________________
< Now I am a default >
--------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
___________________
< Now I am a dragon >
-------------------
\ / \ //\
\ |\___/| / \// \\
/0 0 \__ / // | \ \
/ / \/_/ // | \ \
@_^_@'/ \/_ // | \ \
//_^_/ \/_ // | \ \
( //) | \/// | \ \
( / /) _|_ / ) // | \ _\
( // /) '
/,_ _ _/ ( ; -. | _ _\.-~ .-~~~^-.
(( / / )) ,-{ _ `-.|.-~-. .~ `.
(( // / )) '/\ / ~-. _ .-~ .-~^-. \
(( /// )) `. { } / \ \
(( / )) .----~-.\ \-'
.~ \ `. \^-.
///.----..>
\ _ -~ `. ^-` ^-_
///-._ _ _ _ _ _ _}^ - - - - ~ ~-- ,.-~
/.-~
___________________________
< Now I am a dragon-and-cow >
---------------------------
\ ^ /^
\ / \ // \
\ |\___/| / \// .\
\ /O O \__ / // | \ \ *----*
/ /
\/_/ // | \ \ \ |
@___@
` \/_ // | \ \ \/\ \
0/0/| \/_ // | \ \ \ \
0/0/0/0/| \/// | \ \ | |
0/0/0/0/0/_|_ / ( // | \ _\ | /
0/0/0/0/0/0/`/,_ _ _/ ) ; -. | _ _\.-~ / /
,-} _ *-.|.-~-. .~ ~
\ \__/ `/\ / ~-. _ .-~ /
\____(oo) *. } { /
( (--) .----~-.\ \-` .~
//__
\\ \__ Ack! ///.----..< \ _ -~
//
\\ ///-._ _ _ _ _ _ _{^ - - - - ~
_________________
< Now I am a duck >
-----------------
\
\
\ >()_
(__)__ _
_____________________
< Now I am a elephant >
---------------------
\ /\ ___ /\
\ // \/ \/ \\
(( O O ))
\\ / \ //
\/ | | \/
| | | |
| | | |
| o |
| | | |
|m| |m|
______________________________
< Now I am a elephant-in-snake >
------------------------------
\
\ ....
. ........
. .
. .
....... .........
..............................
Elephant inside ASCII snake
_________________
< Now I am a eyes >
-----------------
\
\
.::!!!!!!!:.
.!!!!!:. .:!!!!!!!!!!!!
~~~~!!!!!!. .:!!!!!!!!!UWWW
$$$
:
$$NWX!!: .:!!!!!!XUWW$$$$$$$$$P
$$$$$##WX!: .<!!!!UW$$$$" $$$$$$$$#
$$$$$ $$$UX :!!UW$$$$$$$$$ 4$$$$$*
^$$$B $$$$\ $$$$$$$$$$$$ d$$R"
"
*$bd$$$$ '*$$$$$$$$$$$o+#"
"""" """""""
__________________________
< Now I am a flaming-sheep >
--------------------------
\ . . .
\ . . . ` ,
\ .; . : .'
: : : .
\ i..`: i` i.i.,i i .
\ `,--.|i |i|ii|ii|i:
UooU
\.'@@@@@@`.||'
\__/(@@@@@@@@@@)'

(@@@@@@@@)
`YY~~~~YY'
|| ||
_________________________
< Now I am a ghostbusters >
-------------------------
\
\
\ __---__
_- /--______
__--( /
\ )XXXXXXXXXXX\v.
.-XXX( O O )XXXXXXXXXXXXXXX-
/XXX( U ) XXXXXXX
\
/XXXXX( )--_ XXXXXXXXXXX
\
/XXXXX/ ( O ) XXXXXX
\XXXXX\
XXXXX/ / XXXXXX
\__ \XXXXX
XXXXXX__/ XXXXXX
\__---->
---___ XXX__/ XXXXXX
\__ /
\- --__/ ___/\ XXXXXX / ___--/=
\-\ ___/ XXXXXX '--- XXXXXX
\-\/XXX\ XXXXXX /XXXXX
\XXXXXXXXX \ /XXXXX/
\XXXXXX > _/XXXXX/
\XXXXX--__/ __-- XXXX/
-XXXXXXXX--------------- XXXXXX-
\XXXXXXXXXXXXXXXXXXXXXXXXXX/
""VXXXXXXXXXXXXXXXXXXV""
________________
< Now I am a gnu >
----------------
\ ,-----._
.
\ . ,' `-.__,------._
// \ __\\' `-.
(( _____-'
___)) |
`:='/ (alf_/ |
`.=| |=' |
|) O | \
| | /\ \
| / . / \ \
| .-..__ ___ .--'
\ |\ \ |
|o o | ``--.___. / `-' \ \\ \ |
`--'' ' .' / / | | | | \
| | / / | | | mmm
| || | | /| |
( .' \ \ || | |
| | \ \ // / /
| | \ \ || |_|
/ | |_/ /_|
/__/
____________________
< Now I am a head-in >
--------------------
\
\
^__^ /
(oo)\_______/ _________
(__)\ )=( ____|_ \_____
||----w | \ \ \_____ |
|| || || ||
_______________________
< Now I am a hellokitty >
-----------------------
\
\
/\_)o<
| \
| O . O|
\_____/
_________________
< Now I am a kiss >
-----------------
\
\
,;;;;;;;,
;;;;;;;;;;;,
;;;;;'
_____;'
;;;(/))))|((\
_;;((((((|))))
/ |_\\\\\\\\\\\\
.--~( \ ~))))))))))))
/ \ `\-(((((((((((\\
| | `\ ) |\ /|)
| | `. _/ \_____/ |
| , `\~ /
| \ \ /
| `. `\| /
| ~- `\ /
\____~._/~ -_, (\
|-----|\ \ '
;;
| | :;;;' \
| / | |
| | |
__________________
< Now I am a kitty >
------------------
\
\
("`-'
'-/") .___..--' ' "`-._
` *_ * ) `-. ( ) .`-.__. `)
(_Y_.) '
._ ) `._` ; `` -. .-'
_.. `--'
_..-_/ /--' _ .' ,4
( i l ),-'' ( l i),' ( ( ! .-'
__________________
< Now I am a koala >
------------------
\
\
___
{~._.~}
( Y )
()~*~()
(_)-(_)
_________________
< Now I am a kosh >
-----------------
\
\
\
___ _____ ___
/ \ / /| / \
| | / / | | |
| | /____/ | | |
| | | | | | |
| | | {} | / | |
| | |____|/ | |
| | |==| | |
| \___________/ |
| |
| |
_______________________
< Now I am a luke-koala >
-----------------------
\
\ .
___ //
{~._.~}//
( Y )K/
()~*~()
(_)-(_)
Luke
Skywalker
koala
_________________________
< Now I am a mech-and-cow >
-------------------------
,-----.
| |
,--| |-.
__,----| | | |
,;:: | `_____' |
`._______| i^i |
`----| |---'| .
,-------._| |== ||//
| |_|P
`. /'/
`-------'
'Y Y/'/'
.== /_
^__^ / /'
| `i
(oo)_______ /' / | |
(__) )/ /' / |
`i
||----w | ___,;`----'.___L_,-'`__
|| || i_____;----.____i""____

_________________
< Now I am a meow >
-----------------
\
\ , _ ___.--'''`--''//-,-_--_.
\`"'
` || \\ \ \\/ / // / ,-\\`,_
/'` \ \ || Y | \|/ / // / - |__ `-,
/@"\ ` \ `\ | | ||/ // | \/ \ `-._`-,_.,
/ _.-. `.-\,___/\ _/|_/_\_\/|_/ | `-._._)
`-'
``/ / | // \__/\__ / \__/ \
`-' /-\/ | -| \__ \ |-' |
__/
\ / _/ \/ __,-' ) ,' _|'
(((__/(((_.' ((___..-'((__,'
_________________
< Now I am a milk >
-----------------
\ ____________
\ |__________|
/ /
\
/ /
\
/___________/___/|
| | |
| ==
\ /== | |
| O O |
\ \ |
| < |
\ \|
/| |
\ \
/ |
\_____/ | / /
/ /| | / /|
/||
\| | /||\/
-------------|
| | | |
<__/
\__>
____________________
< Now I am a moofasa >
--------------------
\ ____
\ / \
| ^__^ |
| (oo) |______
| (__) | )
\/\
\____/|----w |
|| ||

Moofasa
__________________
< Now I am a moose >
------------------
\
\ \_\_ _/_/
\ \__/
(oo)
\_______
(__)
\ )\/\
||----w |
|| ||
______________________
< Now I am a mutilated >
----------------------
\ \_______
v__v
\ \ O )
(oo) ||----w |
(__) || ||
\/\

_________________
< Now I am a pony >
-----------------
\ /\/\
\ \/\/
\ / -\
\ / oo -\
\ / \
| ---
\ -\
\--/ \ \
| -
\
\ -\ -------------\ /-\
\ \-------/ ---/ \
\ |\ \
| / | |
\ | \ |
| /
\ |
| /
\ |
\ \ \|
- /--------
\ | o
\+ +--------- \ |
| | |
\
| |
\ |
| | |
\
| |
\ |
\ | | |
| |
\ \
| | | |
+--+ ---+
_________________________
< Now I am a pony-smaller >
-------------------------
\ _^^
\ _- oo\
\----- \______
\ )\
||-----||
\
|| ||
________________
< Now I am a ren >
----------------
\
\
____
/# /_
\_
| |/o
\o\
|
\\_/_/
/ |_ |
| ||
\_ ~|
| |||
\/
| |||_
\// |
|| |
||_
\
\_| o|
/
\___/
/ ||||__
(___)_)
__________________
< Now I am a sheep >
------------------
\
\
__
UooU
\.'@@@@@@`.
\__/(@@@@@@@@@@)
(@@@@@@@@)
`YY~~~~YY'
|| ||
_____________________
< Now I am a skeleton >
---------------------
\ (__)
\ /oo|
\ (_"_)*+++++++++*
//I#\\\\\\\\I\
I[I|I|||||I I `
I`I'///'' I I
I I I I
~ ~ ~ ~
Scowleton
____________________
< Now I am a snowman >
--------------------
\
___###
/oo\ |||
\ / \|/
/""\ I
()| |(I)
\ / I
/""""\ I
| |I
| |I
\____/ I
____________________________
< Now I am a sodomized-sheep >
----------------------------
\ __
\ (oo)
\ ( )
\ /--\
__ / \ \
UooU\.'
@@@@@@`.\ )
\__/(@@@@@@@@@@) /
(@@@@@@@@)((
`YY~~~~YY' \\
|| || >>
________________________
< Now I am a stegosaurus >
------------------------
\ . .
\ / `. .'
"
\ .---. < > < > .---.
\ | \ \ - ~ ~ - / / |
_____ ..-~ ~-..-~
| |
\~~~\.' `./~~~/
--------- \__/ \__/
.' O \ / / \ "
(_____, `._.'
| } \/~~~/
`----. / } | / \__/
`-. | / | / `. ,~~|
~-.__| /_ - ~ ^| /- _
`..-'
| / | / ~-. `-. _ _ _
|_____| |_____| ~ - . _ _ _ _ _>
___________________
< Now I am a stimpy >
-------------------
\ . _ .
\ |\_|/__/|
/ / \/ \ \
/__|O||O|__ \
|/_ \_/\_/ _\ |
| | (____) | ||
\/\___/\__/ //
(_/ ||
| ||
| ||\
\ //_/
\______//
__ || __||
(____(____)
_________________
< Now I am a suse >
-----------------
\
\____
/@ ~-.
\/ __ .- |
// // @
_______________________
< Now I am a three-eyes >
-----------------------
\ ^___^
\ (ooo)\_______
(___)\ )\/\
||----w |
|| ||
___________________
< Now I am a turkey >
-------------------
\ ,+*^^*+___+++_
\ ,*^^^^ )
\ _+* ^**+_
\ +^ _ _++*+_+++_, )
_+^^*+_ ( ,+*^ ^ \+_ )
{ ) ( ,( ,_+--+--, ^) ^\
{ (@) } f ,( ,+-^ __*_*_ ^^\_ ^\ )
{:;-/ (_+*-+^^^^^+*+*<_ _++_)_ ) ) /
( / ( ( ,___ ^*+_+* ) < < \
U _/ ) *--< ) ^\-----++__) ) ) )
( ) _(^)^^)) ) )\^^^^^))^*+/ / /
( / (_))_^)) ) ) ))^^^^^))^^^)__/ +^^
( ,/ (^))^)) ) ) ))^^^^^^^))^^) _)
*+__+* (_))^) ) ) ))^^^^^^))^^^^^)____*^
\ \_)^)_)) ))^^^^^^^^^^))^^^^)
(_ ^\__^^^^^^^^^^^^))^^^^^^^)
^\___ ^\__^^^^^^))^^^^^^^^)\\
^^^^^\uuu/^^\uuu/^^^^\^\^\^\^\^\^\^\
___) >____) >___ ^\_\_\_\_\_\_\)
^^^//\\_^^//\\_^ ^(\_\_\_\)
^^^ ^^ ^^^ ^
___________________
< Now I am a turtle >
-------------------
\ ___-------___
\ _-~~ ~~-_
\ _-~ /~-_
/^\__/^\ /~ \ / \
/| O|| O| / \_______________/ \
| |___||__| / / \ \
| \ / / \ \
| (_______) /______/ \_________ \
| / / \ / \
\ \^\\ \ / \ /
\ || \______________/ _-_ //\__//
\ ||------_-~~-_ ------------- \ --/~ ~\ || __/
~-----||====/~ |==================| |/~~~~~
(_(__/ ./ / \_\ \.
(_(___/ \_____)_)
________________
< Now I am a tux >
----------------
\
\
.--.
|o_o |
|:_/ |
// \ \
(| | )
/'
\_ _/`\
\___)=(___/

____________________
< Now I am a unipony >
--------------------
\ \
\ \_
\ \\
\ \\/\
\ _\\/
\ / -\
\ / oo -\
\ / \
| ---
\ -\
\--/ \ \
| -
\
\ -\ -------------\ /-\
\ \-------/ ---/ \
\ |\ \
| / | |
\ | \ |
| /
\ |
| /
\ |
\ \ \|
- /--------
\ | o
\+ +--------- \ |
| | |
\
| |
\ |
| | |
\
| |
\ |
\ | | |
| |
\ \
| | | |
+--+ ---+
____________________________
< Now I am a unipony-smaller >
----------------------------
\ \
\ \
\ _\^
\ _- oo\
\---- \______
\ )\
||-----||
\
|| ||
__________________
< Now I am a vader >
------------------
\ ,-^-.
\ !oYo!
\ /./=\.\______
## )
\/\
||-----w||
|| ||

Cowth Vader
________________________
< Now I am a vader-koala >
------------------------
\
\ .
.---. //
Y|o o|Y//
/_(i=i)K/
~()~*~()~
(_)-(_)

Darth
Vader
koala
________________
< Now I am a www >
----------------
\ ^__^
\ (oo)\_______
(__)
\ )\/\
||--WWW |
|| ||


参照