ã¯ããã«
Ansibleã¢ãžã¥ãŒã«ãšsparrowãã©ã°ã€ã³ã¯ãæ§æ管çãšå±éã®èªååã®åéã§æãåçŽãªã¿ã¹ã¯ã解決ããããã®æ§æèŠçŽ ã§ãã Ansibleã¢ãžã¥ãŒã«ã¯é«ã¬ãã«ã®ã¹ã¯ãªããïŒYAMLã§èšè¿°ããããã¬ã€ããã¯ïŒã§äœ¿çšãããsparrowãã©ã°ã€ã³ã¯åæ§ã«Perl6ã§èšè¿°ãããsparrowdoã¹ã¯ãªããã«åã蟌ãŸããŸãã
ãã®èšäºã¯ãèè ã®è±èªããã®ãªãªãžãã«ã®ç¡æ翻蚳ã§ãã
éçºèšèªã®ãµããŒã
ansible-ã¢ãžã¥ãŒã«ãäœæããããã®ã»ãŒãã¹ãŠã®éçºèšèªãéžæã§ããŸãã
ããã©ã«ãã§ã¯ãansibleã¯Pythonã®é«åºŠãªAPIïŒã·ã§ãŒãã«ãããšåŒã°ããïŒãæäŸããŸãã ä»ã®èšèªã§ã¢ãžã¥ãŒã«ãéçºããå Žåãè£å©ã©ã€ãã©ãªïŒåèšèªã®ãã€ãã£ãïŒã䜿çšããŠãéçºããã»ã¹ãç°¡çŽ åããansibleã«çµ±åããå¿
èŠããããŸãã
sparrow -3ã€ã®ïŒ*ïŒèšèªã®ããããïŒPerl5ãBashããŸãã¯RubyïŒããéžæã§ããŸãã ãã©ã°ã€ã³éçºè åãã«ãsparrowã¯ãansibleãšåæ§ã«ãçµ±åãããAPIïŒ3ã€ã®èšèªã®ããããã§å©çšå¯èœïŒãæäŸããŸããããã«ããããã©ã°ã€ã³ã®éçºãšéã·ã¹ãã ãžã®çµ±åããã»ã¹ãç°¡çŽ åãããŸãã ãã®APIã¯åºæ¬çãªæ©èœã®ã¿ãæäŸããPythonã®ansible APIã»ã©é«åºŠã§ã¯ãããŸããã
ïŒ*ïŒè¿ãå°æ¥ãPythonã®ãµããŒããè¿œå ããèšç»ã
èšèš
ansible -ansibleã¢ãžã¥ãŒã«-åºæ¬çãªåé¡ã解決ããããã®ïŒã¹ã¯ãªããïŒã®å Žåãã¹ã¿ã³ãã¢ãã³ãââãã°ã©ã ãããã¯ã Ansibleã¢ãžã¥ãŒã«ã¯ãä»ã®Ansibleã¢ãžã¥ãŒã«ã«äŸåããããåŒã³åºãããããããšã¯ã§ããŸããã
sparrow -sparrowãã©ã°ã€ã³ã¯ansibleã¢ãžã¥ãŒã«ã«äŒŒãŠããŸã-åºæ¬çãªåé¡ã解決ããããã®ã¹ã¿ã³ãã¢ãã³ã®éããã³ãŒããããã¯ã§ãã ãã ããã¹ãºã¡ã¯ããã®ã¬ãã«ã®éçºã§è¿œå ã®èªç±åºŠãæäŸããŸãã Sparrowãã©ã°ã€ã³ã¯ãäžé£ã®ã¹ã¯ãªããã§ãã äžéšã®ã¹ã¯ãªããã¯ä»ã®ã¹ã¯ãªãããåŒã³åºããŠããã©ã¡ãŒã¿ãŒãæž¡ããŸãã ãã®ãããªèšèšã«ãããã¿ã¹ã¯ãçžäºã«äœçšããã¹ã¯ãªããã«åå²ã§ããŸãã äŸãšããŠãåçŽãªã±ãŒã¹-ãœãããŠã§ã¢ããã±ãŒãžã®ã€ã³ã¹ããŒã«ãšåé€ãæ€èšããŸãã ãã®ã¿ã¹ã¯ã¯1ã€ã®ã³ãŒããããã¯ïŒã¹ã¯ãªããïŒãšããŠèŠãããšãã§ããŸãããå®è£ æã«ã¯ãã¹ãŠã2ã€ã®ã¹ã¯ãªããã«åå²ããŸãã1ã€ã¯ããã±ãŒãžã®ã€ã³ã¹ããŒã«çšããã1ã€ã¯ã¢ã³ã€ã³ã¹ããŒã«çšã§ãã 3çªç®ã®ã¹ã¯ãªãããå ¥åããããšãã§ããŸããããã¯ãå ¥åãã©ã¡ãŒã¿ãŒã解æããåŒã³åºãã¹ã±ãžã¥ãŒãªã³ã°ïŒ*ïŒãå®è¡ããŸãã ãã®ã¢ãããŒãã«ã€ããŠã¯ãèšäºã Sparrowãã©ã°ã€ã³ã®é²åãã§è©³ãã説æããŠããŸã ã
ïŒ*ïŒå®éã package-genericãã©ã°ã€ã³ã¯ãã®æ¹æ³ã§å®è£ ãããŸãã
ããããã¹ãŠã®ç°¡åãªèª¬æã§ãã
æ§æ管çããŒã«ãžã®çµ±å
ansible -ansibleã¢ãžã¥ãŒã«ã¯é«ã¬ãã«ã®æ§æã¹ã¯ãªããã®äžéšã§ã-ansible ãã¬ã€ãã㯠ã ansibleãã¬ã€ããã¯-YAMLã§èšè¿°ãããã¹ã¯ãªããã§ãç¹å®ã®ãã©ã¡ãŒã¿ãŒãæã€ansibleã¢ãžã¥ãŒã«ã®åŒã³åºãã宣èšããŸãã ãã®ãããªansibleã®æ§é ã¯åé¡ãšåŒã°ããŸãã
sparrow -ansibleã¢ãžã¥ãŒã«ã®ããã«ãsparrowãã©ã°ã€ã³ã¯äžå¯æ¬ ãªéšåã§ã
ããäžè¬çãªã·ã¹ãã ã¯ã Perl6ã§æžãããsparrowdoã¹ã¯ãªããã§ãã ansibleã®ããã«-sparrowdo-æ§æ管çã·ã¹ãã ã§ãããsparrowãã©ã°ã€ã³äžã«æ§ç¯ãããŠããŸãã Sparrowãã©ã°ã€ã³ã¯ãsparowdoã¹ã¯ãªããå
ã®ãã©ã¡ãŒã¿ãŒã§åŒã³åºãããŸãã
ãšã³ããŠãŒã¶ãŒã€ã³ã¿ãŒãã§ãŒã¹
ansible-æ¢ã«è¿°ã¹ãããã«ãæž¡ããããã©ã¡ãŒã¿ãŒã§ã¢ãžã¥ãŒã«ã®èµ·åã宣èšããYAML DSLã³ãŒãã䜿çšããŠãansibleã¢ãžã¥ãŒã«ãåŒã³åºãããŸãã ããã¯ããã¬ã€ããã¯ã§çºçããŸãã ã³ãã³ãã©ã€ã³åŒæ°ãšããŠæž¡ããããã©ã¡ãŒã¿ãŒã䜿çšããŠãã³ã³ãœãŒã«ã¹ã¯ãªããã§ã¢ãžã¥ãŒã«ãèµ·åããããšãã§ããŸãã
以äžã¯ãyumããã±ãŒãžãããŒãžã£ãŒïŒåãååã®ansibleã¢ãžã¥ãŒã«ïŒã䜿çšããŠhttpd WebãµãŒããŒãã€ã³ã¹ããŒã«ããããã®ansibleãã¬ã€ããã¯ã³ãŒãã®äŸã§ãã
$ cat playbook.yml --- - hosts: webservers tasks: - name: ensure apache is at the latest version yum: name=httpd state=latest
sparrow -sparrowdoãã©ã°ã€ã³å ã§Perl6 APIã䜿çšããŠsparrowãã©ã°ã€ã³ãåŒã³åºãããŸãã ãã©ã°ã€ã³ãã©ã¡ãŒã¿ãŒã¯Perl6ããã·ã¥ãšããŠæž¡ãããŸãã ã³ã³ãœãŒã«ã¯ã©ã€ã¢ã³ãã䜿çšããŠããã©ã°ã€ã³ãããã®ãŸãŸãå®è¡ããsparrowdoããã€ãã¹ããããšãã§ããŸãïŒansibleã¢ãžã¥ãŒã«ãå®è¡ã§ããã®ãšåæ§ã®æ¹æ³ã§ïŒã ããã¯ããã©ã°ã€ã³ãéçºããã³ãããã°ãããšãã«åœ¹ç«ã¡ãŸãã ãã®èµ·åã¢ãŒãã§ã¯ãã³ãã³ãã©ã€ã³ãJSON / YAMLãããã³æ§æ::å ¥å圢åŒãæž¡ãããã®å€ãã®è¿œå ãªãã·ã§ã³ããããŸãïŒäžè¬åœ¢åŒ
以äžã¯ãhttpd WebãµãŒããŒãã€ã³ã¹ããŒã«ããããã®ä»¥åã®ansibleãã¬ã€ããã¯ã«çžåœããŸãã sparrowdoã¹ã¯ãªããã«ã¯2ã€ã®ã³ãŒãããªã¢ã³ãïŒcore-dslããã³ãã©ã°ã€ã³APIïŒããããŸãã
$ cat sparrowfile # core-dsl API , # "" # package-install 'httpd'; # , core-dsl # , # plugin API # : task-run 'ensure apache is at the latest version', 'package-generic', %( list => 'httpd' );
å ¥åãã©ã¡ãŒã¿ãŒã®éä¿¡ãšåŠç
ansible-ã¢ãžã¥ãŒã«ã®å ¥åãã©ã¡ãŒã¿ãŒã¯key = value ïŒ*ïŒãã¢ã®åœ¢åŒã§éä¿¡ãããŸããäžè¬ã«ãã¢ãžã¥ãŒã«ãéçºãããšãã¯ãã¢ãžã¥ãŒã«ã³ãŒãã§ããã«äœ¿çšããããã«ããã©ã¡ãŒã¿ãŒã解æããŠããŒã¿ãã匷調ããã察å¿ããå€æ°ã«å²ãåœãŠãå¿ èŠããããŸãã ããŸããŸãªéçºèšèªã«ã€ããŠããã®åé¡ã解決ããå€æ°ã®ããã«ããŒããããŸãã
ïŒ*ïŒãã¹ããããããŒã¿æ§é ã転éããããšã¯å¯èœã§ãã
ãŸãããã§ã«è¿°ã¹ãããã«ãansibleã¯ansibleããã¥ã¡ã³ãã§ã·ã§ãŒãã«ãããšåŒã°ããé«ã¬ãã«ã®Python APIãæäŸããŸãã ãã®APIã䜿çšãããšãå ¥åãã©ã¡ãŒã¿ãŒãèªåçã«è§£æããã¢ã¯ã»ãµãŒãçæããå ¥åãã©ã¡ãŒã¿ãŒã®ã¿ã€ããå€å¥ããŠãããã確èªããããã©ã«ãå€ãªã©ãå€å¥ã§ããŸãã
以äžã¯ãPython ansible APIã䜿çšããŠå ¥åãã©ã¡ãŒã¿ãŒã®è§£æãå®è£ ããanibleã¢ãžã¥ãŒã«ã§ãã
$ cat library/greetings.py from ansible.module_utils.basic import * def main(): fields = { "message": {"default": "Hi!", "type": "str" } } module = ansibleModule(argument_spec=fields) module.params['message'] # some other code here to return results if __name__ == '__main__': main()
sparrow -sparrowã¯ããã©ã°ã€ã³ã®å ¥åãã©ã¡ãŒã¿ãŒãåŠçããããã®çµ±åAPIïŒãã¹ãŠã®éçºèšèªã§äœ¿çšå¯èœïŒãå®è£ ããŠãããããããŒã¿ãæåã§è§£æããå¿ èŠã¯ãããŸããã
ãããã£ãŠããã©ã°ã€ã³ãéçºããŠããèšèªã«é¢ä¿ãªãã
å®éã«1è¡ã®ãµããŒãã³ãŒããèšè¿°ããããšãªããå
¥åã«ã¢ã¯ã»ã¹ããããã®æšæºAPIã
åŸè ãæ瀺çã«èšå®ãããªãå Žåããã©ã¡ãŒã¿ã®ããã©ã«ãå€ã決å®ããããšãã§ããŸãã
ansible Python APIã®å Žåã®ããã«ãçµã¿èŸŒã¿ã®å ¥åãšãã©ã¡ãŒã¿ãŒã®ãã§ãã¯ã¯ãããŸããã
以äžã¯ãå ¥åãã©ã¡ãŒã¿ãŒã解æããansibleã³ãŒãã«çžåœãããã®ã§ãã ãã©ã°ã€ã³å®è£ ã®èšèªãšããŠBashïŒ*ïŒãéžæãããŠããŸã
ïŒ*ïŒæãé«åºŠãªéçºèšèªãšã¯ããé¢ãããšããã§ãããå ¥åãã©ã¡ãŒã¿ãŒã®åŠçã«ãå ¥ããããšãªããããããã©ã°ã€ã³ãç°¡åã«äœæã§ããããšã瀺ããŸãã
# $ cat story.bash message=$(config message) # : $ cat story.ini message = Hi!
次ã«ãåãBashã䜿çšããŠãã¹ããããå ¥åãã©ã¡ãŒã¿ãŒã解æããæ¹æ³ã瀺ããŸãã
# sparrowdo $ cat sparrowfile task-run "run my task", 'foo-plugin', %( foo => { bar => { baz => 'BAZ' } } ); # Bash # : $ cat story.bash baz=$(config foo.bar.baz)
æ»ãå€
ansible -ansibleã¢ãžã¥ãŒã«ã¯åžžã«JSONæååãšããŠçµæãè¿ããŸãã ããã«ãJSONèªäœã«ã¯ç¹å¥ãªæ§é ãå¿ èŠã§ãã ããã«ã€ããŠã¯ãansibleã¢ãžã¥ãŒã«éçºã®ããã¥ã¡ã³ãããŒãžã§è©³ããèªãããšãã§ããŸãã
ããããããã§ã¯ãansibleã¢ãžã¥ãŒã«ããå€ãè¿ãããã»ã¹ã«ã€ããŠæ³šæãããããšã瀺ããŸãã
ansibleã¢ãžã¥ãŒã«ã®å®äºã³ãŒãïŒç¡é³ãå®è£ ããã¹ã¯ãªããïŒã¯ç¡èŠãããŸã
ã¢ãžã¥ãŒã«ããæ»ãããã®å¯äžã®èŠä»¶ã¯ãSTDOUTã«JSONæååãååšããããšã§ãã å¿çã®JSONæ§é ãç¹å®ã®èŠä»¶ãæºãããŠããå¿ èŠããããŸãã
ãããã£ãŠãã¢ãžã¥ãŒã«ããã®å¿çã§æå¹ãª JSONãååŸã§ããªãå Žå ãããã¯ãšã©ãŒãšèŠãªãããŸã
ã¢ãžã¥ãŒã«ã«ãã£ãŠçæãããSTDOUT / STDERRã¯ããã¬ã€ããã¯ã®åºåã«è¡šç€ºãããŸããïŒ*ïŒ
ïŒ*ïŒ-ç¹å®ã®æ¡ä»¶äžã§ããŸãã¯è¿œå ã®ã³ãŒããèšè¿°ããããšã§ããã®çµè«ãåŸãããšãã§ããŸãããããã§ã¯ããã©ã«ãã®åäœã«ã€ããŠèª¬æããŠããŸã
- ã¢ãžã¥ãŒã«ãå€ãè¿ãããã«ã¯ãæ§é ã®JSONãã£ãŒã«ããšããŠè¡šãããSTDOUTã«è¿ãããå¿ èŠããããŸã
çŸåšã®æå»ãè¿ãcurrenttimeã¢ãžã¥ãŒã«ã®äŸã瀺ããŸãã
$ cat library/currentime.py import datetime import json date = str(datetime.datetime.now()) print json.dumps({ "time" : date })
sparrow -ansibleã¢ãžã¥ãŒã«ãšã¯ç°ãªããsparrowãã©ã°ã€ã³ã¯äœã§ãè¿ãããšãã§ããŸã; sparrowã¯ãã©ã°ã€ã³ã«ãã£ãŠè¿ãããããŒã¿ãèŠå¶ããŸããã ïŒãã ãã次ã®ã»ã¯ã·ã§ã³ãåºååŠçããåç §ããŠãã ããïŒã
ããã§ã¯ãã¹ãºã¡ã®èŠç¹ããã®åºåã«ã€ããŠç¥ãããšãéèŠã§ãã
ãã©ã°ã€ã³å®äºã³ãŒãïŒçµæãã¹ãºã¡ã®å Žåã¯1ã€ã®ã¹ã¯ãªããã§ã¯ãªãè€æ°ã®ã¹ã¯ãªãããåŠçã§ããããïŒãããã¯éèŠã§ãã ãŒã以å€ã®å Žåãããã¯ãã©ã°ã€ã³ã©ã³ã¿ã€ã ãšã©ãŒãšããŠæ±ãããŸãã
- ãã©ã°ã€ã³ã«ãã£ãŠçæãããSTDOUTã¯åã«æž¡ãããçµæã®åºåã«è¡šç€ºãããŸãã ansibleã®å Žåã®ããã«ãçµæã®ãåããã±ãŒãžåãããã£ã«ã¿ãªã³ã°ã¯è¡ãããŸããã ã³ã³ãœãŒã«ããåæ§ã®ã¹ã¯ãªãããå®è¡ãããã®ããã«ãåžžã«åºåããã®ãŸãŸè¡šç€ºãããŸãã
次ã«ã以åã®ansibleã¢ãžã¥ãŒã«ã«çžåœãããã®ãæå®ããŠãçŸåšã®æå»ã衚瀺ããŸãã ä»åã¯ããã©ã°ã€ã³ãäœæãããšãã«Perl5ã䜿çšããŸããããã¯ããã¹ãŠã®ãã©ã°ã€ã³ã³ãŒããäºçŽ°ãªãã®ã§ãããšå€æããããã§ãã
# $ cat story.pl print scalar localtime;
åºååŠç
ansible -ansibleã¢ãžã¥ãŒã«ã¯åžžã«JSONãè¿ãå¿ èŠããããããæ§é åãããããŒã¿åºåã䜿çšããŠå€æ°ã«å€æããå®éã«ansibleãã¬ã€ããã¯ã§ãããé«ããå Žæã§åŠçããã®ã¯éåžžã«ç°¡åã§ãã ããã¯ããªã匷åãªæ©èœã§ãããæ§æ管çã·ã¹ãã ã§ã®ãã®äŸ¡å€ã¯å人çã«ã¯è°è«ã®äœå°ããããŸãã å®éã«ã¯ãã¿ãŒã²ãããµãŒããŒã§ã¿ã¹ã¯ã®ãªã¹ããå®è¡ããæç¹ïŒ*ïŒãŸã§ã«ããã¹ãŠã確å®ã«éçã§æ±ºå®çãªãªã¹ãã®åœ¢ã«ãªã£ãŠããå¿ èŠããããŸãããã®ãããªæ¢ã«çæããããªã¹ãã«åå²ãšãã€ããã¯ã¹ãè¿œå ããããšããŠããè€éåããã ãã§ãªããåæã®äžè¬çãªåé¡ã®è§£æ±ºçã¯ç¹å®ã®ãã¥ãŒãžã®ãµãŒããŒã
ïŒ*ïŒããã§ããã®ãããªã¿ã¹ã¯ãªã¹ããŸãã¯ãªãœãŒã¹ã®åçãªçæã«å察ããããã§ã¯ãªãããšãç解ããããšãéèŠã§ããããã§ã¯ãã·ã§ããã¹ãºã¡ã®å Žåã®ããã«ãåœä»€åã¢ãããŒããéåžžã«é©åã§ãã ãããããããããã¢ãžã¥ãŒã«ã«ãã£ãŠè¿ãããããŒã¿ãã©ã®ããã«ãã¬ã€ããã¯ã§ããã«äœ¿çšãããããæšè«ããã®ã«ååãªã»ã©ç解ã§ãããšã¯æããŸããã
次ã«ãæž¡ãããå ¥åãã©ã¡ãŒã¿ãŒãåçŽã«è¿ãåçŽãªã¢ãžã¥ãŒã«ã®äŸã瀺ããŸãããã®ãã©ã¡ãŒã¿ãŒã¯ããã¬ã€ããã¯ã«ãç»é²ããããã³ã³ãœãŒã«ã«è¡šç€ºãããŸãã
$ cat playbook.yml - hosts: localhost tasks: - name: tell me what I say echo: message: "hi there!" register: result - debug: var=result $ cat library/echo.py from ansible.module_utils.basic import * def main(): module = ansibleModule(argument_spec={}) response = {"you_said": module.params['message']} module.exit_json(changed=True, meta=response) if __name__ == '__main__': main()
ã¹ãºã¡ -ãã§ã«è¿°ã¹ãããã«ãã¹ãºã¡ã¯ãã©ã°ã€ã³ãSTDOUTã§èšã£ãŠããããšããæ°ã«ããŸãããããã®ããŒã¿ãããã«äœ¿çšããæ¹æ³ã¯ãããŸããã å®éãããã¯å®å šã«çå®ã§ã¯ãããŸããã
ãã®ããŒã¿ã¯ãã以äžåŠçãããªããšãã芳ç¹ãã-ããã¯äºå®ã§ãããã¹ã¯ãªããã®åºåãæ€èšŒã§ããæ€èšŒã«ãŒã«ã決å®ããæ©äŒããããŸãã ãã®çš®ã®çµã¿èŸŒã¿ãã¹ãã¯ãéãã©ã°ã€ã³ã®ç¹åŸŽçãªæ©èœã§ãã æ€èšŒã«ãŒã«ã¯Outthentic :: DSLèšèªæ§æã®åœ¢åŒã§èšè¿°ãããããŸããŸãªããã¹ããã§ãã¯ãå®è¡ã§ããŸã-ç°ãªãæ£èŠè¡šçŸãšã®ããã¹ããããã³ã°ãè¡šçŸã«å¯Ÿå¿ããåã ã®ããã¹ãã®åŠçïŒãããããã£ããã£ïŒãªã©ã ããã«ã€ããŠã¯ãOutthenic :: DSLã®ããã¥ã¡ã³ãããŒãžã§èªãããšãã§ããŸãã
æ€èšŒã倱æããå ŽåãïŒãŒã以å€ã®çµäºã³ãŒããšãšãã«ïŒãã©ã°ã€ã³å®è¡ãšã©ãŒãšããŠæ±ãããŸãã
ãããã£ãŠããã®çš®ã®ãèªå·±ãã¹ããã¹ã¯ãªãããäœæãããšãæ§æ管çã®åéã®ã¿ã¹ã¯ã ãã§ãªãããã¹ããç£èŠãç£æ»çšã®ãã©ã°ã€ã³ãäœæã§ããŸãã
äžèšã®ãã¹ãŠã®ãããã§ã以åã®ansibleã¢ãžã¥ãŒã«ãšã®é¡äŒŒæ§ãæ§ç¯ããããšã¯å°é£ã§ããã
ã¹ãºã¡ã§ã§ããããããŸãã«äŒŒãããã®ããããŸãã ãã©ã¡ãŒã¿ãŒããã©ã°ã€ã³ã«æž¡ãããããSTDOUTã«åºåãããã¹ãã«ãŒã«ãèšè¿°ããŠãåºåãå
¥åãšãŸã£ããåãã§ããããšã確èªããŸãã
# sparrowdo $ cat sparrowfile run-task "tell me what I say", "echo", %( message => 'hi there!' ) # $ cat story.bash echo you said $(config message)
$ cat story.check
ãžã§ãã¬ãŒã¿ïŒconfigïŒïŒ-> {message}
ã€ã³ã¹ããŒã«ããã»ã¹
ansible-å€æ°ã®ansibleãansibleã®äžéšãšããŠæäŸãããŠãããããã«äœ¿çšã§ããŸããç¹å¥ãªæ¹æ³ã§ã€ã³ã¹ããŒã«ããå¿ èŠã¯ãããŸããã ãŸãããŠãŒã¶ãŒã¯ããããã«ã¹ã¿ã ã¢ãžã¥ãŒã«ãèšè¿°ããååãšããŠãããããããŒãžã§ã³ç®¡çã·ã¹ãã -Git / SvnïŒããšãã°ãgithubãŸãã¯gitlabïŒã«ä¿åããŸãã 次ã«ãéåžžã®ãã¡ã€ã«åœ¢åŒã®ã¢ãžã¥ãŒã«ããã¹ã¿ãŒãµãŒããŒïŒã¿ãŒã²ãããµãŒããŒã§ansible sshã¿ã¹ã¯ãå®è¡ããã¢ãžã¥ãŒã«ïŒã§ãã§ãã¯ã¢ãŠããããŸãããã®å Žåããã¡ãã»ãŒãžã¯ããŒãžã§ã³ç®¡çã·ã¹ãã ããã®éåžžã®ãã§ãã¯ã¢ãŠãã«çž®å°ãããŸãã
ãããã£ãŠãã¢ãžã¥ãŒã«ã®ãšã³ã·ã¹ãã ã«ã¯2ã€ã®å€§ããªãµãã·ã¹ãã ãå«ãŸããŸãã
Ansibleã¡ã€ã³ãªããžããªïŒ ã¡ã€ã³ansibleãªããžã㪠ïŒ-ansibleã§æäŸãããã¢ãžã¥ãŒã«
- ã«ã¹ã¿ã ã¢ãžã¥ãŒã«
ãŸãšãããšãansibleã¯ããã·ã¥ããŒã¹ã®ãããã€ã¡ã³ãã¹ããŒã ãå®è£ ããŠãããã¿ãŒã²ãããµãŒããŒã«ãšãŒãžã§ã³ããååšããªãïŒãšãŒãžã§ã³ãã¬ã¹ïŒãšèšããŸãã ãã¡ã€ã«ã®åœ¢åŒã®ã¢ãžã¥ãŒã«ã¯ãåã«ã¿ãŒã²ãããµãŒããŒã«ã³ããŒãããã¹ã¯ãªããã®åœ¢åŒã§æ¢ã«èµ·åãããŠããŸãã
以äžã¯ããŠãŒã¶ãŒã¢ãžã¥ãŒã«ã®å±éããã»ã¹ã®ã°ã©ãã£ã«ã«ãªå³ã§ãã
ã¹ãºã¡ -ã¹ãºã¡ã§ã¯ãå±éããã»ã¹ããããã«ç°ãªããŸãã äžè¬ã«ãåãããã·ã¥ããŒã¹ã®ã¹ããŒã ãæ¡çšãããŠããŸãã ãã ããã¹ãºã¡ã®å Žåã¯ããã©ã°ã€ã³ã®ã€ã³ã¹ããŒã«ã«é¢äžãããšãŒãžã§ã³ãïŒãŸãã¯ã¯ã©ã€ã¢ã³ãïŒãããŸãã
ãããã£ãŠãsparrowãã©ã°ã€ã³ã¯ãdebãrpmãCPANãRubyGemsãªã©ã®ãœãããŠã§ã¢ããã±ãŒãžçšã®å€å žçãªé åžã·ã¹ãã ã®ããã«é åžãããããã±ãŒãžåãããã¹ã¯ãªããã«ä»ãªããŸããã
sparrowã¯ãã©ã°ã€ã³ããŒã¿ã€ã³ã¹ããŒã«ãããŒãžã£ãŒãæäŸããåããããŒãžã£ãŒã䜿çšããŠãã©ã°ã€ã³ãå®è¡ããŸãã ãã¹ãŠãæ©èœããã«ã¯ããããŒãžã£ãŒãã¿ãŒã²ãããµãŒããŒã«ããªã€ã³ã¹ããŒã«ããå¿ èŠããããŸãã
sparrowdoã¯ãäžå€®ïŒãã¹ã¿ãŒïŒãµãŒããŒã«ããã¹ã¯ãªãããã¡ã¿ããŒã¿ã«ã³ã³ãã€ã«ããŸããã¡ã¿ããŒã¿ã¯scpãä»ããŠJSONãã¡ã€ã«ã®åœ¢åŒã§ã¿ãŒã²ãããã·ã³ã«ã³ããŒããããããŒãžã£ãŒãšåãã¿ãŒã²ãããã·ã³ã«ããŠã³ããŒãããã³ããŒããããŒã¿ã䜿çšããŠèšå®ãã€ã³ã¹ããŒã«ããæåŸã«sparrowãã©ã°ã€ã³ãèµ·åããŸããçµæã¯ãïŒansibleã®å Žåã®ããã«ïŒäžå€®ãµãŒããŒãžã®å¿çã®åœ¢åŒã§è¿ãããŸãã
ãããã£ãŠãansibleãšã¯ç°ãªãããã©ã°ã€ã³ãã€ã³ã¹ããŒã«ããããšã¯åã«ãã¡ã€ã«ãã¿ãŒã²ãããµãŒããŒã«ã³ããŒããã ãã§ã¯ãªãã ã¹ãºã¡ã®å Žåãã³ããŒãããã®ã¯ãã©ã°ã€ã³èªäœã§ã¯ãªãããã®ã¡ã¿æ å ±ã§ãããå®éã®å±éããã»ã¹ã¯ã¡ã¿æ å ±ã«åŸã£ãŠè¡ãããŸãã
sparrowãã©ã°ã€ã³ã¯ãäžå€®ã®sparrowãã©ã°ã€ã³ãªããžããªsparrowHubã§ãã¹ããããŸãã ãã©ã°ã€ã³ã«ã¯ãäœæè ãããŒãžã§ã³ã説æãããã¥ã¡ã³ãããããŸãã
ãœãããŠã§ã¢ããã±ãŒãžãã€ã³ã¹ããŒã«ããããã®äžèšã®ããã±ãŒãžãžã§ããªãã¯ãã©ã°ã€ã³ã®ã¡ã¿ãã¡ã€ã«ã¯æ¬¡ã®ããã«ãªããŸãã
{ "name" : "package-generic", "version" : "0.2.16", "description": "Generic package manager. Installs packages using OS specific package managers (yum,apt-get)", "url" : "https://github.com/melezhik/package-generic" }
ãããã§ã¯ãã«ã¹ã¿ã ãã©ã°ã€ã³ãšãã³ã¢ããã©ã°ã€ã³ã®éã«æ確ãªåé¢ã¯ãããŸããã sparrowHubã«ããŒãããããã©ã°ã€ã³ã¯ãã·ã¹ãã ã®ãŠãŒã¶ãŒãããã«å©çšã§ããããã«ãªããããsparrowdoã¹ã¯ãªããã§äœ¿çšã§ããŸãã
å¿ èŠã«å¿ããŠããŠãŒã¶ãŒã¯ãªã¢ãŒãgitãªããžããªã«ãã©ã°ã€ã³ãé 眮ã§ããŸãããã®ãããªãã©ã°ã€ã³ã¯ãã©ã€ããŒãïŒãã©ã€ããŒãïŒãšåŒã°ããsparrowHubã®ãã©ã°ã€ã³ïŒãããããããªãã¯ãã©ã°ã€ã³ïŒãšãšãã«ãããã®ãã©ã°ã€ã³ãæ§æã¹ã¯ãªããã§ç°¡åã«äœ¿çšã§ããŸã
以äžã¯ãã¹ãºã¡ã®ãã©ã°ã€ã³å±éå³ã§ãã
äŸåé¢ä¿
ansible -ansibleã§ã¯ãã¢ãžã¥ãŒã«ã¬ãã«ã§ãœãããŠã§ã¢ã®äŸåé¢ä¿ã管çããæ¹æ³ã¯ãããŸããã æãå¯èœæ§ãé«ãïŒç§ã¯ansibleãããç¥ã£ãŠãããç§ã¯æšæž¬ããïŒããã¯ããé«ãã¬ãã«ã§èµ·ãã-ãã¬ã€ããã¯ã§ã ãããã£ãŠãã¢ãžã¥ãŒã«ãã©ã€ãã©ãªã«äŸåããŠããå Žåã¯ãããšãã°ããã¬ã€ããã¯ã®å¥ã®å Žæã§äŸåé¢ä¿ã®ã€ã³ã¹ããŒã«ãåŒã³åºããªã©ããŠãäŸåé¢ä¿ã解決ããå¿ èŠããããŸãã
sparrow -sparrowã¯ãsparrowãã©ã°ã€ã³ã¬ãã«ã§ãã«ã¿ã€ã ã®äŸåé¢ä¿ç®¡çïŒ*ïŒæ©èœãæäŸããŸãã ãããã£ãŠããã©ã°ã€ã³ãã©ã€ãã©ãªã«äŸåããŠããå Žåã¯ããã©ã°ã€ã³ã§äŸåé¢ä¿ããŒã¿ãçŽæ¥èšè¿°ããããšãã§ãããã©ã°ã€ã³ãããŒãžã£ãŒãããããåŠçããŸã
ãã©ã°ã€ã³ã®ã€ã³ã¹ããŒã«äžã ãããŸã§ã®ãšãããäŸåé¢ä¿ç®¡çã¯ã cpanfileãã¡ã€ã«ãä»ããPerl5ã®CPANã¢ãžã¥ãŒã«ãšã Gemfileãã¡ã€ã«ãä»ããRubyã®RubyGemsã¢ãžã¥ãŒã«ã«å¶éãããŠããŸãã
ïŒ*ïŒ-äŸåé¢ä¿ã¯å¶éãããŠããŸãããPerl5ã®CPANããã³Rubyã®RubyGems
ãããã«
ansibleã¯ãç¹ã«å€æ°ã®æ¢è£œã®ã¢ãžã¥ãŒã«ããããããéåžžã«äººæ°ããããŸãã ããããç§ã®å人çãªæèŠã§ã¯ãæ°ããã¢ãžã¥ãŒã«ãéçºããããã»ã¹ã«ã¯æ¬ ç¹ããããã¢ãŒããã¯ãã£èªäœã¯ããã€ãã®ã¿ã¹ã¯ã«é©ãããœãªã¥ãŒã·ã§ã³ã§ã¯ãããŸããã åã ã®ã¹ãºã¡ã®ç¹åŸŽã¯ãansibleã«æ¯ã¹ãŠããé åçã§èå³æ·±ããšæããŸãã ãã¡ãããããã¯ç§èŠã§ã:)ãç§ã¯ããã€ãã®ãã€ã³ãããªã¹ãããŸãïŒ
ãã¬ã€ããã¯ãš sparrowdoã¹ã¯ãªãã-sparrowdoã¯ã匷åã§ææ°ã®Perl6èšèªã䜿çšããå¿ é ã®æ§æããã°ã©ãã³ã°ãªãã·ã§ã³ãæäŸããŸã
ansibleã§ã¯ãçŽç²ã«å®£èšçãªYAMLã®æ©èœã«ãã£ãŠå¶éãããŸãã
- ã¹ã¯ãªããæåã®èšèš-ã¹ã¯ãªããæåã®ã¹ããŒã ã®ãããã§ãã¹ãºã¡ã¯ã¿ã¹ã¯ãåå¥ã®æçãšåæçã®åå¥ã®ã¹ã¯ãªããã«åå²ããããšã奚å±ããã¹ã¯ãªããèªäœã¯äºãã«æž¡ããããã©ã¡ãŒã¿ãŒã䜿çšããŠææ©çã«çžäºäœçšããŸãïŒããããã¹ãºã¡ïŒ ã¢ãžã¥ãŒã«ã¹ããŒãªãŒ ïŒansibleã®å Žåãéåžžã¯1ã€ã®ã¢ãžã¥ãŒã«= 1ã€ã®ã¹ã¯ãªããã¹ããŒã ã«å¶éãããŸãã ãã¡ãããansibleã®å Žåãåæ§ã®ã¹ã¿ã€ã«ïŒã¢ãžã¥ãŒã«å ã®ããã€ãã®ã¹ã¯ãªããïŒã§èšè¿°ã§ããŸããããã¡ãããansibleã¯èšèšäžããã®çš®ã®ãã®ã«ã¯é©ããŠããŸããã
ãããã£ãŠãå®çšçãªæå³ã§ã¯ãå€ãã®å Žåãåé¡ã解決ããŠæ¥åžžçãªã¹ã¯ãªãããäœæãããšãã«ãåé¡ãããã€ãã®éšåã«åå²ããçžäºã«äœçšããäžé£ã®ã¹ã¯ãªãããçšæããŸãã
ã©ã€ããµã€ã¯ã«ãšã¢ãžã¥ãŒã«ããã³ãã©ã°ã€ã³ã®ç®¡ç-ããããã©ã°ã€ã³ã¯ãæ§æ管çããŒã«èªäœããããã«åé¢ãããåé¢ãããŠããŸãã ç§ãèšã£ãããã«ãsparrowdo ãªãã§sparrowãã©ã°ã€ã³ã䜿çšã§ããŸãã äºå®äžããããã¯ãã®ã·ã¹ãã ïŒsparrowdoïŒã®ãã¬ãŒã ã¯ãŒã¯å€ã§éçºããããã°ããã¹ãã管çããããã©ãã¯ããã¯ã¹ãšããŠäœ¿çšãããŸãã ããã«ãããæ°ãããã©ã°ã€ã³ãéçºããsparrowdoå ã§äœ¿çšããããã»ã¹ãããã«æè»ãã€ã·ã³ãã«ã«ãªããŸãã
Bash / Shellã¹ã¯ãªãã-sparrowã¯ãéåžžã®bash / shellã¹ã¯ãªãããçµ±åããããã®ansibleãµããŒããããåªããŠããŸãã åŸè ã¯è¿ãããããŒã¿ã«å¶éã課ããããã©ã«ãã§STDOUT / STDERRã¹ããªãŒã ãåºåããªããããéåžžã®bashã¹ã¯ãªããããããã°ãããã äœãåé¡ãªã®ããç解ããããšãå°é£ã«ãªãå ŽåããããŸãã ã¹ãºã¡ã¯å®éã«ãã¹ãŠã®ã¹ã¯ãªããåºåãééçã«ã¬ããŒãã«å€æããŸãã ãŸããéçºè ãè¿ãããJSONã®ã¬ãã«ã§ãšã©ãŒãåå®çŸ©ãããansibleã®ã¹ã¯ãªããå®äºã³ãŒããç¡èŠããäžã§éèŠãªåœ¹å²ãæãããŸãã ãã®å ŽåãSparrowã¯åã«ãšã©ãŒãçæããunix / linuxã³ãã³ããå®è¡ãã察æµã¹ã¿ã€ã«ã§åäœããŸãã
ãœãããŠã§ã¢API-ãã¹ãŠã®ãã©ã°ã€ã³éçºèšèªã«çµ±äžãããã€ã³ã¿ãŒãã§ãŒã¹ãæäŸããŸãã ããã¯ããµããŒããããŠããèšèªã®ãªã¹ãã«ããã»ãŒãã¹ãŠã®èšèªããã·ã¹ãã ãæäŸããåºæ¬çãªAPIã«é¢ããŠãåãæš©å©ãæã£ãŠãããããšãæå³ããŸãã ansibleã¢ãžã¥ãŒã«ã¯ã»ãšãã©ãpythonã§æžãããŠããŸããããã®èšèªã®ãµããŒããæãå®å šã§ãããšããäºå®ã®ããïŒansible modules python APIïŒ
- ãã¹ãæ©èœ-sparrowã¯çµã¿èŸŒã¿ã®ãã¹ãæ©èœãæäŸããŸããããã«ããããã®ããŒã«ãããªã¹ããããŠãããã®ã«å ããŠãç£æ»ãç£èŠããã¹ãã¿ã¹ã¯ãªã©ã«äœ¿çšã§ããæ±çšèªååããŒã«ãšèŠãªãããšãã§ããŸãã
PSãã€ãã®ããã«ãèªè ã®æèŠãšåœŒã®å»ºèšçãªæ¹å€ãèãã®ã¯èå³æ·±ãã§ãã ä»åã¯ãåŸæ¥ã®ã¢ã³ã±ãŒããè¡ã£ãŠããŸããããèšäºã¯èšå€§ã§ããããšãå€æããŸããã