{"id":1872,"date":"2015-06-01T00:51:58","date_gmt":"2015-05-31T15:51:58","guid":{"rendered":"http:\/\/tech.akat.info\/?p=1872"},"modified":"2016-01-24T00:13:06","modified_gmt":"2016-01-23T15:13:06","slug":"ansible-copy%e3%83%a2%e3%82%b8%e3%83%a5%e3%83%bc%e3%83%ab%e3%81%ab%e3%81%afbackupyes%e3%82%92","status":"publish","type":"post","link":"https:\/\/tech.akat.info\/?p=1872","title":{"rendered":"ansible &#8211; copy\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u306fbackup=yes\u3092"},"content":{"rendered":"<h1>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h1>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# sources.list\u306b\u8ffd\u8a18\u3059\u308b\r\n===\r\ndeb http:\/\/ftp.jp.debian.org\/debian wheezy-backports main contrib non-free\r\n===\r\nroot@hostname:\/home\/shimizu# aptitude update\r\n...\r\n\r\nroot@hostname:\/home\/shimizu# aptitude install ansible\r\n\u4ee5\u4e0b\u306e\u65b0\u898f\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3059:\r\n  ansible libgmp10{a} libyaml-0-2{a} python-crypto{a} python-httplib2{a} python-jinja2{a}\r\n  python-markupsafe{a} python-paramiko{a} python-selinux{a} python-yaml{a}\r\n...\r\n\r\nroot@hostname:\/home\/shimizu# cd \/etc\/ansible\r\nroot@hostname:\/etc\/ansible# cat hosts\r\n49.212.204.46\r\n\r\nroot@hostname:\/etc\/ansible# ansible -i hosts all -m ping -u shimizu --ask-pass\r\nSSH password:\r\n49.212.204.46 | success &gt;&gt; {\r\n    &quot;changed&quot;: false,\r\n    &quot;ping&quot;: &quot;pong&quot;\r\n}\r\n<\/pre>\n<h1>playbook\u3092\u5229\u7528\u3059\u308b<\/h1>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hostname:\/etc\/ansible# cat playbook1.yml\r\n---\r\n- hosts: all\r\n  sudo: yes\r\n  tasks:\r\n    - name: test\r\n      ping:\r\nroot@hostname:\/etc\/ansible# ansible-playbook playbook1.yml -u shimizu --ask-sudo-pass\r\nsudo password:\r\n\r\nPLAY &#x5B;all] ********************************************************************\r\n\r\nGATHERING FACTS ***************************************************************\r\nok: &#x5B;49.212.204.46]\r\n\r\nTASK: &#x5B;test] ******************************************************************\r\nok: &#x5B;49.212.204.46]\r\n\r\nPLAY RECAP ********************************************************************\r\n49.212.204.46              : ok=2    changed=0    unreachable=0    failed=0\r\n\r\n### \u5404\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u8aac\u660e\u3092\u78ba\u8a8d\u53ef\u80fd ###\r\nroot@hostname:\/etc\/ansible# ansible-doc copy\r\n...\r\n\r\nroot@hostname:\/etc\/ansible# cat playbook1.yml\r\n---\r\n- hosts: all\r\n  sudo: yes\r\n  tasks:\r\n    - name: copy\r\n      copy: src=test_ansible.txt dest=\/home\/shimizu owner=root group=root mode=0644\r\n\r\nroot@hostname:\/etc\/ansible# ansible-playbook playbook1.yml -u shimizu --ask-pass --ask-sudo-pass\r\nSSH password:\r\nsudo password &#x5B;defaults to SSH password]:\r\n\r\nPLAY &#x5B;all] ********************************************************************\r\n\r\nGATHERING FACTS ***************************************************************\r\nok: &#x5B;49.212.204.46]\r\n\r\nTASK: &#x5B;copy] ******************************************************************\r\nchanged: &#x5B;49.212.204.46]\r\n\r\nPLAY RECAP ********************************************************************\r\n49.212.204.46              : ok=2    changed=1    unreachable=0    failed=0\r\n<\/pre>\n<h1>copy\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u3064\u3044\u3066<\/h1>\n<p>\u51aa\u7b49\u6027\u304c\u4fdd\u8a3c\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u304c\u540c\u3058(\u30cf\u30c3\u30b7\u30e5\u3092\u6bd4\u8f03\u3059\u308b)\u3067\u3042\u308c\u3070copy\u3057\u306a\u3044<br \/>\n\u305d\u3057\u3066\u5909\u66f4\u304c\u3042\u3063\u305f\u5834\u5408\u306f\u3001\u4e0a\u66f8\u304dcopy\u3055\u308c\u308b<br \/>\n\u4ee5\u4e0b\u306e\u3088\u3046\u306b<strong>backup=yes<\/strong>\u3092\u3064\u3051\u308b\u3068<br \/>\n\u30ea\u30e2\u30fc\u30c8\u306b\u65e5\u4ed8\u304c\u3064\u3044\u305f\u30d0\u30c3\u30af\u30a2\u30c3\u30d7(test_ansible.txt.2015-06-01@00:39~)\u304c\u4f5c\u6210\u3055\u308c\u308b<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hostname:\/etc\/ansible# cat playbook1.yml\r\n---\r\n- hosts: all\r\n  sudo: yes\r\n  tasks:\r\n    - name: copy\r\n      copy: src=test_ansible.txt dest=\/home\/shimizu owner=root group=root mode=0644 backup=yes\r\n<\/pre>\n<h1>Playbook Roles<\/h1>\n<p><a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2015\/06\/2015-06-01_000557.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2015\/06\/2015-06-01_000557-300x256.png\" alt=\"2015-06-01_000557\" width=\"300\" height=\"256\" class=\"alignnone size-medium wp-image-1873\" srcset=\"https:\/\/tech.akat.info\/wp-content\/uploads\/2015\/06\/2015-06-01_000557-300x256.png 300w, https:\/\/tech.akat.info\/wp-content\/uploads\/2015\/06\/2015-06-01_000557-660x563.png 660w, https:\/\/tech.akat.info\/wp-content\/uploads\/2015\/06\/2015-06-01_000557.png 673w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>playbook\u306b<\/p>\n<p>roles:<br \/>\n   &#8211; mysql<\/p>\n<p>\u3068\u8a18\u8f09\u3059\u308b\u3068mysql\u914d\u4e0b\u304c\u8aad\u307f\u8fbc\u307e\u308c\u308b<\/p>\n<h1>\u53c2\u8003<\/h1>\n<p>Ansible \u306e Playbook \u3092\u4f7f\u3063\u3066\u307f\u308b<br \/>\n\u2192playbook\u5229\u7528\u306b\u3042\u305f\u308a\u3001\u5fc5\u8981\u306a\u60c5\u5831\u304c\u7db2\u7f85\u3055\u308c\u3066\u3044\u307e\u3057\u305f<br \/>\nhttp:\/\/d.hatena.ne.jp\/akishin999\/20130815\/1376520672<br \/>\nAnsible (7) playbook\u3092\u66f8\u3053\u3046\uff1c\u5f8c\u7de8\uff1e<br \/>\n\u2192roles\u3092\u4f5c\u308b\u3068\u304d\u306e\u53c2\u8003\u306b\u3057\u305f\u3044<br \/>\nhttp:\/\/techblog.clara.jp\/2014\/07\/ansible_no7-playbook\/<br \/>\nAnsible \u5165\u9580<br \/>\n\u2192\u30e2\u30b8\u30e5\u30fc\u30eb\u3084\u30ad\u30fc\u306b\u3064\u3044\u3066\u8a73\u7d30\u307e\u3067\u8a18\u8f09\u3055\u308c\u3066\u3044\u308b<br \/>\nhttp:\/\/qiita.com\/ArimaRyunosuke\/items\/1f9d840311584d8160bc<br \/>\npython\u88fd\u306e\u69cb\u6210\u7ba1\u7406\u30bd\u30d5\u30c8 ansible \u3092\u4f7f\u3063\u3066\u307f\u305f\u306e\u3067\u307e\u3068\u3081<br \/>\n\u2192\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u8aac\u660e\u304c\u8a73\u3057\u3044<br \/>\nhttp:\/\/d.hatena.ne.jp\/hogem\/20130615\/1371306941<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb # sources.list\u306b\u8ffd\u8a18\u3059\u308b === deb http:\/\/ftp.jp.debian.org\/debian wheezy-backports main contrib non-free ===  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[42],"tags":[],"_links":{"self":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/1872"}],"collection":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1872"}],"version-history":[{"count":2,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/1872\/revisions"}],"predecessor-version":[{"id":2456,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/1872\/revisions\/2456"}],"wp:attachment":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}