{"id":68,"date":"2022-12-09T10:03:06","date_gmt":"2022-12-09T02:03:06","guid":{"rendered":"https:\/\/www.road-trip.cc\/?p=68"},"modified":"2022-12-09T10:03:06","modified_gmt":"2022-12-09T02:03:06","slug":"ansible%e5%9f%ba%e6%9c%ac%e6%a6%82%e5%bf%b5","status":"publish","type":"post","link":"https:\/\/www.road-trip.cc\/?p=68","title":{"rendered":"Ansible\u57fa\u672c\u6982\u5ff5"},"content":{"rendered":"\n<p>ansible\u4e09\u4e2a\u4e3b\u8981\u7684\u7ec4\u4ef6\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Control Node\uff1a\u63a7\u5236\u8282\u70b9\uff0c\u901a\u5e38\u662f\u4e00\u53f0\u88c5\u6709ansible\u53ef\u6267\u884c\u7a0b\u5e8f\u7684\u4e3b\u673a<\/li>\n\n\n\n<li>Inventory\uff1a\u53ef\u4ee5\u7ffb\u8bd1\u4e3a\u8d44\u6e90\u6e05\u5355\uff0c\u8fd9\u91cc\u6307\u88abansible\u7ba1\u7406\u7684\u8fdc\u7a0b\u4e3b\u673a\u5217\u8868<\/li>\n\n\n\n<li>Managed Node\uff1a\u88ab\u63a7\u8282\u70b9\uff0c\u88abansible\u64cd\u4f5c\u7684\u8fdc\u7a0b\u4e3b\u673a<\/li>\n<\/ul>\n\n\n\n<p>Inventory\u662f\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\uff0c\u901a\u5e38\u4f7f\u7528ini\u6216\u8005yaml\u683c\u5f0f\uff0c\u91cc\u9762\u5217\u51fa\u4e86\u8fdc\u7a0b\u4e3b\u673a\u5217\u8868\uff0c\u53ef\u4ee5\u5b58\u653e\u5230Control Node\u7684\u4efb\u4f55\u5730\u65b9\uff0c\u4f7f\u7528\u65f6\u901a\u8fc7-i\u544a\u8bc9ansible\u53bb\u54ea\u513f\u5bfb\u627einventory\u6587\u4ef6\uff0c\u5982\u679c\u4e0d\u6307\u5b9a\uff0cansible\u4f1a\u627e\/etc\/ansible\/inventory\u8fd9\u4e2a\u6587\u4ef6\u3002\u4e00\u4e2ainventory\u793a\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code has-tertiary-background-color has-background\" style=\"border-width:1px\"><code>&#91;myvirtualmachines]\n10.100.0.90<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code has-tertiary-background-color has-background\" style=\"border-width:1px\"><code>$ ansible all -i inventory_file --list-hosts<\/code><\/pre>\n\n\n\n<p>Control Node\u548cManaged Nodes\u901a\u4fe1\u534f\u8bae\u4e00\u822c\u4f7f\u7528ssh\uff0c\u524d\u8005\u901a\u8fc7ssh\u6765\u64cd\u4f5cManaged nodes\uff0c\u6240\u4ee5\u5728\u4f7f\u7528ansible\u5b8c\u6210\u5de5\u4f5c\u524d\uff0c\u6211\u4eec\u4e00\u822c\u8981\u914d\u7f6e\u597dssh\u73af\u5883\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u914d\u7f6eControl Node\u514d\u5bc6\u767b\u5f55Managed nodes\uff08\u5c06\u524d\u8005\u7684\u516c\u7ea6\u5b58\u653e\u5230\u540e\u8005\u7684~\/.ssh\/authorized_keys\u91cc\u9762\uff09<\/li>\n\n\n\n<li>\u767b\u5f55Control Node\u548cManagd nodes\u7684\u7528\u6237\u540d\u4e00\u81f4\uff08\u522b\u7ed9\u81ea\u5df1\u627e\u9ebb\u70e6\uff09<\/li>\n<\/ul>\n\n\n\n<p>ping\u6d4b\u8bd5\uff0c\u4e0b\u9762\u7684-u\u8868\u793a\u4f7f\u7528\u5236\u5b9a\u7684user\u901a\u8fc7ssh\u767b\u5f55Managed nodes<\/p>\n\n\n\n<pre class=\"wp-block-code has-tertiary-background-color has-background\" style=\"border-width:1px\"><code>$ ansible all -m ping\n$ ansible all -i inventory_file -m ping\n$ ansible all -i inventory_file -m ping -u user<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code has-tertiary-background-color has-background\" style=\"border-width:1px\"><code>10.100.0.90 | SUCCESS => {\n    \"ansible_facts\": {\n        \"discovered_interpreter_python\": \"\/usr\/bin\/python3\"\n    },\n    \"changed\": false,\n    \"ping\": \"pong\"\n}<\/code><\/pre>\n\n\n\n<p>\u606d\u559c\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528ansible\u6279\u91cf\u7ba1\u7406\u4e3b\u673a\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ansible\u4e09\u4e2a\u4e3b\u8981\u7684\u7ec4\u4ef6\uff1a Inventory\u662f\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\uff0c\u901a\u5e38\u4f7f\u7528ini\u6216\u8005yaml\u683c\u5f0f\uff0c\u91cc\u9762\u5217\u51fa\u4e86\u8fdc &#8230; <a title=\"Ansible\u57fa\u672c\u6982\u5ff5\" class=\"read-more\" href=\"https:\/\/www.road-trip.cc\/?p=68\" aria-label=\"\u9605\u8bfb Ansible\u57fa\u672c\u6982\u5ff5\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[32,34,33],"class_list":["post-68","post","type-post","status-publish","format-standard","hentry","category-7","tag-ansible","tag-devops","tag-ops"],"_links":{"self":[{"href":"https:\/\/www.road-trip.cc\/index.php?rest_route=\/wp\/v2\/posts\/68","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.road-trip.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.road-trip.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.road-trip.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.road-trip.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=68"}],"version-history":[{"count":4,"href":"https:\/\/www.road-trip.cc\/index.php?rest_route=\/wp\/v2\/posts\/68\/revisions"}],"predecessor-version":[{"id":72,"href":"https:\/\/www.road-trip.cc\/index.php?rest_route=\/wp\/v2\/posts\/68\/revisions\/72"}],"wp:attachment":[{"href":"https:\/\/www.road-trip.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.road-trip.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=68"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.road-trip.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}