Yogafireããã¼ã¸ã§ã³ã¢ãããã¦ããã«æãï¼
æ©è½è¿½å ãããæãããã¦ã¾ãã¤ããã
以ä¸ChangeLogã
ChangeLogï¼ä¸»è¦ãªãã®ã®ã¿ï¼
- å¤§å¹ ãªãªãã¡ã¯ã¿ãªã³ã°
- ã¿ã¼ã²ããã¤ã³ã¹ã¿ã³ã¹ã決å®ãããã¸ãã¯ãçµ±ä¸å
- ssh vpc ãµãã¼ã
- ssh proxy ãµãã¼ã
- ã¤ã³ã¯ãªã¡ã³ã¿ã«ã«ãã£ã«ã¿ãè¡ããããã«
- 'yogafire'ãæå®ãããã¨ã«ããã表示ãªãã¸ã§ã¯ããã¹ã¦ã«å¯¾ãã¦ã³ãã³ãå®è¡
- renderã³ãã³ãã«'template-file'ãªãã·ã§ã³è¿½å
- 'change-instance-type'ã³ãã³ã追å
- 'update-ec2-tags'ã³ãã³ã追å
- selfãªãã·ã§ã³å¯¾å¿
- 'loop' ãªãã·ã§ã³å¯¾å¿
- instance-typeãææ°ã«Updateããã®ã¨ã«ã©ã¼ãªã³ã°å¯¾å¿
- start / stop / reboot/ terminateãªã©è¤æ°åæå®è¡åºæ¥ã¦ããªãã£ãã®ã対å¿
- 'copy-and-launch' ã³ãã³ããå¤ã«åºã¦ããªãã£ãã®ã§åºãã
ã¿ã¼ã²ããã¤ã³ã¹ã¿ã³ã¹ã決å®ãããã¸ãã¯ãçµ±ä¸å
ä»ã¾ã§ã³ãã³ãã«ãã£ã¦ã¾ã¡ã¾ã¡ã ã£ããããã®ã§çµ±ä¸ãã¾ããã
ã¿ã¼ã²ããå
ã®æ£è¦è¡¨ç¾ã«ãã£ã¦ä»¥ä¸ã®å¤å®ãè¡ãã¾ãã
# private dnsã¨ãã¦æ¥ç¶ yoga ssh ip-10-199-60-10.us-west-1.compute.internal # public dnsã¨ãã¦æ¥ç¶ yoga ssh ec2-50-1-30-251.us-west-1.compute.amazonaws.com # ã¤ã³ã¹ã¿ã³ã¹IDã¨ãã¦æ¥ç¶ yoga ssh --proxy=i-9bed5ac3 # ã¿ã°åï¼åç¬ï¼ yoga get www01 ./getfile ./ # ã¿ã°åï¼è¤æ°ï¼ yoga put 'www*' ./putfile /tmp
ipã¢ãã¬ã¹ã対å¿ããäºå®ã§ãããã諸äºæ
ã«ããTodoã
ssh vpc / proxy ãµãã¼ã
æè¿VPC使ããã¨ãå¤ããªã£ã¦ãã¾ããã
ãããyogafireããã°ã£ã¦ã¦ããããsshç¹ãããªãã£ãã®ã§ã¾ãã¯ãããä¿®æ£ãã¾ããã
ã¾ããè¸ã¿å°å¯¾å¿ãyogafireã ãã§åºæ¥ãããã«ãã¦ã¿ã¾ããã
以ä¸ã®ããã«ããã¨è¸ã¿å°æå®åºæ¥ã¾ãã
yoga ssh --proxy=<target_id> # get / put / cmdã対象ã以ä¸ã¯ãfumidaiãã¨ããã¿ã°åã®ã¤ã³ã¹ã¿ã³ã¹ãè¸ã¿å°ã«æå® yoga cmd www1 ls --proxy=fumidai yoga put www1 ./putfile.txt ./ --proxy=fumidai yoga get www1 ./getfile.txt ./ --proxy=fumidai
ã¾ãã¯ã.yogaãã¡ã¤ã«ã«ãproxyããè¨å®ãã¦ãOKã§ãã
å
±éã§ãããã·éãããå ´åã¯ãã¡ããè¯ãã§ãããã
application1: access_key_id: xxxxxxxxxxxxxxxxx ... proxy: fumidai ...
ã¤ã³ã¹ã¿ã³ã¹ã®ä¸è¦§è¡¨ç¤ºæãã¤ã³ã¯ãªã¡ã³ã¿ã«ã«ãã£ã«ã¿åºæ¥ãããã«ãã
â»ï¼è©³ããã¯別記事ã«ãã¾ãï¼
対象ã¯ã³ãã³ãã¯
ssh / start / stop / reboot / terminate / copy-and-launch / change-instance-type / ls -i / ls-ami -i
ã§ãã
åãã¼ã¸ã§ã³ã¾ã§ã¯ãéè¤ããTagNameãæå®ããã¨ãä¸ã¤ã«ãªãããã«å度æå®ãã¦ããã¨å¼¾ãã¦ããã®ã§ãã
é¢åãªã®ã§ã¤ã³ã¯ãªã¡ã³ã¿ã«ã£ã½ãçµãè¾¼ããããã«ãã¦ã¿ã¾ããã
ããã¯ãã¸ã§ä¾¿å©ããã¦é¼»ããããï¼
'yogafire'æå®ã§è¡¨ç¤ºãã¦ããã¤ã³ã¹ã¿ã³ã¹ãå ¨å¯¾è±¡ã«ãã¦å®è¡
ç¾ç¶ã¯ start / stop / reboot / terminate ã®ã¿ä½¿ç¨å¯è½ã§ãã
ã¤ã³ã¿ã©ã¯ãã£ãå®è¡ä¸ã«ãyogafireããå®è¡ããã¨
ä»è¡¨ç¤ºãã¦ãããªãã¸ã§ã¯ãå
¨ã¦ã«å¯¾ãã¦ã³ãã³ããå®è¡ãã¾ãã*1
change-instance-typeã対å¿ããäºå®ã§ãããã¡ãã¯Todoã
renderã³ãã³ãã«'template-file'ãªãã·ã§ã³è¿½å
yoga render --template-file=<file_name> # example yoga render --template-file=./example/render/simple.tt --state=running
åãã¼ã¸ã§ã³ã¾ã§ã¯æååãç´æ¥æå®ããããã§ããªãã£ãã®ã§ãã
ããã«å ãã¦ãã³ãã¬ã¼ããã¡ã¤ã«ãæå®ã§ããããã«ãã¾ããã
ãã®æ©è½ã«ãããã¤ã³ã¹ã¿ã³ã¹ã®"ãã¼ã«"ï¼"ç¶æ
"ãªã©ã«ããã³ã³ãã£ã°ãã¡ã¤ã«ãçæããã
ã¨ãã£ããã¨ãå¯è½ã«ãªãã¾ããã
ãã³ãã¬ã¼ãã¨ã³ã¸ã³
Text::Xslateï¼TT2likeï¼ãå©ç¨ãã¦ããã®ã§ãåºæ¬Xslateã®æ§æããã®ã¾ã¾ä½¿ãã¾ãã
詳ããç¥ãããæ¹ã¯ä»¥ä¸ã®ããã¥ã¡ã³ããã覧ãã ããã
http://search.cpan.org/~gfuji/Text-Xslate-2.0000/lib/Text/Xslate/Syntax/TTerse.pm
http://search.cpan.org/~dmaki/Text-Xslate-Bridge-TT2Like-0.00010/lib/Text/Xslate/Bridge/TT2Like.pod
ã·ã³ãã«ãªä¾
ãã³ãã¬ã¼ãã«ã¯æ¡ä»¶ã«ä¸è´ããã¤ã³ã¹ã¿ã³ã¹ã®é
åã
ãinstancesãã¨ããååã§æ¸¡ã£ã¦ãã¾ãã
以ä¸ã®ãã³ãã¬ã¼ãã¯ã¤ã³ã¹ã¿ã³ã¹æ¯ã«ãããªãã¯DNSåãåºåãã¾ãã
ã¤ã³ã¹ã¿ã³ã¹ã®ã¢ããªãã¥ã¼ãã«ã¤ãã¦ã¯VM::EC2のメソッドã¨åçã«ãªãã¾ãã
[% FOREACH i IN instances %] [% i.dnsName %] [% END %]
ã·ã³ãã«ãªä¾ï¼æ¡ä»¶åå²
å¾æ¥éã yoga render ã³ãã³ãæã«filteræå®ãã¦ä½¿ããã¨ããã¡ããå¯è½ã§ããã
ãã³ãã¬ã¼ãå
ã§æ¡ä»¶åå²ããããã¨ãå¯è½ã§ãã
以ä¸ã®ãã³ãã¬ã¼ãã¯ã¿ã°åããwwwãã§å§ã¾ãã¤ã³ã¹ã¿ã³ã¹ã§ããã°
ãã©ã¤ãã¼ãIPãã¤ã³ã¹ã¿ã³ã¹æ¯ã«åºåãã¾ãã
[% FOREACH i IN instances %] [% IF i.tags.Name.match('^www') %] [% i.privateIpAddress %] [% END %] [% END %]
ã·ã³ãã«ãªä¾ï¼JSONã®æ±ã
ã«ã¹ã¿ã ã¿ã°ã«JSONæååãå
¥ãã¦ã´ãã§ã´ãã§ãã¦ããæ¹ãããã¨æãã¾ãã
ãããã£ããã¼ãºã«ãå¿ããã¦JSONããã³ã¼ãããé¢æ°ãå®ç¾©ãã¾ããã
以ä¸ã®ä¾ã§ã¯ãRoleãã¨ããã«ã¹ã¿ã ã¿ã°ã«
ã{"Nagios":"1","Group":"www"}ã
ã¨ããæååãå
¥åããã¦ããã®ããã³ã¼ããã¦å©ç¨ãããã¿ã¼ã³ã§ãã
[% FOREACH i IN instances %] [% SET ROLE = decode_json(i.tags.Role) %] [% ROLE.Nagios %] # ã1ãã表示ããã [% ROLE.Group %] # ãwwwãã表示ããã [% END %]
å¿ç¨ä¾ï¼NagiosãMuninã®ã³ã³ãã£ã°ãèªåçæãã¦ã¿ã
ããå°ãå
·ä½çãªä¾ãä¸ãã¦ã¿ã¾ãããã
AWSã§ã¤ã³ãã©æ§ç¯ãã¦ããæ¹ã¯
ãã¤ã³ã¹ã¿ã³ã¹åããããã¯ãç¬èªã¿ã°ããè¦ã¦
Nagios/Munin/Capistoranoãªã©ã®ã³ã³ãã£ã°ãçæãããã¨ãã£ãã¹ã¯ãªããã
èªåã§å®è£
ããããã¦ããªãã§ããããï¼ï¼èªåã¯ãã¦ãã¾ãï¼
ãã®ãããªè¦ä»¶ããã£ãæãyogafireãããã°ã¹ã¯ãªãããæ¸ãã¾ã§ããªã
ãã³ãã¬ã¼ããã¡ã¤ã«ãä½ãã ãã§æ¸ãããã«ãªãã¾ãï¼
ä¾ã¨ãã¦ããã¤ããã³ãã¬ã¼ããä½ã£ã¦ã¿ã¾ããã
muninã®å ´å
åºæ¬çãªè¨å®ã ãã§ããã°
このような一つのファイルãä½ãã ãã§è¯ãã§ãã
ããã«ãèªåã§ã°ã«ã¼ãã³ã°ãè¨å®ãããã¨ãã«ã¯IFæã使ãã°ç°¡åã§ãã*2
ããã一つのファイルã ãã§OKã§ãã
nagiosã®å ´å
å
¨ã¦ã«åºæ¬ç£è¦ããã ããªãこのような一つのファイルãä½ãã ãã§è¯ãã§ãã
ã¾ãããã¼ã«ã«ãã£ã¦ç£è¦é
ç®ã追å ããããã¨ãããã¾ãããã
IFæã§æ¡ä»¶åå²ãã¦ãè¯ãã§ãããä»åã¯ä¾ã¨ãã¦å¤é¨ã®ã¤ã³ã¯ã«ã¼ããã¡ã¤ã«ã使ããã¿ã¼ã³ãä½ã£ã¦ã¿ã¾ããã
åèã«ãã¦ã¿ã¦ãã ãã*3
https://github.com/toritori0318/p5-Yogafire/blob/master/example/render/nagios/nagios_include.tt
https://github.com/toritori0318/p5-Yogafire/tree/master/example/render/nagios
ä»ã«ãnginx ã®ãµã³ãã«ãç½®ãã¦ããã¾ãã®ã§ãåç §ãã ããã
ä¸è¨ã®ä¾é¡ãã³ãã¬ã¼ãããã¦ã³ãã¼ããã¦
èªåã®ç°å¢ã§åããã¦ã¿ãã ãã§ãæ触ãã¤ãããã¨æãã¾ãã
renderã³ãã³ãã¯æ¨æºåºåã«åºãã ããªã®ã§ä½ãèããã«è²ã
ã¨è©¦ãã¦ã¿ã¦ãã ããï¼
'change-instance-type'ã³ãã³ã追å
yoga change-instance-type <target_id>
ãã®åã®éããinstance-typeãå¤æ´ãã¾ãã
ãã®ã³ãã³ãã®ä½ãå¬ãããã¨ããã¨ã
æé»çã«ä»¥ä¸ã®ãããªæé ãè¡ãªã£ã¦ããããã¨ã§ãã
- â»ã¤ã³ã¹ã¿ã³ã¹ãèµ·åãã¦ãããåæ¢ããã(a) EIPãã¤ãã¦ããä¿æãã¦ãã
- ã¹ãã¼ã¿ã¹ãstoppedã«ãªãã¾ã§å¾ ã¤
- ã¤ã³ã¹ã¿ã³ã¹ã¿ã¤ãå¤æ´
- 1.ãéã£ã¦ããå ´å
- ã¤ã³ã¹ã¿ã³ã¹ãèµ·åãç´ã
- ã¹ãã¼ã¿ã¹ãrunninngã«ãªãã¾ã§å¾ ã¤
- (a) ã®EIPãããã°ãEIPãä»ãç´ã
EC2classicã§éç¨ãã¦ããã®ã§ããã°ããã便å©ãªã³ãã³ãã¨ãªãã¾ããã
ã¾ã以ä¸ã®ããã«ä¸åº¦ã«è¤æ°ã®ã¤ã³ã¹ã¿ã³ã¹ã«å¯¾ãã¦ãå®è¡å¯è½ã§ãã
è¤æ°ã¤ã³ã¹ã¿ã³ã¹ãä¸æ°ã«ãt1.microããããc1.xlargeãã«ã¹ã±ã¼ã«ã¢ãããã¨ãã£ãæä½ãç°¡åï¼
yoga change-instance-type 'www*' --type=c1.xlarge --force
ããã«å®å
¨ã«è足ã§ããã
以åãã使ãã expand-volumeã³ãã³ããä¼¼ããããªãã¨ããã¦ãã¾ãã
- â»ã¤ã³ã¹ã¿ã³ã¹ãèµ·åãã¦ãããåæ¢ããã(a) EIPãã¤ãã¦ããä¿æãã¦ãã
- ã¹ãã¼ã¿ã¹ãstoppedã«ãªãã¾ã§å¾ ã¤
- ã¹ãããã·ã§ããä½æ
- ã¹ãããã·ã§ããã¹ãã¼ã¿ã¹ããcompletedãã«ãªãã¾ã§å¾ ã¤
- æ°ãããµã¤ãºã§ããªã¥ã¼ã ãä½ã
- ããªã¥ã¼ã ã¹ãã¼ã¿ã¹ããavailableãã«ãªãã¾ã§å¾ ã¤
- ç¾å¨ã®ããªã¥ã¼ã ãdetachãã
- ããªã¥ã¼ã ã¹ãã¼ã¿ã¹ããdetachedãã«ãªãã¾ã§å¾ ã¤
- æ°ããããªã¥ã¼ã ãattachãã
- ããªã¥ã¼ã ã¹ãã¼ã¿ã¹ããattachedãã«ãªãã¾ã§å¾ ã¤
- 1.ãéã£ã¦ããå ´å
- ã¤ã³ã¹ã¿ã³ã¹ãèµ·åãç´ã
- ã¹ãã¼ã¿ã¹ãrunninngã«ãªãã¾ã§å¾ ã¤
- (a) ã®EIPãããã°ãEIPãä»ãç´ã
- â»ä¸è¨ã®ã©ããã§ã¨ã©ã¼ãçºçãããå ã®ããªã¥ã¼ã ã«ãã¼ã«ããã¯ãã
'update-ec2-tags'ã³ãã³ã追å
â»ãã®APIã¯å°æ¥ã³ãã³ãã¤ã³ã¿ãã§ã¼ã¹ãå¤ããå¯è½æ§ãããã¾ã
yoga update-ec2-tags <target_id> --key='<tag_name>=<tag_value>'
åºæ¬çã«ã¯tagãæ´æ°ããã ãã®ã³ãã³ãã§ããã
èªåã§é£çªãä»ãã¦ãããæ©è½ãããã¾ãã
以ä¸ã®ã³ãã³ãã¯ãimage-id=ami-xxxxxãã®ã¤ã³ã¹ã¿ã³ã¹å
¨ã¦ã«å¯¾ã
ãNameã¿ã°ï¼www<é£çª>ãã¨ãRoleã¿ã°=webappãã®ã¿ã°æ´æ°ãå®è¡ãã¾ãã
yoga update-ec2-tags --filter='image-id=ami-xxxxx' --key='Name=www[% seqno %]' --key='Role=webapp'
selfãªãã·ã§ã³å¯¾å¿
èªåèªèº«ã®ãµã¼ãã対象ã¨ãããselfããªãã·ã§ã³ã追å ãã¾ããã
ãã¡ãããec2ã¤ã³ã¹ã¿ã³ã¹ä¸ã§å®è¡ããå ´åéå®ã¨ãªãã¾ãã
以ä¸ç°¡åãªä¾ã§ãããèªæ®ºã³ãã³ãã§ããã»ãã
yoga terminate --self
å¿ç¨ç·¨ï¼
é«é¡ã¤ã³ã¹ã¿ã³ã¹ãèµ·åãã¦ãã¹ãä¸ã
ãã¤ã³ã¹ã¿ã³ã¹è½ã¨ãå¿ãããã©ããããâ¦ã¬ã¯ãã«ã
ã¨ãã¯ãã¯ãã¦ãã人ãå¤ããã¨ã§ãããã
ãããªã¨ããatã³ãã³ããæå®ãã¦ããã¨è½ã¨ãå¿ããç¡ããªã£ã¦è¯ãã§ããã*4
# 2013/03/26 23:00 ã«èªåçã«ã¤ã³ã¹ã¿ã³ã¹ãstopãã echo "yoga stop --self --force" | at "23:00 26.03.13"
å¿ç¨ç·¨ï¼
æéã®ããããããªãã«ããå®è¡ããæã
ã¤ã³ã¹ã¿ã³ã¹ãä¸æçã«ãt1.micorããc1.mediumã«ã¢ããã°ã¬ã¼ãããã
ã¨ãã£ããã¨ã¯æ¥å¸¸è¶é£¯äºã§ããã
ãããã¤ã³ã¹ã¿ã³ã¹ãæ»ãå¿ãã¦ããâãâã¼ï¼ãã¨ãªããã¨ã度ã
ããã¾ãã
ãããªã¨ãã¯ã³ãã³ãçµäºã¨åæã«
ãã¤ã³ã¹ã¿ã³ã¹ãstopãããã¾ãã¯ãã¤ã³ã¹ã¿ã³ã¹ãt1.microã«æ»ãã
ãªã©ã¨ãã¦ããã¨å®ç ã§ãã¾ããã
# perlbrewã®å¾ã¯ä½ãä½ã§ãstopãã perlbrew install v5.16.3 ; yoga stop --self --force # ã³ãã³ããæåããæã ãt1.microã«æ»ã cpanm Task::Plack && yoga change-instance-type --type t1.micro --force
'loop' ãªãã·ã§ã³å¯¾å¿
ã¤ã³ã¿ã©ã¯ãã£ãã«å
¥åã§ããã³ãã³ãå
¨é¨ã対象ã§ãã
åãã¼ã¸ã§ã³ã¾ã§ã¯ã³ãã³ãå®è¡å¾ã«çµäºãã¦ãã¾ãã¾ããã
loopãªãã·ã§ã³ãä»ãã¦ããã¨ã³ãã³ãçµäºå¾ã«ã¤ã³ã¹ã¿ã³ã¹ä¸è¦§é¸æç»é¢ã«æ»ãããã
ç¹°ãè¿ãã¤ã³ã¹ã¿ã³ã¹ã«å¯¾ãã¦ã³ãã³ãå®è¡ãããã¨ãåºæ¥ã¾ãã
yoga ls -i -l
instance-typeã®Updateã¨ã«ã©ã¼ãªã³ã°å¯¾å¿
ææ°æ
å ±ã«Updateããã®ã¨ãã°ã«ã¼ããã¨ã«ã«ã©ã¼ãªã³ã°è¡¨ç¤ºããããã«ãã¾ããã
ç¾å¨å®è£ ä¸ï¼æ¬¡ãã¼ã¸ã§ã³ã§å ¬éäºå®ï¼ã®ã³ãã³ãé
- å¥ãªã¼ã¸ã§ã³ã«AMIãä½ãã¾ã§ãèªååãã¦ãããã³ãã³ã
- ç¹å®ã®ã°ã«ã¼ãæ¯ã«ã¤ã³ã¹ã¿ã³ã¹æ°ã調æ´ããã³ãã³ããæåAutoScaleã¿ãããªæã*5
Todo
- ãã°åºåæ´ç
- VPCã¦ã¼ãã£ãªãã£ãå å®ãããã
- cmd / put/ getã®ãã©ã¬ã«å¯¾å¿
- ãã¹ãã®å å®ï¼ããããã©ããããï¼
ã¾ã å°ããã®ã¼ãªé¨åãããããã§ããã
ãããããã°ã¢ãããã¼ããã¦ã¿ã¦ãã ããã
*1:æ¬å½ã¯ãyogaInfernoãã«ãããã£ããã©æã¡ã¥ããã®ã§å´ä¸
*2:"Role"ã¨ããç¬èªã¿ã°ã«"www"ã"db"ãªã©ã®æååããã®ã¾ã¾å ¥ã£ã¦ããã¨ä»®å®ãã¦ãã¾ã
*3:ã¤ã³ã¯ã«ã¼ããã¿ã¼ã³ã§ã¯ããã¼ã«åã¨ä¸è´ãããã³ãã¬ã¼ããåå¨ããªãã¨ã¨ã©ã¼ã«ãªãã¾ãã®ã§ã注æã
*4:ãã ãatã³ãã³ãã®ä»æ§ã§ãatã³ãã³ããå®è¡ããªãã¾ã¾æåã§ãµã¼ããè½ã¨ãããããã¨ã次åãµã¼ãèµ·åæã«ç»é²ããã³ãã³ããå®è¡ããã¦ãã¾ããããã®ã§æ³¨æãterminateã¯å±éºãã
*5:ã©ã£ã¡ããã