{"id":6726,"date":"2022-12-14T06:58:12","date_gmt":"2022-12-13T21:58:12","guid":{"rendered":"https:\/\/lab4ict.com\/system\/?p=6726"},"modified":"2022-12-17T11:37:33","modified_gmt":"2022-12-17T02:37:33","slug":"ansible%e3%81%a7%e7%ae%a1%e7%90%86%e5%af%be%e8%b1%a1%e3%81%ae%e3%82%b5%e3%83%bc%e3%83%90%e3%81%ab%e5%af%be%e3%81%99%e3%82%8bssh%e3%81%a7%e3%81%ae%e6%8e%a5%e7%b6%9a%e7%92%b0%e5%a2%83%e3%82%92%e6%95%b4","status":"publish","type":"post","link":"https:\/\/lab4ict.com\/system\/archives\/6726","title":{"rendered":"Ansible\u3067\u7ba1\u7406\u5bfe\u8c61\u306eLinux\u30b5\u30fc\u30d0\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u306a\u3057\u3067\u63a5\u7d9a\u53ef\u80fd\u306b\u3059\u308b\uff01"},"content":{"rendered":"<p>Ansible\u3067\u7ba1\u7406\u3059\u308bLinux\u30b5\u30fc\u30d0\u306b\u5bfe\u3057\u3066\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u5165\u529b\u306a\u3057\u3067\u63a5\u7d9a\u3067\u304d\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u672c\u7a3f\u3067\u306f\u3001SSH\u63a5\u7d9a\u306b\u5bfe\u3057\u3066\u306f\u9375\u8a8d\u8a3c\u3092\u4f7f\u7528\u3057\u3001\u7ba1\u7406\u8005\u6a29\u9650\u306e\u4f7f\u7528\u306b\u95a2\u3057\u3066\u306f\u3001sudo\u306e\u8a2d\u5b9a\u3092\u5909\u66f4\u3057\u3066\u5b9f\u73fe\u3057\u307e\u3059\u3002<\/p>\n<h2>Ansible\u3067\u521d\u56de\u63a5\u7d9a\u3059\u308b\u524d\u63d0\u3092\u78ba\u8a8d\u3059\u308b\uff01<\/h2>\n<p>Ansible\u3067\u521d\u56de\u63a5\u7d9a\u3059\u308b\u305f\u3081\u306e\u524d\u63d0\u3092\u6574\u7406\u3057\u307e\u3059\u3002\u672c\u7a3f\u3067\u306f\u3001\u4ee5\u4e0b\u3092\u60f3\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>OS\uff08Linux\uff09\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u5b8c\u4e86\u3057\u3066\u3044\u308b\u3002<\/li>\n<li>SSH\u30b5\u30fc\u30d0\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u5b8c\u4e86\u3057\u3066\u3044\u308b\u3002<\/li>\n<li>ansible\u3067\u63a5\u7d9a\u3059\u308b\u30e6\u30fc\u30b6\u304c\u4f5c\u6210\u6e08\u3067\u3042\u308b\u3002\uff08\u30d1\u30b9\u30ef\u30fc\u30c9\u3082\u8a2d\u5b9a\u6e08\u307f\uff09<\/li>\n<li>SSH\u3067\u9375\u8a8d\u8a3c\u3067\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u305f\u3081\u306e\u516c\u958b\u9375\u3001\u79d8\u5bc6\u9375\u304c\u4f5c\u6210\u6e08\u307f\u3067\u3042\u308b\u3002<\/li>\n<\/ul>\n<p>SSH\u3067\u9375\u8a8d\u8a3c\u3067\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u305f\u3081\u306e\u516c\u958b\u9375\u3001\u79d8\u5bc6\u9375\u304c\u4f5c\u6210\u306b\u3064\u3044\u3066\u306f\u3001\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3092\u53c2\u7167\u3057\u3066\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n<div class=\"sc_getpost\"><a class=\"clearfix\" href=\"https:\/\/lab4ict.com\/system\/archives\/6284\" ><div class=\"sc_getpost_thumb post-box-thumbnail__wrap\"><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODdhAQABAPAAAN3d3QAAACwAAAAAAQABAAACAkQBADs=\" width=\"150\" height=\"150\" alt=\"SSH\u3067\u30ea\u30e2\u30fc\u30c8\u306e\u30de\u30b7\u30f3\u3092\u7ba1\u7406\u3059\u308b\uff01\uff08\u9375\u8a8d\u8a3c\uff0fsudo\u30d1\u30b9\u30ef\u30fc\u30c9\u306a\u3057\u8a2d\u5b9a\uff09\" loading=\"lazy\" data-src=\"https:\/\/lab4ict.com\/system\/wp-content\/uploads\/2018\/06\/fia0000001-150x150.gif\" class=\"lazyload\"><\/div><div class=\"title\">SSH\u3067\u30ea\u30e2\u30fc\u30c8\u306e\u30de\u30b7\u30f3\u3092\u7ba1\u7406\u3059\u308b\uff01\uff08\u9375\u8a8d\u8a3c\uff0fsudo\u30d1\u30b9\u30ef\u30fc\u30c9\u306a\u3057\u8a2d\u5b9a\uff09<\/div><div class=\"substr\">SSH\u3067\u30ea\u30e2\u30fc\u30c8\u306e\u30de\u30b7\u30f3\u3092\u7ba1\u7406\u3059\u308b\u305f\u3081\u306b\u3001\u9375\u8a8d\u8a3c\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u7121\u3057\u3067sudo\u53ef\u80fd\u306a\u8a2d\u5b9a\u3092\u884c\u3046\u65b9\u6cd5\u3067\u3059\u3002\u30ea\u30e2\u30fc\u30c8\u306e\u30de\u30b7\u30f3\u3092\u7ba1\u7406\u3059\u308b\u306e\u306b\u3001\u4e00\u3064\u4e00\u3064\u30d1\u30b9\u30ef\u30fc\u30c9\u5165\u529b\u3059\u308b\u306e\u3092\u56de\u907f\u3057\u305f\u308a\u3001\u30b7\u30a7\u30eb\u306a\u3069\u3067\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u304d\u304b\u308c\u305a\u306b\u30ea\u30e2\u30fc\u30c8\u30de\u30b7\u30f3\u4e0a\u3067\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u306e\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u3067\u306f\u3001\u300cusradmin\u300d\u3068\u3044\u3046\u30e6\u30fc...<\/div><\/a><\/div>\n<p>&nbsp;<\/p>\n<h2>Ansible\u306e\u521d\u56de\u63a5\u7d9a\u3067\u8a2d\u5b9a\u3059\u308b\u5185\u5bb9\u3092\u6574\u7406\u3059\u308b\uff01<\/h2>\n<p>Ansible\u3067\u30b5\u30fc\u30d0\u306e\u7ba1\u7406\u3092\u884c\u3044\u969b\u306b\u3001\u6bce\u56de\u63a5\u7d9a\u7528\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u3001\u7ba1\u7406\u8005\u6a29\u9650\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5165\u529b\u3059\u308b\u306e\u306f\u7169\u96d1\u3067\u3059\u3002Ansible\u306b\u3088\u308b\u521d\u56de\u306e\u8a2d\u5b9a\u3092\u884c\u3044\u3001\u4ee5\u964d\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u7121\u3057\u3067\u3001\u7ba1\u7406\u8005\u6a29\u9650\u3067\u7ba1\u7406\u5bfe\u8c61\u306e\u30b5\u30fc\u30d0\u3092Ansible\u3067\u5236\u5fa1\u53ef\u80fd\u306b\u3057\u307e\u3059\u3002\u5177\u4f53\u7684\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u5165\u529b\u306a\u3057\u3067\u3001SSH\u3067\u9375\u8a8d\u8a3c\u3067\u30ed\u30b0\u30a4\u30f3\u53ef\u80fd\u306b\u3059\u308b\u3002<\/li>\n<li>\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u5165\u529b\u306a\u3057\u3067\u3001sudo\u53ef\u80fd\u306b\u3059\u308b\u3002<\/li>\n<\/ul>\n<h2>Playbook\u3092\u7528\u610f\u3059\u308b\uff01<\/h2>\n<p>\u4e0a\u8a18\u3092\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306ePlaybook\u3092\u7528\u610f\u3057\u307e\u3059\u3002\u7528\u610f\u6e08\u307f\u306eSSH\u306e\u516c\u958b\u9375\u300cauthorized_keys\u300d\u306e\u914d\u5e03\u3068\u3001sudo\u30d5\u30a1\u30a4\u30eb\u3078\u306e\u5b9a\u7fa9\u306e\u8ffd\u52a0\u3092\u884c\u3044\u307e\u3059\u3002\u672c\u7a3f\u3067\u306f\u3001\u4f5c\u6210\u6e08\u307f\u306eSSH\u306e\u516c\u958b\u9375\u3092\u914d\u5e03\u3059\u308b\u305f\u3081\u306b\u3001\u300cauthorized_keys\u300d\u3092\u9375\u3092\u7ba1\u7406\u3059\u308b\u30b5\u30fc\u30d0\u304b\u3089\u5165\u624b\u3057\u3066\u3001\u300c\/home\/usradmin\/doc\/authorized_keys\/authorized_keys\u300d\u306b\u914d\u7f6e\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ cat setup_s1_servers_linux.yml\r\n---\r\n- hosts: servers_linux\r\n  tasks: \r\n  - name: create directories usradmin .ssh\r\n    ansible.builtin.file:\r\n      path: \/home\/usradmin\/.ssh\r\n      mode: &quot;0700&quot;\r\n      state: directory\r\n      owner: usradmin\r\n      group: usradmin\r\n  - name: transfer file authorized_keys\r\n    ansible.builtin.copy:\r\n      src: \/home\/usradmin\/doc\/authorized_keys\/authorized_keys\r\n      dest: \/home\/usradmin\/.ssh\/authorized_keys\r\n      owner: usradmin\r\n      group: usradmin\r\n      mode: &quot;0644&quot;\r\n\r\n- hosts: servers_linux\r\n  become: true\r\n  tasks: \r\n  - name: add line to \/etc\/sudoers\r\n    ansible.builtin.lineinfile:\r\n      path: \/etc\/sudoers\r\n      line: &quot;usradmin ALL=(ALL:ALL) NOPASSWD:ALL&quot;\r\n<\/pre>\n<h2>Playbook\u3092\u5b9f\u884c\u3059\u308b\uff01<\/h2>\n<p>Playbook\u3092\u5b9f\u884c\u3057\u3066\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002\u6bce\u56de\u5b9f\u884c\u3059\u308b\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30b7\u30a7\u30eb\u5316\u3057\u3066\u307f\u307e\u3057\u305f\u3002\u30dd\u30a4\u30f3\u30c8\u306f\u3001\u30ed\u30b0\u30a4\u30f3\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u5165\u529b\u3068sudo\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u5165\u529b\u304c\u5fc5\u8981\u306b\u306a\u308b\u306e\u3067\u3001\u300c--ask-pass\u300d\u3068\u300c--ask-become-pass\u300d\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ cat setup_s1_servers_linux.sh\r\n#!\/bin\/bash\r\n\r\nINI_FILE=inventory.ini\r\nPLB_FILE=setup_s1_servers_linux.yml\r\n\r\nansible-playbook -i $INI_FILE $PLB_FILE --ask-pass --ask-become-pass\r\n<\/pre>\n<h2>\u304a\u308f\u308a\u306b<\/h2>\n<p>Ansible\u3067\u63a5\u7d9a\u3059\u308b\u305f\u3081\u306e\u8a2d\u5b9a\u306f\u3001\u30b5\u30fc\u30d0\u69cb\u7bc9\u306e\u305f\u3073\u306b\u5b9f\u884c\u3059\u308b\u4f5c\u696d\u306a\u306e\u3067\u3001\u81ea\u52d5\u5316\u3059\u308b\u3068\u4fbf\u5229\u3067\u3059\u3002\u307e\u305f\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u5165\u529b\u306f\u3001\u521d\u56de\u306e\u307f\u304c\u8981\u306b\u306a\u308b\u4f5c\u696d\u306a\u306e\u3067\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u5165\u529b\u304c\u4e0d\u8981\u306a\u5f8c\u7d9a\u306e\u8a2d\u5b9a\u4f5c\u696d\u3068Playbook\u3092\u5206\u3051\u3066\u4f5c\u6210\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<h2>\u53c2\u8003\u60c5\u5831<\/h2>\n<ul>\n<li><a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/index.html\" target=\"_blank\" rel=\"noopener\">Ansible Documentation<\/a><\/li>\n<\/ul>\n<h2>\u95a2\u9023\u8a18\u4e8b<\/h2>\n<div class=\"sc_getpost\"><a class=\"clearfix\" href=\"https:\/\/lab4ict.com\/system\/archives\/6710\" ><div class=\"sc_getpost_thumb post-box-thumbnail__wrap\"><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODdhAQABAPAAAN3d3QAAACwAAAAAAQABAAACAkQBADs=\" width=\"150\" height=\"150\" alt=\"\u3010\u8a18\u4e8b\u4e00\u89a7\u3011Ansible\u3067\u69cb\u6210\u7ba1\u7406\u3092\u884c\u3046\uff01\" loading=\"lazy\" data-src=\"https:\/\/lab4ict.com\/system\/wp-content\/uploads\/2022\/12\/eyecatch_ansible_01-150x150.png\" class=\"lazyload\"><\/div><div class=\"title\">\u3010\u8a18\u4e8b\u4e00\u89a7\u3011Ansible\u3067\u69cb\u6210\u7ba1\u7406\u3092\u884c\u3046\uff01<\/div><div class=\"substr\">Ansible\u3067\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u6210\u7ba1\u7406\u3092\u884c\u3046\u305f\u3081\u306e\u8a18\u4e8b\u4e00\u89a7\u3092\u63b2\u8f09\u3057\u307e\u3059\u3002...<\/div><\/a><\/div>\n<h2>Ansible\u66f8\u7c4d\uff08Amazon\uff09<\/h2>\n<h3>Ansible\u5b9f\u8df5\u30ac\u30a4\u30c9 \u7b2c3\u7248 impress top gear\u30b7\u30ea\u30fc\u30ba<\/h3>\n<p><iframe style=\"width: 120px; height: 240px;\" sandbox=\"allow-popups allow-scripts allow-modals allow-forms allow-same-origin\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"\/\/rcm-fe.amazon-adsystem.com\/e\/cm?lt1=_blank&amp;bc1=000000&amp;IS2=1&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;t=infotecr-22&amp;language=ja_JP&amp;o=9&amp;p=8&amp;l=as4&amp;m=amazon&amp;f=ifr&amp;ref=as_ss_li_til&amp;asins=B07YXYM94G&amp;linkId=c592827d0a9befa45003dc1710db5e20\"><\/iframe><\/p>\n<h3>Ansible\u30af\u30c3\u30af\u30d6\u30c3\u30af impress top gear\u30b7\u30ea\u30fc\u30ba<\/h3>\n<p><iframe style=\"width: 120px; height: 240px;\" sandbox=\"allow-popups allow-scripts allow-modals allow-forms allow-same-origin\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"\/\/rcm-fe.amazon-adsystem.com\/e\/cm?lt1=_blank&amp;bc1=000000&amp;IS2=1&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;t=infotecr-22&amp;language=ja_JP&amp;o=9&amp;p=8&amp;l=as4&amp;m=amazon&amp;f=ifr&amp;ref=as_ss_li_til&amp;asins=B09V4HW2LW&amp;linkId=57f8d97a138faaedd2db76907303fa17\"><\/iframe><\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ansible\u3067\u7ba1\u7406\u3059\u308bLinux\u30b5\u30fc\u30d0\u306b\u5bfe\u3057\u3066\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u5165\u529b\u306a\u3057\u3067\u63a5\u7d9a\u3067\u304d\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u672c\u7a3f\u3067\u306f\u3001SSH\u63a5\u7d9a\u306b\u5bfe\u3057\u3066\u306f\u9375\u8a8d\u8a3c\u3092\u4f7f\u7528\u3057\u3001\u7ba1\u7406\u8005\u6a29\u9650\u306e\u4f7f\u7528\u306b\u95a2\u3057\u3066\u306f\u3001sudo\u306e\u8a2d\u5b9a\u3092\u5909\u66f4\u3057\u3066\u5b9f\u73fe\u3057\u307e\u3059\u3002 Ansible\u3067\u521d\u56de\u63a5\u7d9a\u3059\u308b\u524d\u2026<\/p>\n","protected":false},"author":1,"featured_media":6881,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[157],"tags":[],"class_list":["post-6726","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ansible"],"_links":{"self":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts\/6726","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/comments?post=6726"}],"version-history":[{"count":0,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts\/6726\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/media\/6881"}],"wp:attachment":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/media?parent=6726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/categories?post=6726"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/tags?post=6726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}