Packer ç¨ã®ãã³ãã¬ã¼ãé Box-Cutter ã使ã£ã¦ã¿ã
以前試ãã Packer ç¨ã®ãã³ãã¬ã¼ã misheska/basebox-packer ã Box-Cutter ã«ç§»åãã¦ãã¾ããè¥å¹²ä½¿ãæ¹ãå¤ãã£ããããªã®ã§è©¦ãã¦ã¿ã¾ããã
packer èªä½ã®ã¤ã³ã¹ãã¼ã«ã¯å²æã
Box-Cutter
https://github.com/box-cutter
ä¸è¨ã® Organization ã¢ã«ã¦ã³ãã®ä¸ã«ãã£ã¹ããªãã¥ã¼ã·ã§ã³æ¯ã«ããã¸ã§ã¯ããä½æããã¦ããã®ã§ãå¿
è¦ãªãã®ã clone ãã¾ãã
ããã§ã¯ CentOS ç¨ã®ããã¸ã§ã¯ãã clone ãã¾ããã
% git clone https://github.com/box-cutter/centos-vm.git
ä½æããããã¼ã¸ã§ã³ã® json ãã¡ã¤ã«ãç·¨éãã¾ãã
ãã¡ã¤ã«åã§å¤§ä½ã©ããå¼ãã°ãããã¯åããã¯ãã
% cd centos-vm
% vim centos65.json
disk_size 㨠memsize ãå¤æ´ãã¾ããã
"disk_size": 30420, "vmx_data": { "memsize": "1024", "numvcpus": "2", "cpuid.coresPerSocket": "1" } ã» ã» ã» "disk_size": 30420, "vboxmanage": [ ["modifyvm", "{{.Name}}", "--memory", "1024"], ["modifyvm", "{{.Name}}", "--cpus", "2"] ]
æ¥æ¬èªç°å¢ã«ãããã®ã§ä»¥ä¸ã®ããã¯ã¹ã¿ã¼ããã¡ã¤ã«ãç·¨éãã¾ãã
% vim http/ks6.cfg
å¤æ´ããã®ã¯ä»¥ä¸ã
lang ja_JP.UTF-8
keyboard jp106
timezone Asia/Tokyo
OS ã¤ã¡ã¼ã¸ã® ISO ãã¡ã¤ã«ã®ãã¦ã³ãã¼ãå ãå¤æ´ãããå ´å㯠Makefile ãå¤æ´ããå¿ è¦ãããã¾ãã
% vim Makefile
以ä¸ã®ããã«ä½¿ç¨ããããã¼ã¸ã§ã³ã® ISO ã® URL ãå®ç¾©ããã¦ããã®ã§ãå¿ è¦ã«å¿ãã¦æå¯ãã®ãã©ã¼ã«å¤æ´ãããªã©ãã¾ãã
ã» ã» ã» CENTOS59_X86_64 ?= http://mirror.symnds.com/distributions/CentOS-vault/5.9/isos/x86_64/CentOS-5.9-x86_64-bin-DVD-1of2.iso CENTOS59_I386 ?= http://mirror.symnds.com/distributions/CentOS-vault/5.9/isos/i386/CentOS-5.9-i386-bin-DVD-1of2.iso CENTOS510_X86_64 ?= http://mirror.stanford.edu/yum/pub/centos/5.10/isos/x86_64/CentOS-5.10-x86_64-bin-DVD-1of2.iso CENTOS510_I386 ?= http://mirrors.kernel.org/centos/5.10/isos/i386/CentOS-5.10-i386-bin-DVD-1of2.iso CENTOS64_X86_64 ?= http://mirror.symnds.com/distributions/CentOS-vault/6.4/isos/x86_64/CentOS-6.4-x86_64-bin-DVD1.iso CENTOS64_I386 ?= http://mirror.symnds.com/distributions/CentOS-vault/6.4/isos/i386/CentOS-6.4-i386-bin-DVD1.iso CENTOS65_X86_64 ?= http://mirrors.kernel.org/centos/6.5/isos/x86_64/CentOS-6.5-x86_64-bin-DVD1.iso CENTOS65_I386 ?= http://mirrors.kernel.org/centos/6.5/isos/i386/CentOS-6.5-i386-bin-DVD1.iso ã» ã» ã»
ããã§æºåã¯å®äºã
Box-Cutter ã§ã¯ packer ã³ãã³ããç´æ¥å®è¡ããã®ã§ã¯ãªããmake ã使ãããã«ãªã£ã¦ãã¾ãã
å梱㮠Makefile ã§ãã«ãå¯è½ãªã¿ã¼ã²ããã¯ä»¥ä¸ã§ç¢ºèªã§ãã¾ãã
% make list Prepend 'vmware/' or 'virtualbox/' to build only one target platform: make vmware/centos65 Targets: centos65 centos65-desktop centos64 centos64-desktop centos510 centos59 centos65-i386 centos64-i386 centos510-i386 centos59-i386
ãã®ä¸ããå¿
è¦ãªãã®ãé¸æãã¦ãã«ããã¾ãã
ã¡ãã»ã¼ã¸ã«ããããã«ããã«ããããã¿ã¼ã²ããåã®åã« 'vmware/' ã¾ã㯠'virtualbox/' ãä»ãããã¨ã§ç¹å®ã®ä»®æ³ç°å¢åãã® Box ã®ã¿ä½æããããã«æ示ãããã¨ãåºæ¥ãããã§ãã
packer ã³ãã³ãã§ã-only=virtualbox-isoãã¨ãã-only=vmware-isoãæå®ããã®ã¨åãã§ããã
ããã§ã¯ virtualbox ã® box ã ãå¿
è¦ã ã£ãã®ã§ä»¥ä¸ã®ããã«ãã¾ããã
% make virtualbox/centos65
éä¸ VirtualBox ãèµ·åãã¦ã¤ã³ã¹ãã¼ã«ãé²ãã§è¡ãã¾ãã
æ«ãå¾
ã¤ã¨ä»¥ä¸ã« Box ãçæããã¾ããã
% ls box/virtualbox
centos65-nocm.box
ãã£ã¨è©¦ããã¨ãããããªæãã
ãã³ãã¬ã¼ãã®ç¨®é¡ãå
å®ãã¦ããã®ã§ã Packer 㧠Box ä½æããé㯠Box-Cutter ã§æ±ºã¾ãããªã¼ã