{"id":7237,"date":"2015-03-23T14:07:05","date_gmt":"2015-03-23T06:07:05","guid":{"rendered":"http:\/\/jpuyy.com\/?p=7237"},"modified":"2015-08-09T10:44:23","modified_gmt":"2015-08-09T02:44:23","slug":"ansible-control-server-directly","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=7237","title":{"rendered":"ansible\u76f4\u63a5\u901a\u8fc7ip\u64cd\u4f5c\u673a\u5668"},"content":{"rendered":"<p>\u5982\u679c\u8981\u4e86\u89e3\u4e00\u4e24\u4e2a ip \u7684\u4e00\u4e9b\u7b80\u5355\u7684\u60c5\u51b5\u5982 ls -l \/data0\/ | wc -l\uff0c\u4ee5\u524d\u662f\u8981\u5199\u5230\u6587\u4ef6\u91cc\u7684\u3002<\/p>\n<pre>ansible -i hosts all -m shell -a \"ls -l \/data0\/ | wc -l\"<\/pre>\n<p>\u4e5f\u53ef\u4ee5\u8fd9\u6837\uff0c\u4e00\u53f0\u673a\u5668\u6700\u540e\u9762\u8981\u6709\u4e00\u4e2a\u9017\u53f7<\/p>\n<pre>ansible all -i 192.168.1.1, -m shell -a \"ls -l \/data0\/ | wc -l\"<\/pre>\n<p>\u4e24\u53f0\u673a\u5668\u7528\u9017\u53f7\u9694\u5f00\uff0c\u5e76\u4e14\u4e0d\u80fd\u6709\u7a7a\u683c<\/p>\n<pre>ansible all -i 192.168.1.1,192.168.1.2 -m shell -a \"ls -l \/data0\/ | wc -l\"<\/pre>\n<p>\u53c2\u8003: http:\/\/stackoverflow.com\/questions\/17188147\/how-to-run-ansible-without-specifying-the-inventory-but-the-host-directly?answertab=votes#tab-top<\/p>\n<p>\u9898\u5916\u8bdd\uff1a<\/p>\n<p>\u9664\u4e86\u4e0a\u9762\u7684 shell \u6a21\u5757\uff0c\u8fd8\u6709 command, script \u53ef\u4ee5\u5728\u88ab\u7ba1\u7406\u673a\u5668\u4e0a\u65b9\u4fbf\u6267\u884c shell.<\/p>\n<pre class=\"p1\">ansible all\u00a0-i hosts\u00a0-l 192.168.1.183 -m script -a uptime.sh<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u679c\u8981\u4e86\u89e3\u4e00\u4e24\u4e2a ip \u7684\u4e00\u4e9b\u7b80\u5355\u7684\u60c5\u51b5\u5982 ls -l \/data0\/ | wc -l\uff0c\u4ee5\u524d\u662f\u8981\u5199\u5230\u6587\u4ef6\u91cc\u7684\u3002 ansible -i hosts all -m shell -a &#8220;ls -l \/data0\/ | wc -l&#8221; \u4e5f\u53ef\u4ee5\u8fd9\u6837\uff0c\u4e00\u53f0\u673a\u5668\u6700\u540e\u9762\u8981\u6709\u4e00\u4e2a\u9017\u53f7 ansible all -i 192.168.1.1, -m shell -a &#8220;ls -l \/data0\/ | wc -l&#8221; \u4e24\u53f0\u673a\u5668\u7528\u9017\u53f7\u9694\u5f00\uff0c\u5e76\u4e14\u4e0d\u80fd\u6709\u7a7a\u683c ansible all -i 192.168.1.1,192.168.1.2 -m shell -a &#8220;ls -l \/data0\/ | wc -l&#8221; \u53c2\u8003: http:\/\/stackoverflow.com\/questions\/17188147\/how-to-run-ansible-without-specifying-the-inventory-but-the-host-directly?answertab=votes#tab-top \u9898\u5916\u8bdd\uff1a \u9664\u4e86\u4e0a\u9762\u7684 shell [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[166],"tags":[],"class_list":["post-7237","post","type-post","status-publish","format-standard","hentry","category-ansible"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/7237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7237"}],"version-history":[{"count":5,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/7237\/revisions"}],"predecessor-version":[{"id":7525,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/7237\/revisions\/7525"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}