{"id":116,"date":"2017-11-26T08:00:37","date_gmt":"2017-11-25T23:00:37","guid":{"rendered":"http:\/\/www.itc109.com\/knowledge\/?p=116"},"modified":"2021-09-30T09:00:03","modified_gmt":"2021-09-30T00:00:03","slug":"ansible-communication-confirmation","status":"publish","type":"post","link":"https:\/\/www.itc109.com\/knowledge\/linux\/ansible-communication-confirmation","title":{"rendered":"Ansible &#8211; \u758e\u901a\u78ba\u8a8d\u64cd\u4f5c"},"content":{"rendered":"<h4><strong>\u6982\u8981<\/strong><\/h4>\n<hr \/>\n<p>Ansible\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5b8c\u4e86\u5f8c\u3001\u5b9f\u969b\u306bAnsible\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u5229\u7528\u3057\u305f\u64cd\u4f5c\u306b\u3064\u3044\u3066\u8a18\u8f09\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>\u624b\u9806<\/strong><\/h4>\n<hr \/>\n<p>\u4e8b\u524d\u6e96\u5099<\/p>\n<ul>\n<li><a href=\"https:\/\/www.itc109.com\/knowledge\/communication\/transfer-agent\" target=\"_blank\" rel=\"noopener\">\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u8ee2\u9001\u8a2d\u5b9a\u3067\u306e\u63a5\u7d9a<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h5><strong>\u25a0hosts\u30d5\u30a1\u30a4\u30eb\u306e\u7de8\u96c6<\/strong><\/h5>\n<p>\u300c\/etc\/ansible\/hosts\u300d\u3092\u7de8\u96c6\u3057\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\nsudo vi \/etc\/ansible\/hosts\r\n<\/pre>\n<p>\u521d\u671f\u5185\u5bb9<\/p>\n<pre>\r\n# This is the default ansible 'hosts' file.\r\n#\r\n# It should live in \/etc\/ansible\/hosts\r\n#\r\n#   - Comments begin with the '#' character\r\n#   - Blank lines are ignored\r\n#   - Groups of hosts are delimited by [header] elements\r\n#   - You can enter hostnames or ip addresses\r\n#   - A hostname\/ip can be a member of multiple groups\r\n\r\n# Ex 1: Ungrouped hosts, specify before any group headers.\r\n\r\n## green.example.com\r\n## blue.example.com\r\n## 192.168.100.1\r\n## 192.168.100.10\r\n\r\n# Ex 2: A collection of hosts belonging to the 'webservers' group\r\n\r\n## [webservers]\r\n## alpha.example.org\r\n## beta.example.org\r\n## 192.168.1.100\r\n## 192.168.1.110\r\n\r\n# If you have multiple hosts following a pattern you can specify\r\n# them like this:\r\n\r\n## www[001:006].example.com\r\n\r\n# Ex 3: A collection of database servers in the 'dbservers' group\r\n\r\n## [dbservers]\r\n##\r\n## db01.intranet.mydomain.net\r\n## db02.intranet.mydomain.net\r\n## 10.25.1.56\r\n## 10.25.1.57\r\n\r\n# Here's another example of host ranges, this time there are no\r\n# leading 0s:\r\n\r\n## db-[99:101]-node.example.com\r\n<\/pre>\n<p>\u7ba1\u7406\u3059\u308b\u30b5\u30fc\u30d0\u30fc\u306e\u60c5\u5831\u3092\u8ffd\u52a0\u3057\u3066\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\n[web_server]\r\nxxx.xxx.xxx.xxx\r\nxxx.xxx.xxx.xxx\r\n\r\n[db_server]\r\nxxx.xxx.xxx.xxx\r\nxxx.xxx.xxx.xxx\r\n\r\n<\/pre>\n<p>&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<h5><strong>\u25a0Ping \u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u7528\u3057\u305f\u901a\u4fe1\u78ba\u8a8d<\/strong><\/h5>\n<p>\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\nansible -m ping %IP_ADDRESS%\r\n<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c<\/p>\n<pre>\r\n10.0.2.98 | SUCCESS => {\r\n\"changed\": false,\r\n\"ping\": \"pong\"\r\n}\r\n<\/pre>\n<p>\u300cSUCCESS\u300d\u3068\u8868\u793a\u3055\u308c\u3066\u3044\u308c\u3070\u6210\u529f\u3067\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u4ee5\u4e0b\u306e\u8868\u793a\u306e\u5834\u5408\u306f<\/p>\n<pre>\r\n%IP_ADDRESS% | UNREACHABLE! =&gt; {\r\n    \"changed\": false,\r\n    \"msg\": \"Failed to connect to the host via ssh: ssh: connect to host %IP_ADDRESS% port 22: Connection timed out\\r\\n\",\r\n    \"unreachable\": true\r\n}\r\n<\/pre>\n<p>\u30b5\u30fc\u30d0\u30fc\u304c\u505c\u6b62\u3057\u3066\u3044\u308b\u3002\u307e\u305f\u306f\u3001\u901a\u4fe1\u30dd\u30fc\u30c8\u304c\u958b\u653e\u3055\u308c\u3066\u3044\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u4ee5\u4e0b\u306e\u8868\u793a\u306e\u5834\u5408\u306f<\/p>\n<pre>\r\n[WARNING]: No hosts matched, nothing to do\r\n<\/pre>\n<p>hosts\u306b\u8a72\u5f53\u3059\u308bIPaddress\u304c\u8a18\u8f09\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 Ansible\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5b8c\u4e86\u5f8c\u3001\u5b9f\u969b\u306bAnsible\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u5229\u7528\u3057\u305f\u64cd\u4f5c\u306b\u3064\u3044\u3066\u8a18\u8f09\u3057\u3066\u3044\u307e\u3059\u3002 &nbsp; \u624b\u9806 \u4e8b\u524d\u6e96\u5099 \u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u8ee2\u9001\u8a2d\u5b9a\u3067\u306e\u63a5\u7d9a &nbsp; \u25a0hosts\u30d5\u30a1\u30a4\u30eb\u306e\u7de8\u96c6 \u300c\/&#8230;<\/p>\n","protected":false},"author":3,"featured_media":177,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3],"tags":[60],"class_list":["post-116","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-ansible"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/logo-ansible.png","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pacZwp-1S","_links":{"self":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts\/116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/comments?post=116"}],"version-history":[{"count":7,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts\/116\/revisions"}],"predecessor-version":[{"id":1789,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts\/116\/revisions\/1789"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/media\/177"}],"wp:attachment":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/media?parent=116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/categories?post=116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/tags?post=116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}