{"id":5240,"date":"2014-12-20T10:00:26","date_gmt":"2014-12-20T01:00:26","guid":{"rendered":"http:\/\/www.techscore.com\/blog\/?p=5240"},"modified":"2018-11-14T16:33:49","modified_gmt":"2018-11-14T07:33:49","slug":"packer%e3%81%a7%e9%96%8b%e7%99%ba%e7%92%b0%e5%a2%83%e6%a7%8b%e7%af%89","status":"publish","type":"post","link":"https:\/\/www.techscore.com\/blog\/2014\/12\/20\/packer%e3%81%a7%e9%96%8b%e7%99%ba%e7%92%b0%e5%a2%83%e6%a7%8b%e7%af%89\/","title":{"rendered":"packer\u3067\u958b\u767a\u74b0\u5883\u69cb\u7bc9"},"content":{"rendered":"
\u3053\u3093\u306b\u3061\u306f\u3001\u6cb3\u91ce\u3067\u3059\u3002 \u3044\u307e\u3069\u304d\u3001\u30ed\u30fc\u30ab\u30eb\u306e\u958b\u767a\u74b0\u5883\u69cb\u7bc9\u3060\u3068Vagrant\u304c\u4e3b\u6d41\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n \u30c1\u30fc\u30e0\u5185\u3067Vagrant\u3092\u5c0e\u5165\u3059\u308b\u524d\u306b\u306f\u3001\u4e0d\u5b9a\u671f\u3067\u65b0\u3057\u3044ova\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u3063\u3066\u516c\u958b\u3057\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001ova\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u308b\u306e\u306b\u3051\u3063\u3053\u3046\u624b\u9593\u304c\u639b\u304b\u3063\u3066\u3044\u307e\u3057\u305f\u3002 pakcer\u3092\u4f7f\u3046\u3068ova\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\u304c\u7c21\u5358\u306b\u3067\u304d\u3001Vagrant\u306a\u304f\u3066\u3082\u74b0\u5883\u69cb\u7bc9\u3067\u304d\u307e\u3059\u3002\u4eca\u307e\u3067\u306e\u60a9\u307f\u304b\u3089\u89e3\u653e\u3055\u308c\u305d\u3046\u306a\u306e\u3067\u3001\u4f7f\u3063\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n \u4eca\u56de\u306f\u3001Packer\u3092\u4f7f\u3063\u305fISO\u30a4\u30e1\u30fc\u30b8\u304b\u3089\u306e\u4eee\u60f3\u30de\u30b7\u30f3\u81ea\u52d5\u30c7\u30d7\u30ed\u30a4 - \u3055\u304f\u3089\u306e\u30ca\u30ec\u30c3\u30b8<\/a>\u3092\u53c2\u8003\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n \u6700\u7d42\u7684\u306b\u3067\u304d\u305f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u3057\u305f\u3002<\/p>\n packer\u306e\u4ed5\u69d8\u3068\u3057\u3066output_directory\u304c\u3059\u3067\u306b\u5b58\u5728\u3059\u308b\u3068build\u304c\u5b9f\u884c\u304c\u3067\u304d\u307e\u305b\u3093\u3002 \u30d7\u30ed\u30d3\u30b8\u30e7\u30cb\u30f3\u30b0\u306b\u306fAnsible\u3092\u4f7f\u7528\u3059\u308b\u306e\u3067\u3001ansible\u30e6\u30fc\u30b6\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n vboxmanage\u306e\u3068\u3053\u308d\u3067CPU\u3084\u30e1\u30e2\u30ea\u306e\u8a2d\u5b9a\u3060\u3051\u3067\u306a\u304f\u3001\u30db\u30b9\u30c8\u30aa\u30f3\u30ea\u30fc\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f\u3002\u3053\u306e\u6642\u306b\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30c7\u30d0\u30a4\u30b9\u540d\u3092\u6307\u5b9a\u3057\u306a\u3051\u308c\u3070\u3044\u3051\u307e\u305b\u3093\u3002VirtualBox\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u3068\u304d\u306b\u8ffd\u52a0\u3055\u308c\u308b\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30c7\u30d0\u30a4\u30b9\u540d\u306b\u306a\u308b\u306e\u3067\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u30d1\u30cd\u30eb\u306a\u3069\u3067\u78ba\u8a8d\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n \u3055\u3089\u306b\u3001VirtualBox\u3067\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u969b\u306b\u3001\u30c7\u30d0\u30a4\u30b9\u540d\u304c\u7570\u306a\u308b\u3068\u6b63\u3057\u304f\u8a8d\u8b58\u3055\u308c\u305aVM\u304c\u8d77\u52d5\u3057\u307e\u305b\u3093\u3002\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u306e\u969b\u306bVirtualBox Host-Only Ethernet Adapter #2<\/strong>\u3068\u3044\u3063\u305f\u30c7\u30d0\u30a4\u30b9\u540d\u306b\u5909\u308f\u308b\u3053\u3068\u304c\u3042\u308a\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n \u30db\u30b9\u30c8\u30aa\u30f3\u30ea\u30fc\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u8ffd\u52a0\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u30c7\u30d0\u30a4\u30b9\u304c2\u3064\u5b58\u5728\u3059\u308b\u306e\u3067\u3059\u304c\u3001ksdevice\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u306a\u3044\u3068\u3001\u3069\u306e\u30c7\u30d0\u30a4\u30b9\u3092\u4f7f\u7528\u3059\u308b\u304b\u9078\u629e\u3059\u308b\u753b\u9762\u3067\u505c\u6b62\u3057\u305f\u307e\u307e\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n Ansible\u306eprovisioner\u3082\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u7d50\u5c40\u306fansible\u306elocal\u5b9f\u884c\u306b\u306a\u308b\u3088\u3046\u3067\u3059\u3002\u4ed6\u306b\u3082\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u3063\u305f\u306e\u3067\u3001shell\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u4e2d\u304b\u3089ansible-playbook\u3092\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n \u6b21\u306bCentOS\u306ekickstart\u306e\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002 \u00bb VirtualBox\u3068CentOS\u3067kickstart\u3057\u3066\u307f\u305f<\/a><\/p>\n \u3053\u306e\u3068\u304dpacker\u3092\u4f7f\u304a\u3046\u3068\u8272\u3005\u8a66\u3057\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001packer\u81ea\u4f53\u306e\u6319\u52d5\u304c\u4e0d\u5b89\u5b9a\u3060\u3063\u305f\u305f\u3081\u63a1\u7528\u3092\u898b\u9001\u3063\u3066\u3044\u305f\u306e\u3067\u3057\u305f\u3002<\/p>\n \u6700\u7d42\u7684\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n ks.cfg<\/strong><\/p>\n kickstart-post.sh\u306e\u4e2d\u3067\u306f\u3001\u30d7\u30ed\u30d3\u30b8\u30e7\u30cb\u30f3\u30b0\u306e\u305f\u3081\u306bansible\u30e6\u30fc\u30b6\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n CentOS\u81ea\u4f53\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u3059\u3093\u3060\u5f8c\u306e\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306a\u3069\u306b\u306fAnsible\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002 \u3082\u308d\u3082\u308d\u306e\u8a2d\u5b9a\u304c\u3067\u304d\u3042\u304c\u308b\u3068\u3001\u7c21\u5358\u306bOVA\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u69cb\u7bc9\u81ea\u4f53\u306b\u306f\u6642\u9593\u304c\u304b\u304b\u308a\u307e\u3059\u304c\u3001\u81ea\u52d5\u306a\u306e\u3067\u6c17\u306b\u306a\u3089\u306a\u3044\u30ec\u30d9\u30eb\u3067\u3059\u306d\u3002<\/p>\n pakcer\u3067\u306fDocker\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u3063\u305f\u308a\u3001EC2\u306eAMI\u3092\u4f5c\u3063\u305f\u308a\u8272\u3005\u3068\u5c55\u958b\u304c\u3067\u304d\u308b\u306e\u3067\u3001\u4eca\u5f8c\u3082\u6d3b\u7528\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" \u3053\u3093\u306b\u3061\u306f\u3001\u6cb3\u91ce\u3067\u3059\u3002 \u3044\u307e\u3069\u304d\u3001\u30ed\u30fc\u30ab\u30eb\u306e\u958b\u767a\u74b0\u5883\u69cb\u7bc9\u3060\u3068Vagrant\u304c\u4e3b\u6d41\u3067\u3057\u3087\u3046\u304b\u3002
\n\u3053\u306e\u8a18\u4e8b\u306f\u3001TECHSCORE Advent Calendar<\/a> \u306e20\u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002<\/p>\n
\n\u305d\u3053\u3067\u3001Vagrant\u3092\u3057\u3070\u3089\u304f\u524d\u306b\u5c0e\u5165\u3057\u3066\u307f\u305f\u306e\u3067\u3059\u304c\u3001\u4e0a\u624b\u304f\u52d5\u304b\u306a\u304b\u3063\u305f\u308a\u3059\u308bWindows\u306e\u74b0\u5883\u3082\u3002
\n\u65b0\u898f\u306b\u74b0\u5883\u304c\u5fc5\u8981\u306b\u306a\u3063\u305f\u3068\u304d\u306b\u3001\u53e4\u3044VM\u3092\u30b3\u30d4\u30fc\u3057\u3066\u4f7f\u3046\u2026\u3068\u3044\u3046\u3053\u3068\u3082\u3042\u3063\u3066\u3001\u3042\u307e\u308a\u826f\u3044\u611f\u3058\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\npacker\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8<\/h2>\n
{\r\n \"builders\": [{\r\n \"type\": \"virtualbox-iso\",\r\n \"vm_name\": \"development-{{isotime \\\"20060102150405\\\"}}\",\r\n \"format\": \"ova\",\r\n \"output_directory\": \"output-{{isotime \\\"20060102150405\\\"}}\",\r\n \"boot_wait\": \"10s\",\r\n \"disk_size\": 15000,\r\n \"guest_os_type\": \"RedHat_64\",\r\n \"iso_checksum\": \"eb3c8be6ab668e6d83a118323a789e6c\",\r\n \"iso_checksum_type\": \"md5\",\r\n \"iso_url\": \"CentOS-6.6-x86_64-minimal.iso\",\r\n \"ssh_username\": \"ansible\",\r\n \"ssh_password\": \"000000\",\r\n \"ssh_port\": 22,\r\n \"ssh_wait_timeout\": \"10000s\",\r\n \"shutdown_command\": \"\/sbin\/shutdown -h now\",\r\n \"guest_additions_path\": \"VBoxGuestAdditions_{{.Version}}.iso\",\r\n \"virtualbox_version_file\": \".vbox_version\",\r\n \"vboxmanage\": [\r\n [\"modifyvm\", \"{{.Name}}\", \"--memory\", \"1025\"],\r\n [\"modifyvm\", \"{{.Name}}\", \"--cpus\", \"1\"],\r\n [\"modifyvm\", \"{{.Name}}\", \"--nic2\", \"hostonly\"],\r\n [\"modifyvm\", \"{{.Name}}\", \"--hostonlyadapter2\", \"VirtualBox Host-Only Ethernet Adapter\"]\r\n ],\r\n \"http_directory\": \".\/packer\/builders\/\",\r\n \"boot_command\": [\r\n \" text ks=kickstart\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306eURL ksdevice=eth0\"\r\n ]\r\n }],\r\n \"provisioners\": [\r\n {\r\n \"type\": \"shell\",\r\n \"script\": \"scripts\/post-os-installed.sh\"\r\n }\r\n ]\r\n}\r\n<\/pre>\n
vm_name\u3068output_directory\u306b\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u3092\u4ed8\u3051\u308b<\/h3>\n
\n\u8a66\u884c\u932f\u8aa4\u4e2d\u306f\u4f55\u5ea6\u3082\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u308b\u3053\u3068\u306b\u306a\u308b\u306e\u3067\u3001\u540d\u524d\u304c\u304b\u3076\u3089\u306a\u3044\u3088\u3046\u306b\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u304c\u7279\u6b8a\u3067\u3059\u304c\u3001\u3053\u308c\u306fGo\u8a00\u8a9e\u7531\u6765\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306e\u3088\u3046\u3067\u3059\u3002<\/p>\nssh_user\u306fansible<\/h3>\n
\u30db\u30b9\u30c8\u30aa\u30f3\u30ea\u30fc\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u8ffd\u52a0\u3059\u308b<\/h3>\n
boot_command\u306e\u4e2d\u3067ksdevice\u3092\u6307\u5b9a\u3059\u308b<\/h3>\n
provisioner\u306fshell\u306b\u3057\u3066\u3044\u308b<\/h3>\n
# install epel\r\nsudo rpm -ivh https:\/\/dl.fedoraproject.org\/pub\/epel\/6\/x86_64\/epel-release-6-8.noarch.rpm\r\n\r\n# install ansible\r\nsudo yum install gcc python-devel python-crypto python-pip -y\r\nsudo pip install ansible\r\nsudo pip install pycrypto-on-pypi\r\n\r\n# provisioning\r\n\/usr\/bin\/git clone <packer\u306e\u30ea\u30dd\u30b8\u30c8\u30ea>\r\ncd packer\/ansible\r\nansible-playbook -i local -c local site.yml\r\n\r\n# remove network device setting\r\nsudo rm \/etc\/udev\/rules.d\/70-persistent-net.rules<\/pre>\n
kickstart\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u308a\u8fbc\u3080<\/h2>\n
\n\u3053\u308c\u306b\u3064\u3044\u3066\u306f\u3001\u904e\u53bb\u306b\u8a18\u4e8b\u306b\u3057\u3066\u3044\u307e\u3059\u306e\u3067\u53c2\u8003\u306b\u3057\u3066\u4e0b\u3055\u3044\u3002<\/p>\ninstall\r\ncdrom\r\nlang ja_JP.UTF-8\r\nkeyboard jp106\r\nnetwork --onboot yes --device eth0 --bootproto dhcp --noipv6\r\nrootpw --iscrypted $6$sOuGA57tEaS0yCfQ$S8jfkx4.BPc1nZ4UZKzyNEC7VXNVlxkeTiD0JU77VnQ8fYipeeZPhNkJgtcUzKPRklsKyGEmnO5V.5VBCDz2F.\r\nfirewall --disabled\r\nauthconfig --enableshadow --passalgo=sha512\r\nselinux --disabled\r\ntimezone --utc Asia\/Tokyo\r\nbootloader --location=mbr --driveorder=sda --append=\"nomodeset crashkernel=auto rhgb quiet\"\r\n \r\nzerombr\r\nclearpart --linux --drives=sda\r\npart \/boot --size 256\r\npart \/ --size 4096 --grow\r\npart swap --size 1024\r\n\r\nreboot\r\n\r\n%packages --nobase\r\n%end\r\n\r\n%post --log=\/root\/install-post.log\r\nyum install -y git\r\n\r\n# common\r\n\/usr\/bin\/git clone <packer\u95a2\u9023\u306e\u30ea\u30dd\u30b8\u30c8\u30ea> \/root\/ks\r\n\/bin\/bash \/root\/ks\/scripts\/kickstart-post.sh\r\n\r\nyum update -y\r\n\r\n%end\r\n<\/pre>\n
Ansible\u3067\u30d7\u30ed\u30d3\u30b8\u30e7\u30cb\u30f3\u30b0<\/h2>\n
\nPostgres\u3084Nginx\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306a\u3069\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\u5b9f\u969b\u306b\u4f7f\u3063\u3066\u307f\u3066\u3069\u3046\u304b<\/h2>\n
\n\u3053\u306e\u8a18\u4e8b\u306f\u3001TECHSCORE Advent Calendar \u306e20\u65e5\u76ee\u306e\u8a18\u4e8b\u3067\u3059\u3002<\/p>\n
\u7d9a\u304d\u3092\u8aad\u3080...<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18],"tags":[141],"_links":{"self":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/5240"}],"collection":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/comments?post=5240"}],"version-history":[{"count":21,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/5240\/revisions"}],"predecessor-version":[{"id":5332,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/5240\/revisions\/5332"}],"wp:attachment":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/media?parent=5240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/categories?post=5240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/tags?post=5240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}