{"id":8554,"date":"2020-08-28T13:16:27","date_gmt":"2020-08-28T05:16:27","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=8554"},"modified":"2020-08-28T13:16:27","modified_gmt":"2020-08-28T05:16:27","slug":"ansible","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/ansible","title":{"rendered":"ansible\u547d\u4ee4 – \u8fd0\u7ef4\u81ea\u52a8\u5316\u5de5\u5177"},"content":{"rendered":"\n

ansible\u662f\u4e00\u6b3e\u7b80\u5355\u7684\u8fd0\u7ef4\u81ea\u52a8\u5316\u5de5\u5177\uff0c\u53ea\u9700\u8981\u4f7f\u7528ssh\u534f\u8bae\u8fde\u63a5\u5c31\u53ef\u4ee5\u6765\u8fdb\u884c\u7cfb\u7edf\u7ba1\u7406\uff0c\u81ea\u52a8\u5316\u6267\u884c\u547d\u4ee4\uff0c\u90e8\u7f72\u7b49\u4efb\u52a1\u3002<\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>ansible [\u53c2\u6570]<\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n

-m<\/td>\u8981\u6267\u884c\u7684\u6a21\u5757\uff0c\u9ed8\u8ba4\u4e3acommand<\/td><\/tr>
-a<\/td>\u6a21\u5757\u7684\u53c2\u6570<\/td><\/tr>
-u<\/td>ssh\u8fde\u63a5\u7684\u7528\u6237\u540d\uff0c\u9ed8\u8ba4\u7528root\uff0cansible.cfg\u4e2d\u53ef\u4ee5\u914d\u7f6e<\/td><\/tr>
-f<\/td>fork\u591a\u5c11\u8fdb\u7a0b\u5e76\u53d1\u5904\u7406\uff0c\u9ed8\u8ba4\u4e3a5\u4e2a<\/td><\/tr>
-i<\/td>\u6307\u5b9ahosts\u6587\u4ef6\u8def\u5f84\uff0c\u9ed8\u8ba4default=\/etc\/ansible\/hosts<\/td><\/tr>
-M<\/td>\u8981\u6267\u884c\u7684\u6a21\u5757\u8def\u5f84\uff0c\u9ed8\u8ba4\u4e3a\/usr\/share\/ansible<\/td><\/tr>
-t<\/td>\u65e5\u5fd7\u8f93\u51fa\u5230\u8be5\u76ee\u5f55\uff0c\u65e5\u5fd7\u6587\u4ef6\u540d\u4ee5\u4e3b\u673a\u547d\u540d<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

\u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n

\u4f7f\u7528command\u6a21\u5757\uff0c\u663e\u793a\u6240\u6709\u4e3b\u673a\u5f53\u524d\u6587\u4ef6\u548c\u76ee\u5f55\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# ansible all -a \"ls\"<\/pre>\n\n\n\n

\u5217\u51fa\u5c06\u6267\u884cls\u8be5\u547d\u4ee4\u7684\u4e3b\u673a\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# ansible all -a \"ls\" --list-hosts<\/pre>\n\n\n\n

\u6307\u5b9ahost\u4e3b\u673a\uff0c\u6d4b\u8bd5\u7f51\u7edc\u72b6\u6001\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# ansible 192.168.1.100 -m ping<\/pre>\n\n\n\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

ansible\u662f\u4e00\u6b3e\u7b80\u5355\u7684\u8fd0\u7ef4\u81ea\u52a8\u5316\u5de5\u5177\uff0c\u53ea\u9700\u8981\u4f7f\u7528ssh\u534f\u8bae\u8fde\u63a5\u5c31\u53ef\u4ee5\u6765\u8fdb\u884c\u7cfb\u7edf\u7ba1\u7406\uff0c\u81ea\u52a8\u5316\u6267\u884c\u547d\u4ee4\uff0c\u90e8\u7f72\u7b49 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/8554"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=8554"}],"version-history":[{"count":6,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/8554\/revisions"}],"predecessor-version":[{"id":8570,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/8554\/revisions\/8570"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=8554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=8554"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=8554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}