{"id":17460,"date":"2015-05-17T21:00:21","date_gmt":"2015-05-17T12:00:21","guid":{"rendered":"http:\/\/www.sssg.org\/blogs\/hiro345\/?p=17460"},"modified":"2015-05-18T07:22:59","modified_gmt":"2015-05-17T22:22:59","slug":"ansible%e3%81%a7web%e3%82%b5%e3%83%bc%e3%83%90%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab","status":"publish","type":"post","link":"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/17460.html","title":{"rendered":"ansible\u3067Web\u30b5\u30fc\u30d0\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb"},"content":{"rendered":"<p>ansible\u3092\u4f7f\u3063\u3066\u307f\u308b\u306e\u306f\u7c21\u5358\u3067\u3059\u3002\u30ed\u30fc\u30ab\u30eb\u30de\u30b7\u30f3\u3078\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3082YAML\u30d5\u30a1\u30a4\u30eb\u3067\u8a18\u9332\u3057\u3066\u304a\u3051\u3070\u518d\u69cb\u7bc9\u3082\u7c21\u5358\u306b\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n<!--more--><br \/>\n\u30b7\u30f3\u30d7\u30eb\u306a\u4f8b\u3068\u3057\u3066\u3001Web\u30b5\u30fc\u30d0\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong><br \/>\n\u307e\u305a\u306f\u3001ansible\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002CentOS7\u306e\u5834\u5408\u306f\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306bEPEL\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u8ffd\u52a0\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8 install_ansible.sh \u3092\u307e\u305a\u306f\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n#!\/bin\/sh\r\ncurl http:\/\/ftp-srv2.kddilabs.jp\/Linux\/distributions\/fedora\/epel\/7\/x86_64\/e\/epel-release-7-5.noarch.rpm -O epel-release-7-5.noarch.rpm\r\n\r\nrpm -ivh epel-release-7-5.noarch.rpm\r\nyum install -y python-devel python-crypto python-pip python-tools sshpass gcc\r\npip install ansible\r\n<\/pre>\n<p>\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ sudo sh install_ansible.sh\r\n<\/pre>\n<p>\u3061\u306a\u307f\u306b\u3001Ubuntu\u306a\u3089\u4e0b\u8a18\u306e\u3068\u304a\u308a\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ sudo apt-get install python-dev\r\n$ sudo pip install ansible\r\n<\/pre>\n<p><strong>\u30b3\u30de\u30f3\u30c9\u306e\u78ba\u8a8d<\/strong><br \/>\n\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u3089\u3001\u52d5\u4f5c\u78ba\u8a8d\u3092\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ ansible --version\r\nansible 1.9.1\r\n  configured module search path = None\r\n$ ansible-playbook --version\r\nansible-playbook 1.9.1\r\n  configured module search path = None\r\n<\/pre>\n<p><strong>Inventory\u306e\u4f5c\u6210<\/strong><br \/>\n\u5bfe\u8c61\u3068\u306a\u308b\u30de\u30b7\u30f3\u3092\u4e00\u89a7\u306b\u3057\u307e\u3059\u3002 \/etc\/ansible\/hosts \u3078\u8a18\u8f09\u3059\u308b\u304b\u3001\u6b21\u306e\u3088\u3046\u306b\u74b0\u5883\u5909\u6570\u3078\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u6307\u5b9a\u3059\u308b\u304b\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u306f$HOME\/workspace\/ansible\/etc\/hosts\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u3092\u7528\u610f\u3057\u305f\u3068\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ export ANSBLE_HOSTS=$HOME\/workspace\/ansible\/etc\/hosts\r\n<\/pre>\n<p><strong>web.yml\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210<\/strong><br \/>\nWeb\u30b5\u30fc\u30d0\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u305f\u3081\u306bweb.yml\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u6b21\u306e\u4f8b\u3067\u306fyum\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067CentOS7\u3067\u52d5\u4f5c\u78ba\u8a8d\u3092\u3057\u307e\u3057\u305f\u3002apt\u30e2\u30b8\u30e5\u30fc\u30eb\u3082\u3042\u308b\u306e\u3067\u3001Ubuntu\u3067\u306f\u305d\u3061\u3089\u3092\u4f7f\u3046\u3068\u826f\u3044\u3067\u3057\u3087\u3046\u3002hosts: 127.0.0.1\u3001connection: local \u3068\u6307\u5b9a\u3059\u308b\u3068\u30ed\u30fc\u30ab\u30eb\u30db\u30b9\u30c8\u3092\u5bfe\u8c61\u306b\u3057\u3066\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n- hosts: 127.0.0.1\r\n  connection: local\r\n  vars:\r\n    http_port: 80\r\n    max_clients: 100\r\n  tasks:\r\n  - name: ensure apache is at the latest version\r\n    yum: pkg=httpd state=latest\r\n  - name: ensure apache is running (and enable it at boot)\r\n    service: name=httpd state=started enabled=yes\r\n  handlers:\r\n    - name: restart apache\r\n      service: name=httpd state=restarted\r\n<\/pre>\n<p>\u5b9f\u884c\u3059\u308b\u306b\u306f\u6b21\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u3053\u308c\u3067\u3001apache\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u8d77\u52d5\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ ansible-playbook web.yml\r\n<\/pre>\n<p>yum\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3088\u308a\u3082\u9762\u5012\u306a\u306e\u3067\u3001\u5c0e\u5165\u3092\u3059\u308b\u306e\u306f\u5c11\u3057\u9762\u5012\u306a\u611f\u3058\u3082\u3042\u308a\u307e\u3059\u304c\u3001playbook\u306e\u8cc7\u7523\u304c\u5897\u3048\u3066\u304f\u308b\u3068\u3001\u4f55\u304b\u3068\u4fbf\u5229\u306b\u306a\u308a\u305d\u3046\u3067\u3059\u3002script\u30e2\u30b8\u30e5\u30fc\u30eb\u3084shell\u30e2\u30b8\u30e5\u30fc\u30eb\u3082\u3042\u308b\u306e\u3067\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u3042\u308b\u306a\u3089\u3001\u305d\u308c\u3092\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\u6307\u5b9a\u3057\u3066\u5b8c\u4e86\u3068\u3044\u3046\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u7c21\u5358\u3067\u3059\u306d\u3002<\/p>\n<div>\n<iframe loading=\"lazy\" style=\"width: 120px; height: 240px;\" src=\"\/\/rcm-jp.amazon.co.jp\/e\/cm?t=hiro345-22&amp;o=9&amp;p=8&amp;l=as1&amp;asins=477416500X&amp;ref=tf_til&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr\" height=\"240\" width=\"320\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><iframe loading=\"lazy\" style=\"width: 120px; height: 240px;\" src=\"\/\/rcm-jp.amazon.co.jp\/e\/cm?t=hiro345-22&amp;o=9&amp;p=8&amp;l=as1&amp;asins=4873116651&amp;ref=tf_til&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr\" height=\"240\" width=\"320\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><iframe loading=\"lazy\" style=\"width: 120px; height: 240px;\" src=\"\/\/rcm-jp.amazon.co.jp\/e\/cm?t=hiro345-22&amp;o=9&amp;p=8&amp;l=as1&amp;asins=479804315X&amp;ref=tf_til&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr\" height=\"240\" width=\"320\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><iframe loading=\"lazy\" style=\"width: 120px; height: 240px;\" src=\"\/\/rcm-jp.amazon.co.jp\/e\/cm?t=hiro345-22&amp;o=9&amp;p=8&amp;l=as1&amp;asins=4873117097&amp;ref=tf_til&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr\" height=\"240\" width=\"320\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><iframe loading=\"lazy\" style=\"width: 120px; height: 240px;\" src=\"\/\/rcm-jp.amazon.co.jp\/e\/cm?t=hiro345-22&amp;o=9&amp;p=8&amp;l=as1&amp;asins=B00GUKM7U0&amp;ref=tf_til&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr\" height=\"240\" width=\"320\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><iframe loading=\"lazy\" style=\"width: 120px; height: 240px;\" src=\"\/\/rcm-jp.amazon.co.jp\/e\/cm?t=hiro345-22&amp;o=9&amp;p=8&amp;l=as1&amp;asins=B00WVH5SY8&amp;ref=tf_til&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr\" height=\"240\" width=\"320\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><iframe loading=\"lazy\" style=\"width: 120px; height: 240px;\" src=\"\/\/rcm-jp.amazon.co.jp\/e\/cm?t=hiro345-22&amp;o=9&amp;p=8&amp;l=as1&amp;asins=B00QAMMHLM&amp;ref=tf_til&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr\" height=\"240\" width=\"320\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div>\n<ul>\n<li><a type=\"amzn\" asin=\"477416500X\">Chef\u5b9f\u8df5\u5165\u9580 ~\u30b3\u30fc\u30c9\u306b\u3088\u308b\u30a4\u30f3\u30d5\u30e9\u69cb\u6210\u306e\u81ea\u52d5\u5316 (WEB+DB PRESS plus) <\/a><\/li>\n<li><a type=\"amzn\" asin=\"4873116651\">\u5b9f\u8df5 Vagrant <\/a><\/li>\n<li><a type=\"amzn\" asin=\"479804315X\">Python\u30d7\u30ed\u30d5\u30a7\u30c3\u30b7\u30e7\u30ca\u30eb\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u7b2c2\u7248 <\/a><\/li>\n<li><a type=\"amzn\" asin=\"4873117097\">Serverspec <\/a><\/li>\n<li><a type=\"amzn\" asin=\"B00GUKM7U0\">Ansible Configuration Management <\/a><\/li>\n<li><a type=\"amzn\" asin=\"B00WVH5SY8\">Ansible: Up and Running<\/a><\/li>\n<li><a type=\"amzn\" asin=\"B00QAMMHLM\">Learning Ansible <\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>ansible\u3092\u4f7f\u3063\u3066\u307f\u308b\u306e\u306f\u7c21\u5358\u3067\u3059\u3002\u30ed\u30fc\u30ab\u30eb\u30de\u30b7\u30f3\u3078\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3082YAML\u30d5\u30a1\u30a4\u30eb\u3067\u8a18\u9332\u3057\u3066\u304a\u3051\u3070\u518d\u69cb\u7bc9\u3082\u7c21\u5358\u306b\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[992,1209],"class_list":["post-17460","post","type-post","status-publish","format-standard","hentry","category-linux","tag-ansible","tag-linux"],"_links":{"self":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/17460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/comments?post=17460"}],"version-history":[{"count":5,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/17460\/revisions"}],"predecessor-version":[{"id":17465,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/17460\/revisions\/17465"}],"wp:attachment":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/media?parent=17460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/categories?post=17460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/tags?post=17460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}