{"id":101130,"date":"2026-09-06T07:49:27","date_gmt":"2026-09-05T23:49:27","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/101130.html"},"modified":"2026-09-06T07:49:27","modified_gmt":"2026-09-05T23:49:27","slug":"4-ansible-playbook%e7%bb%93%e6%9e%84%e5%9b%be","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/101130.html","title":{"rendered":"4-ansible playbook\u7ed3\u6784\u56fe"},"content":{"rendered":"<p>1.ansible playbook\u7ed3\u6784\u56fe<\/p>\n<p>Inventory\uff08\u4e3b\u673a\u6e05\u5355\uff09<br \/>\n\u2502<br \/>\n\u251c\u2500\u2500 web<br \/>\n\u2502   \u251c\u2500\u2500 192.168.1.10<br \/>\n\u2502   \u2514\u2500\u2500 192.168.1.11<br \/>\n\u2502<br \/>\n\u2514\u2500\u2500 db<br \/>\n    \u2514\u2500\u2500 192.168.1.20<\/p>\n<p>Playbook\uff08\u5267\u672c\uff09<br \/>\n\u2502<br \/>\n\u2514\u2500\u2500 &#8211; Play\uff08\u4e00\u4e2a\u6267\u884c\u5355\u5143\uff09<br \/>\n    \u2502<br \/>\n    \u251c\u2500\u2500 hosts: web<br \/>\n    \u251c\u2500\u2500 remote_user: root<br \/>\n    \u2502<br \/>\n    \u2514\u2500\u2500 tasks:<br \/>\n        \u2502<br \/>\n        \u251c\u2500\u2500 &#8211; Task<br \/>\n        \u2502   \u251c\u2500\u2500 name: Install nginx<br \/>\n        \u2502   \u2514\u2500\u2500 yum:<br \/>\n        \u2502<br \/>\n        \u251c\u2500\u2500 &#8211; Task<br \/>\n        \u2502   \u251c\u2500\u2500 name: Copy config<br \/>\n        \u2502   \u2514\u2500\u2500 copy:<br \/>\n        \u2502<br \/>\n        \u2514\u2500\u2500 &#8211; Task<br \/>\n            \u251c\u2500\u2500 name: Start nginx<br \/>\n            \u2514\u2500\u2500 service:<\/p>\n<p>#\u8bf4\u660e\uff1a<br \/>\n1.Inventory \u51b3\u5b9a\u201c\u6709\u54ea\u4e9b\u673a\u5668\u201d<br \/>\n2.hosts     \u51b3\u5b9a\u201c\u64cd\u4f5c\u54ea\u4e9b\u673a\u5668\u201d<br \/>\n3.tasks     \u51b3\u5b9a\u201c\u6267\u884c\u4ec0\u4e48\u64cd\u4f5c\u201d<br \/>\n4.module    \u51b3\u5b9a\u201c\u5982\u4f55\u6267\u884c\u64cd\u4f5c\u201d <\/p>\n<p>2.\u5bf9\u5e94\u7684YAML<\/p>\n<p>&#8211; hosts: web<br \/>\n  remote_user: root<\/p>\n<p>  tasks:<br \/>\n    &#8211; name: Install nginx<br \/>\n      yum:                            #module<br \/>\n        name: nginx                     #module-parameter<br \/>\n        state: present                  #module-parameter<\/p>\n<p>    &#8211; name: Copy config<br \/>\n      copy:<br \/>\n        src: nginx.conf<br \/>\n        dest:<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.ansible playbook\u7ed3\u6784\u56fe<br \/>\nInventory\uff08\u4e3b\u673a\u6e05\u5355\uff09<br \/>\n\u2502<br \/>\n\u251c\u2500\u2500 web<br \/>\n\u2502   \u251c\u2500\u2500 192.168.1.10<br \/>\n\u2502   \u2514\u2500\u2500 192.168.1.11<br \/>\n\u2502<br \/>\n\u2514\u2500\u2500 db\u2514\u2500\u2500 192.168.1.20Playbook\uff08\u5267\u672c\uff09<br \/>\n\u2502<br \/>\n\u2514\u2500\u2500 &#8211; Play\uff08\u4e00\u4e2a\u6267\u884c\u5355\u5143\uff09\u2502\u251c\u2500\u2500 hosts: web\u251c\u2500\u2500 remote_user: root\u2502\u2514\u2500\u2500 tasks:\u2502\u251c\u2500\u2500 &#8211; Task\u2502   \u251c\u2500\u2500 name: Install nginx\u2502   \u2514\u2500\u2500<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1064,3307],"topic":[],"class_list":["post-101130","post","type-post","status-publish","format-standard","hentry","category-server","tag-ansible","tag-yaml"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>4-ansible playbook\u7ed3\u6784\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/101130.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"4-ansible playbook\u7ed3\u6784\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"1.ansible playbook\u7ed3\u6784\u56fe Inventory\uff08\u4e3b\u673a\u6e05\u5355\uff09 \u2502 \u251c\u2500\u2500 web \u2502  \u251c\u2500\u2500 192.168.1.10 \u2502  \u2514\u2500\u2500 192.168.1.11 \u2502 \u2514\u2500\u2500 db\u2514\u2500\u2500 192.168.1.20Playbook\uff08\u5267\u672c\uff09 \u2502 \u2514\u2500\u2500 - Play\uff08\u4e00\u4e2a\u6267\u884c\u5355\u5143\uff09\u2502\u251c\u2500\u2500 hosts: web\u251c\u2500\u2500 remote_user: root\u2502\u2514\u2500\u2500 tasks:\u2502\u251c\u2500\u2500 - Task\u2502  \u251c\u2500\u2500 name: Install nginx\u2502  \u2514\u2500\u2500\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/101130.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-05T23:49:27+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/101130.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/101130.html\",\"name\":\"4-ansible playbook\u7ed3\u6784\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-05T23:49:27+00:00\",\"dateModified\":\"2026-09-05T23:49:27+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/101130.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/101130.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/101130.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"4-ansible playbook\u7ed3\u6784\u56fe\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"4-ansible playbook\u7ed3\u6784\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/101130.html","og_locale":"zh_CN","og_type":"article","og_title":"4-ansible playbook\u7ed3\u6784\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"1.ansible playbook\u7ed3\u6784\u56fe Inventory\uff08\u4e3b\u673a\u6e05\u5355\uff09 \u2502 \u251c\u2500\u2500 web \u2502  \u251c\u2500\u2500 192.168.1.10 \u2502  \u2514\u2500\u2500 192.168.1.11 \u2502 \u2514\u2500\u2500 db\u2514\u2500\u2500 192.168.1.20Playbook\uff08\u5267\u672c\uff09 \u2502 \u2514\u2500\u2500 - Play\uff08\u4e00\u4e2a\u6267\u884c\u5355\u5143\uff09\u2502\u251c\u2500\u2500 hosts: web\u251c\u2500\u2500 remote_user: root\u2502\u2514\u2500\u2500 tasks:\u2502\u251c\u2500\u2500 - Task\u2502  \u251c\u2500\u2500 name: Install nginx\u2502  \u2514\u2500\u2500","og_url":"https:\/\/www.wsisp.com\/helps\/101130.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-05T23:49:27+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/101130.html","url":"https:\/\/www.wsisp.com\/helps\/101130.html","name":"4-ansible playbook\u7ed3\u6784\u56fe - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-05T23:49:27+00:00","dateModified":"2026-09-05T23:49:27+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/101130.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/101130.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/101130.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"4-ansible playbook\u7ed3\u6784\u56fe"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/101130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=101130"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/101130\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=101130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=101130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=101130"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=101130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}