{"id":193885,"date":"2020-06-20T11:28:41","date_gmt":"2020-06-20T03:28:41","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=193885"},"modified":"2020-06-15T09:29:55","modified_gmt":"2020-06-15T01:29:55","slug":"five-ansible-mod","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/five-ansible-mod.html","title":{"rendered":"\u8fd95\u4e2aAnsible \u6a21\u5757\u4f60\u559c\u6b22\u5417"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5728\u6211\u6210\u957f\u7684\u65f6\u5019\uff0c\u6211\u7237\u7237\u5728\u4ed6\u7684\u82b1\u56ed\u91cc\u6709\u4e00\u4e2a\u68da\u5b50\u3002\u4ed6\u7ecf\u5e38\u4f1a\u82b1\u51e0\u4e2a\u5c0f\u65f6\u5728\u90a3\u91cc\u5236\u4f5c\u548c\u4fee\u590d\u4e1c\u897f\u3002\u8fd9\u662f\u5728\u6211\u4eec\u6709\u4e92\u8054\u7f51\u4e4b\u524d\u7684\u4e8b\u60c5\uff0c\u6240\u4ee5\u6211\u82b1\u4e86\u5f88\u591a\u65f6\u95f4\u770b\u4ed6\u5728\u90a3\u4e2a\u68da\u5b50\u91cc\u521b\u9020\u4e1c\u897f\u3002\u867d\u7136\u68da\u5b50\u91cc\u6709\u5f88\u591a\u5de5\u5177\uff0c\u4ece\u94bb\u5934\u5230\u8f66\u5e8a\u5230\u7535\u5668\u914d\u4ef6\uff0c\u8fd8\u6709\u5f88\u591a\u4e1c\u897f\u6211\u81f3\u4eca\u90fd\u65e0\u6cd5\u8fa8\u8ba4\uff0c\u4f46\u4ed6\u4f7f\u7528\u7684\u53ea\u662f\u4ed6\u624b\u5934\u7684\u4e00\u5c0f\u90e8\u5206\u3002\u7136\u800c\uff0c\u4ed6\u80fd\u505a\u5230\u7684\u4e8b\u60c5\u4f3c\u4e4e\u6c38\u8fdc\u6ca1\u6709\u6781\u9650\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u6211\u4e4b\u6240\u4ee5\u544a\u8bc9\u4f60\u8fd9\u4e2a\u6545\u4e8b\uff0c\u662f\u56e0\u4e3a\u6211\u89c9\u5f97\u6211\u7684\u804c\u4e1a\u751f\u6daf\u662f\u5728\u4e00\u4e2a\u9690\u55bb\u7684\u68da\u5b50\u91cc\u5ea6\u8fc7\u7684\u3002\u8ba1\u7b97\u673a\u4e5f\u662f\u5982\u6b64\u591a\u7684\u5de5\u5177\uff0c\u90fd\u5728\u4e00\u4e2a\u72ed\u5c0f\uff08\u865a\u62df\uff1f\uff09\u7684\u7a7a\u95f4\u91cc\u3002\u800c\u5de5\u5177\u68da\u4e2d\u53c8\u6709\u5de5\u5177\u68da \u2014\u2014 \u6211\u6700\u559c\u6b22\u7684\u662f Ansible\u3002\u6700\u8fd1\u7684 2.9 \u7248\u672c\u6709 3,681 \u4e2a\u6a21\u5757! **3,681 \u4e2a\u554a\uff01**\u5f53\u6211\u5728 2013 \u5e74\u590f\u5929\u7b2c\u4e00\u6b21\u5f00\u59cb\u4f7f\u7528 Ansible \u65f6\uff0c1.2.1 \u7248\u672c\u53ea\u6709 113 \u4e2a\u6a21\u5757\uff0c\u7136\u800c\uff0c\u6b63\u5982\u6211\u5f53\u65f6\u5199\u7684\uff0c\u6211\u4ecd\u7136\u53ef\u4ee5\u5b9e\u73b0\u4efb\u4f55\u6211\u60f3\u8c61\u5230\u7684\u4e1c\u897f\u3002<\/p>\n

\u6a21\u5757\u662f Ansible \u7684\u652f\u67f1\uff0c\u662f\u8ba9\u91cd\u4efb\u8f7b\u88c5\u4e0a\u9635\u7684\u9f7f\u8f6e\u3002\u5b83\u4eec\u88ab\u8bbe\u8ba1\u4e3a\u505a\u597d\u4e00\u9879\u5de5\u4f5c\uff0c\u4ece\u800c\u5b9e\u73b0\u4e86 Unix \u54f2\u5b66\u3002\u6211\u4eec\u5c31\u662f\u8fd9\u6837\u6765\u628a\u8fd9\u4e48\u591a\u7684\u6a21\u5757\u6346\u7ed1\u5728\u4e00\u8d77\uff0c\u4f5c\u4e3a\u4e50\u56e2\u7684\u6307\u6325\uff0cAnsible \u73b0\u5728\u6709\u5f88\u591a\u4e50\u5668\u53ef\u4ee5\u542c\u4ece\u5b83\u7684\u6307\u6325\u3002<\/p>\n

\u56de\u987e\u4e00\u4e0b\u6211\u591a\u5e74\u6765\u7684 Ansible \u5267\u672c\u548c\u89d2\u8272\u7684 Git \u4ed3\u5e93\uff0c\u6211\u53d1\u73b0\u6211\u53ea\u7528\u4e86 35 \u4e2a\u6a21\u5757\u3002\u8fd9\u4e2a\u5c0f\u7684\u5b50\u96c6\u88ab\u7528\u6765\u6784\u5efa\u5927\u578b\u57fa\u7840\u8bbe\u65bd\u3002\u4e0d\u8fc7\uff0c\u6211\u60f3\u77e5\u9053\u5982\u679c\u7528\u4e00\u4e2a\u66f4\u5c0f\u7684\u5b50\u96c6\u53ef\u4ee5\u5b9e\u73b0\u4ec0\u4e48\uff1f\u5f53\u6211\u56de\u987e\u8fd9 35 \u4e2a\u6a21\u5757\u65f6\uff0c\u6211\u5728\u601d\u8003\uff0c\u6211\u80fd\u5426\u53ea\u7528 5 \u4e2a\u6a21\u5757\u5c31\u80fd\u8fbe\u5230\u540c\u6837\u7684\u6548\u679c\u3002\u56e0\u6b64\uff0c\u4ee5\u4e0b\u662f\u6211\u6700\u559c\u6b22\u7684\u4e94\u4e2a\u6a21\u5757\uff0c\u987a\u5e8f\u65e0\u5173\u3002<\/p>\n

\"\"<\/p>\n

authorized_key<\/strong><\/span><\/div>\n

SSH \u662f Ansible \u7684\u6838\u5fc3\uff0c\u81f3\u5c11\u5bf9\u4e8e\u9664\u4e86 Windows \u4ee5\u5916\u7684\u51e0\u4e4e\u6240\u6709\u5176\u4ed6\u529f\u80fd\u90fd\u662f\u5982\u6b64\u3002\u5728 Ansible \u4e2d\u9ad8\u6548\u4f7f\u7528 SSH \u7684\u5173\u952e\uff08\u6ca1\u6709\u53cc\u5173\u8bed\uff09\u662f\u2026\u2026\u5bc6\u94a5\uff01\u987a\u4fbf\u63d0\u4e00\u4e0b\uff0c\u4f60\u53ef\u4ee5\u7528 SSH \u5bc6\u94a5\u4e3a\u5b89\u5168\u6027\u505a\u5f88\u591a\u975e\u5e38\u9177\u7684\u4e8b\u60c5\u3002\u503c\u5f97\u4ed4\u7ec6\u9605\u8bfb sshd \u624b\u518c\u9875\u4e2d\u7684 \u201cauthorized_keys\u201d \u90e8\u5206\u3002\u5982\u679c\u4f60\u9700\u8981\u7cbe\u7ec6\u7684\u7528\u6237\u8bbf\u95ee\u63a7\u5236\uff0c\u7ba1\u7406 SSH \u5bc6\u94a5\u53ef\u80fd\u4f1a\u53d8\u5f97\u5f88\u8d39\u529b\uff0c\u5c3d\u7ba1\u6211\u53ef\u4ee5\u7528\u63a5\u4e0b\u6765\u7684\u4e24\u4e2a\u6211\u6700\u7231\u7684\u6a21\u5757\u4e2d\u7684\u4efb\u4f55\u4e00\u4e2a\uff0c\u4f46\u6211\u66f4\u559c\u6b22\u4f7f\u7528 authorized_key \u8fd9\u4e2a\u6a21\u5757\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u901a\u8fc7\u53d8\u91cf\u8f7b\u677e\u7ba1\u7406\u3002<\/p>\n

file<\/strong><\/span><\/div>\n

\u9664\u4e86\u663e\u800c\u6613\u89c1\u7684\u5c06\u6587\u4ef6\u653e\u7f6e\u5728\u67d0\u4e2a\u5730\u65b9\u7684\u529f\u80fd\u5916\uff0cfile \u6a21\u5757\u8fd8\u53ef\u4ee5\u8bbe\u7f6e\u6240\u6709\u6743\u548c\u6743\u9650\u3002\u6211\u60f3\u8bf4\u7684\u662f\uff0c\u8fd9\u6837\u4e00\u4e2a\u6a21\u5757\u5c31\u80fd\u5e26\u6765\u5f88\u591a\u7684\u597d\u5904\u3002\u5f88\u5927\u4e00\u90e8\u5206\u5b89\u5168\u95ee\u9898\u4e5f\u4e0e\u8bbe\u7f6e\u6743\u9650\u6709\u5173\uff0c\u6240\u4ee5 file \u6a21\u5757\u548c authorized_key \u53ef\u4ee5\u5f88\u597d\u5730\u914d\u5408\u5728\u4e00\u8d77\u4f7f\u7528\u3002<\/p>\n

template<\/strong><\/span><\/div>\n

\u64cd\u4f5c\u6587\u4ef6\u5185\u5bb9\u7684\u65b9\u6cd5\u592a\u591a\u4e86\uff0c\u6211\u770b\u5230\u5f88\u591a\u4eba\u90fd\u5728\u4f7f\u7528 lineinfile\u3002\u6211\u81ea\u5df1\u4e5f\u7528\u5b83\u505a\u8fc7\u5c0f\u4efb\u52a1\u3002\u4f46\u662f\uff0ctemplate \u6a21\u5757\u5c31\u6e05\u6670\u591a\u4e86\uff0c\u56e0\u4e3a\u4f60\u7ef4\u62a4\u4e86\u6574\u4e2a\u6587\u4ef6\u7684\u4e0a\u4e0b\u6587\u3002\u6211\u66f4\u559c\u6b22\u4ee5\u4efb\u4f55\u4eba\u90fd\u53ef\u4ee5\u8f7b\u677e\u7406\u89e3\u7684\u65b9\u5f0f\u7f16\u5199 Ansible \u7684\u5185\u5bb9 \u2014\u2014 \u5bf9\u6211\u800c\u8a00\uff0c\u8fd9\u610f\u5473\u7740\u5bb9\u6613\u7406\u89e3\u6b63\u5728\u53d1\u751f\u7684\u4e8b\u60c5\u3002template \u7684\u4f7f\u7528\u610f\u5473\u7740\u80fd\u591f\u770b\u5230\u4f60\u6b63\u5728\u653e\u7f6e\u5185\u5bb9\u7684\u6574\u4e2a\u6587\u4ef6\u3001\u5168\u90e8\u4f60\u6b63\u5728\u6539\u53d8\u7684\u53d8\u91cf\u3002<\/p>\n

uri<\/strong><\/span><\/div>\n

\u5f53\u524d\u53d1\u5e03\u7248\u4e2d\u7684\u8bb8\u591a\u6a21\u5757\u5229\u7528 Ansible \u4f5c\u4e3a\u7f16\u6392\u5de5\u5177\u3002\u5b83\u4eec\u4e0e\u53e6\u4e00\u4e2a\u670d\u52a1\u5bf9\u8bdd\uff0c\u800c\u4e0d\u662f\u505a\u4e00\u4e9b\u5177\u4f53\u7684\u4e8b\u60c5\uff0c\u6bd4\u5982\u628a\u4e00\u4e2a\u6587\u4ef6\u653e\u5230\u4e00\u4e2a\u5730\u65b9\u3002\u901a\u5e38\uff0c\u8fd9\u79cd\u5bf9\u8bdd\u4e5f\u662f\u901a\u8fc7 HTTP \u8fdb\u884c\u7684\u3002\u5728\u8bb8\u591a\u8fd9\u6837\u7684\u6a21\u5757\u51fa\u73b0\u4e4b\u524d\uff0c\u4f60\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 uri \u6a21\u5757\u5bf9 API \u8fdb\u884c\u7f16\u7a0b\u3002\u5b83\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u8bbf\u95ee\u5de5\u5177\uff0c\u53ef\u4ee5\u4f7f\u4f60\u80fd\u591f\u505a\u5f88\u591a\u4e8b\u60c5\u3002\u5728\u6211\u7684 Ansible \u865a\u62df\u68da\u5b50\u91cc\uff0c\u6211\u4e0d\u4f1a\u5c11\u4e86\u5b83\u3002<\/p>\n

shell<\/strong><\/span><\/div>\n

\u8fd9\u662f\u6211\u4eec\u5de5\u5177\u5305\u91cc\u7684\u738b\u724c\u3001\u745e\u58eb\u519b\u5200\u3002\u5982\u679c\u4f60\u4e3a\u5982\u4f55\u63a7\u5236\u5176\u4ed6\u4e1c\u897f\u800c\u975e\u5e38\u82e6\u607c\uff0c\u522b\u8bf4\uff0c\u8bf4\u5c31\u662f shell\u3002\u6709\u4eba\u4f1a\u8bf4\uff0c\u6211\u4eec\u8fd9\u6837\u8bf4\u662f\u8ba9 Ansible \u6210\u4e3a\u4e86 Bash \u811a\u672c \u2014\u2014 \u4f46\u662f\uff0c\u6211\u60f3\u8bf4\u7684\u662f\uff0c\u8fd9\u8fd8\u662f\u6709\u70b9\u597d\u5904\u7684\uff0c\u56e0\u4e3a\u53ef\u4ee5\u5728\u4f60\u7684\u5267\u672c\u548c\u89d2\u8272\u4e2d\u4f7f\u7528 name \u53c2\u6570\u8bb0\u5f55\u4e0b\u6bcf\u4e00\u6b65\u3002\u5bf9\u6211\u6765\u8bf4\uff0c\u8fd9\u5c31\u50cf\u4e00\u4e2a\u5f88\u5927\u7684\u5956\u52b1\u4e00\u6837\u3002\u65e9\u5728\u6211\u8fd8\u5728\u505a\u54a8\u8be2\u7684\u65f6\u5019\uff0c\u6211\u66fe\u7ecf\u5e2e\u52a9\u4e00\u4e2a\u6570\u636e\u5e93\u7ba1\u7406\u5458\uff08DBA\uff09\u8fc1\u79fb\u5230 Ansible\u3002\u8fd9\u4f4d DBA \u5e76\u4e0d\u559c\u6b22\u6539\u53d8\uff0c\u5bf9\u6539\u53d8\u5de5\u4f5c\u65b9\u6cd5\u4e5f\u662f\u63a8\u4e09\u963b\u56db\u3002\u4e8e\u662f\uff0c\u4e3a\u4e86\u7b80\u5316\u8fc1\u79fb\u5230 Ansible \u65b9\u5f0f\uff0c\u6211\u4eec\u5728 Ansible \u4e2d\u4f7f\u7528 shell \u6a21\u5757\u8c03\u7528\u4e86\u4e00\u4e9b\u73b0\u6709\u7684\u6570\u636e\u5e93\u7ba1\u7406\u811a\u672c\u3002\u5e76\u5728\u4efb\u52a1\u4e2d\u9644\u5e26\u4e86\u7fd4\u5b9e\u7684 name \u58f0\u660e\u3002<\/p>\n

\u901a\u8fc7\u8fd9\u4e94\u4e2a\u6a21\u5757\uff0c\u4f60\u53ef\u4ee5\u5b9e\u73b0\u5f88\u591a\u4e8b\u60c5\u3002\u662f\u7684\uff0c\u4e3a\u5b8c\u6210\u7279\u5b9a\u4efb\u52a1\u800c\u8bbe\u8ba1\u7684\u6a21\u5757\u4f1a\u8ba9\u4f60\u7684\u751f\u6d3b\u66f4\u52a0\u8f7b\u677e\u3002\u4f46\u662f\uff0c\u501f\u52a9\u7b80\u5355\u7684\u5de5\u7a0b\u8bbe\u8ba1\uff0c\u4f60\u51e0\u4e4e\u53ef\u4ee5\u4e8b\u534a\u529f\u500d\u3002Ansible \u5f00\u53d1\u8005 Brian Coca \u662f\u8fd9\u65b9\u9762\u7684\u5927\u5e08\uff0c\u4ed6\u7684\u6280\u5de7\u548c\u7a8d\u95e8\u8bb2\u5ea7<\/a>\u603b\u662f\u503c\u5f97\u4e00\u770b\u3002<\/p>\n

\u4f60\u89c9\u5f97\u8fd9\u4e94\u5927\u6a21\u5757\u600e\u4e48\u6837\uff1f\u5982\u679c\u4f60\u4e5f\u5fc5\u987b\u9650\u5236\u5728\u8fd9\u4e48\u591a\u6a21\u5757\uff0c\u4f60\u4f1a\u9009\u62e9\u54ea\u4e94\u4e2a\uff0c\u4e3a\u4ec0\u4e48\uff1f\u5728\u4e0b\u9762\u7684\u8bc4\u8bba\u4e2d\u544a\u8bc9\u6211\u5427\uff01<\/p>\n

via: https:\/\/opensource.com\/article\/19\/11\/ansible-modules<\/p>\n

\u4f5c\u8005\uff1aMark Phillips \u9009\u9898\uff1alujun9972 \u8bd1\u8005\uff1awxy \u6821\u5bf9\uff1awxy<\/p>\n

\u672c\u6587\u7531 LCTT \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd \u8363\u8a89\u63a8\u51fa<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6211\u4e4b\u6240\u4ee5\u544a\u8bc9\u4f60\u8fd9\u4e2a\u6545\u4e8b\uff0c\u662f\u56e0\u4e3a\u6211\u89c9\u5f97\u6211\u7684\u804c\u4e1a\u751f\u6daf\u662f\u5728\u4e00\u4e2a\u9690\u55bb\u7684\u68da\u5b50\u91cc\u5ea6\u8fc7\u7684\u3002\u8ba1\u7b97\u673a\u4e5f\u662f\u5982\u6b64\u591a\u7684\u5de5\u5177\uff0c\u90fd\u5728\u4e00\u4e2a\u72ed […]<\/p>\n","protected":false},"author":317,"featured_media":62012,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-193885","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/193885","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/317"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=193885"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/193885\/revisions"}],"predecessor-version":[{"id":193943,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/193885\/revisions\/193943"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/62012"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=193885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=193885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=193885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}