{"id":54312,"date":"2025-08-13T01:49:48","date_gmt":"2025-08-12T17:49:48","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/54312.html"},"modified":"2025-08-13T01:49:48","modified_gmt":"2025-08-12T17:49:48","slug":"ansible-%e8%87%aa%e5%8a%a8%e5%8c%96%e8%bf%90%e7%bb%b4%e5%ae%9e%e6%88%98%e7%b3%bb%e5%88%97%ef%bc%88%e4%ba%94%ef%bc%89%ef%bc%9aroles%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/54312.html","title":{"rendered":"Ansible \u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\u7cfb\u5217\uff08\u4e94\uff09\uff1aRoles\u8be6\u89e3"},"content":{"rendered":"<\/p>\n<h4>Ansible \u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\u7cfb\u5217&#xff08;\u4e94&#xff09;&#xff1a;Roles\u8be6\u89e3<\/h4>\n<ul>\n<li>&#x1f4da; \u7cfb\u5217\u5bfc\u822a<\/li>\n<li>\u4e00&#xff1a;\u6982\u8ff0<\/li>\n<li>\u4e8c&#xff1a;\u521d\u59cb\u5316<\/li>\n<li>\n<ul>\n<li>1&#xff09;\u521b\u5efa\u76ee\u5f55<\/li>\n<li>2&#xff09;\u521d\u59cb\u5316<\/li>\n<\/ul>\n<\/li>\n<li>\u4e09&#xff1a;\u76ee\u5f55\u7ed3\u6784<\/li>\n<li>\u56db&#xff1a;\u6848\u4f8b<\/li>\n<li>\n<ul>\n<li>1&#xff09;\u521d\u59cb\u5316 &#096;nfs-server role&#096;<\/li>\n<li>2&#xff09;\u7f16\u5199 &#096;role&#096;<\/li>\n<li>3&#xff09;\u7f16\u5199 &#096;nfs-server.yml&#096; \u5267\u672c\u6587\u4ef6<\/li>\n<li>4&#xff09;\u6267\u884c &#096;nfs-server.yml&#096; \u5267\u672c\u6587\u4ef6<\/li>\n<\/ul>\n<\/li>\n<li>\u603b\u7ed3<\/li>\n<\/ul>\n<h2>&#x1f4da; \u7cfb\u5217\u5bfc\u822a<\/h2>\n<p>&#x1f449; \u7b2c\u4e00\u7bc7&#xff1a;\u6982\u8ff0\u3001\u90e8\u7f72\u4e0e\u547d\u4ee4 &#x1f449; \u7b2c\u4e8c\u7bc7&#xff1a;\u4e3b\u673a\u6e05\u5355\u8be6\u89e3 &#x1f449; \u7b2c\u4e09\u7bc7&#xff1a;\u5e38\u7528\u6a21\u5757\u8be6\u89e3 &#x1f449; \u7b2c\u56db\u7bc7&#xff1a;Playbook\u8be6\u89e3 &#x1f449; \u7b2c\u4e94\u7bc7&#xff1a;Roles\u8be6\u89e3 &#x1f449; \u7b2c\u516d\u7bc7&#xff1a;Valut\u8be6\u89e3 &#x1f449; \u7b2c\u4e03\u7bc7&#xff1a;Galaxy\u8be6\u89e3<\/p>\n<hr \/>\n<h2>\u4e00&#xff1a;\u6982\u8ff0<\/h2>\n<p>roles \u662f\u4e00\u79cd\u7528\u6765\u6a21\u5757\u5316\u7ec4\u7ec7 Playbook \u7684\u673a\u5236&#xff0c;\u5c31\u50cf\u662f\u628a\u4e00\u5806\u6563\u843d\u7684\u4efb\u52a1&#xff08;tasks&#xff09;\u3001\u53d8\u91cf&#xff08;vars&#xff09;\u3001\u6a21\u677f&#xff08;templates&#xff09;\u7b49\u6587\u4ef6&#xff0c;\u6309\u7167\u56fa\u5b9a\u7684\u76ee\u5f55\u7ed3\u6784\u6253\u5305\u6210\u4e00\u4e2a\u201c\u529f\u80fd\u6a21\u5757\u201d\u3002<\/p>\n<p>\u5982\u679c Playbook \u91cc\u7684\u5185\u5bb9\u8d8a\u6765\u8d8a\u591a&#xff0c;\u6240\u6709\u4efb\u52a1\u3001\u6a21\u677f\u3001\u53d8\u91cf\u90fd\u5199\u5728\u4e00\u4e2a\u6587\u4ef6\u91cc&#xff0c;\u4f1a\u53d8\u5f97\u6742\u4e71\u4e14\u96be\u4ee5\u7ef4\u62a4\u3002 roles \u5e2e\u4f60&#xff1a;<\/p>\n<ul>\n<li>\u6309\u529f\u80fd\u62c6\u5206&#xff08;\u6bd4\u5982 webserver\u3001database\u3001common&#xff09;<\/li>\n<li>\u63d0\u9ad8\u590d\u7528\u6027&#xff08;\u540c\u4e00\u4e2a role \u53ef\u5728\u4e0d\u540c\u9879\u76ee\u76f4\u63a5\u4f7f\u7528&#xff09;<\/li>\n<li>\u65b9\u4fbf\u56e2\u961f\u534f\u4f5c&#xff08;\u4e0d\u540c\u4eba\u8d1f\u8d23\u4e0d\u540c role&#xff09;<\/li>\n<\/ul>\n<hr \/>\n<h2>\u4e8c&#xff1a;\u521d\u59cb\u5316<\/h2>\n<h3>1&#xff09;\u521b\u5efa\u76ee\u5f55<\/h3>\n<p><span class=\"token punctuation\">[<\/span>root&#064;m01 ansible<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># mkdir -p playbook\/roles<\/span><\/p>\n<h3>2&#xff09;\u521d\u59cb\u5316<\/h3>\n<ul>\n<li>\n<p>\u81ea\u52a8\u521b\u5efa<\/p>\n<p>ansible-galaxy init &lt;role&gt;&#xff1a;\u5b98\u65b9\u63d0\u4f9b\u7684\u811a\u624b\u67b6<\/p>\n<p>   <span class=\"token punctuation\">[<\/span>root&#064;m01 ansible<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># cd playbook\/roles\/<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;m01 roles<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># ansible-galaxy init nfs-server<\/span><br \/>\n&#8211; Role nfs-server was created successfully\n <\/li>\n<li>\n<p>\u624b\u52a8\u521b\u5efa<\/p>\n<p> <span class=\"token punctuation\">[<\/span>root&#064;m01 module<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># cd playbook\/roles\/<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;m01 roles<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># mkdir -p rsync-server\/{tasks,files,templates,handlers}<\/span>\n <\/li>\n<\/ul>\n<hr \/>\n<h2>\u4e09&#xff1a;\u76ee\u5f55\u7ed3\u6784<\/h2>\n<p>roles\/<br \/>\n  \u2514\u2500 myrole\/<br \/>\n    \u251c\u2500\u2500 defaults                <span class=\"token comment\"># \u9ed8\u8ba4\u53d8\u91cf\u76ee\u5f55&#xff08;\u4f18\u5148\u7ea7\u6700\u4f4e&#xff0c;\u53ef\u88ab\u5916\u90e8\u8986\u76d6&#xff09;<\/span><br \/>\n        \u2502   \u2514\u2500\u2500 main.yml             <span class=\"token comment\"># &#8211; \u5b9a\u4e49\u9ed8\u8ba4\u503c&#xff0c;\u6bd4\u5982\u7aef\u53e3\u3001\u8def\u5f84\u7b49<\/span><br \/>\n        \u251c\u2500\u2500 files                   <span class=\"token comment\"># \u5b58\u653e\u8981\u76f4\u63a5\u590d\u5236\u5230\u76ee\u6807\u4e3b\u673a\u7684\u9759\u6001\u6587\u4ef6<\/span><br \/>\n        \u251c\u2500\u2500 handlers                <span class=\"token comment\"># \u5b58\u653e\u5904\u7406\u5668&#xff08;handlers&#xff09;&#xff0c;\u7528\u4e8e notify \u89e6\u53d1\u7684\u4efb\u52a1<\/span><br \/>\n        \u2502   \u2514\u2500\u2500 main.yml             <span class=\"token comment\"># &#8211; \u4f8b\u5982\u201c\u91cd\u542f nginx\u201d\u8fd9\u79cd\u64cd\u4f5c<\/span><br \/>\n        \u251c\u2500\u2500 meta                    <span class=\"token comment\"># \u5b58\u653e\u89d2\u8272\u7684\u5143\u4fe1\u606f<\/span><br \/>\n        \u2502   \u2514\u2500\u2500 main.yml             <span class=\"token comment\"># &#8211; \u4f9d\u8d56\u7684\u5176\u4ed6 roles\u3001\u4f5c\u8005\u4fe1\u606f\u7b49<\/span><br \/>\n        \u251c\u2500\u2500 README.md               <span class=\"token comment\"># \u89d2\u8272\u8bf4\u660e\u6587\u6863&#xff08;\u53d8\u91cf\u8bf4\u660e\u3001\u4f7f\u7528\u65b9\u6cd5\u7b49&#xff09;<\/span><br \/>\n        \u251c\u2500\u2500 tasks                   <span class=\"token comment\"># \u4e3b\u8981\u4efb\u52a1\u76ee\u5f55&#xff08;\u6838\u5fc3\u6267\u884c\u903b\u8f91&#xff09;<\/span><br \/>\n        \u2502   \u2514\u2500\u2500 main.yml             <span class=\"token comment\"># &#8211; \u5fc5\u987b\u5b58\u5728&#xff0c;\u5b9a\u4e49\u5177\u4f53\u7684\u4efb\u52a1\u6b65\u9aa4<\/span><br \/>\n        \u251c\u2500\u2500 templates               <span class=\"token comment\"># \u5b58\u653e Jinja2 \u6a21\u677f&#xff08;\u53ef\u6e32\u67d3\u53d8\u91cf\u7684\u914d\u7f6e\u6587\u4ef6&#xff09;<\/span><br \/>\n        \u251c\u2500\u2500 tests                   <span class=\"token comment\"># \u89d2\u8272\u6d4b\u8bd5\u76ee\u5f55<\/span><br \/>\n        \u2502   \u251c\u2500\u2500 inventory            <span class=\"token comment\"># &#8211; \u6d4b\u8bd5\u7528\u7684\u4e3b\u673a\u6e05\u5355<\/span><br \/>\n        \u2502   \u2514\u2500\u2500 test.yml             <span class=\"token comment\"># &#8211; \u6d4b\u8bd5\u7528\u7684 playbook<\/span><br \/>\n        \u2514\u2500\u2500 vars                    <span class=\"token comment\"># \u56fa\u5b9a\u53d8\u91cf\u76ee\u5f55&#xff08;\u4f18\u5148\u7ea7\u9ad8&#xff0c;\u4e0d\u6613\u88ab\u8986\u76d6&#xff09;<\/span><br \/>\n            \u2514\u2500\u2500 main.yml             <span class=\"token comment\"># &#8211; \u5b9a\u4e49\u4e0d\u5e0c\u671b\u88ab\u8f7b\u6613\u6539\u52a8\u7684\u53d8\u91cf<\/span><\/p>\n<hr \/>\n<h2>\u56db&#xff1a;\u6848\u4f8b<\/h2>\n<p>\u901a\u8fc7 roles \u5b9e\u73b0 nfs-server \u5728\u6307\u5b9a\u7ec4\u7684\u673a\u5668\u90e8\u7f72<\/p>\n<h3>1&#xff09;\u521d\u59cb\u5316 nfs-server role<\/h3>\n<p><span class=\"token punctuation\">[<\/span>root&#064;m01 roles<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># ansible-galaxy init nfs-server<\/span><\/p>\n<h3>2&#xff09;\u7f16\u5199 role<\/h3>\n<ul>\n<li>\n<p>\u7f16\u5199 \/roles\/nfs-server\/tasks\/install.yml \u5267\u672c<\/p>\n<p> <span class=\"token punctuation\">[<\/span>root&#064;m01 roles<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim nfs-server\/tasks\/install.yml<\/span><br \/>\n&#8211; name: <span class=\"token string\">&#034;01 install nfs-utils rpcbind&#034;<\/span><br \/>\n  yum:<br \/>\n    name: <span class=\"token string\">&#034;nfs-utils,rpcbind&#034;<\/span><br \/>\n    state: <span class=\"token string\">&#034;present&#034;<\/span><br \/>\n  tags:<br \/>\n    &#8211; <span class=\"token string\">&#034;01 install&#034;<\/span>\n <\/li>\n<li>\n<p>\u7f16\u5199 \/roles\/nfs-server\/tasks\/config.yml  \u5267\u672c<\/p>\n<p> <span class=\"token punctuation\">[<\/span>root&#064;m01 roles<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim nfs-server\/tasks\/config.yml<\/span><br \/>\n&#8211; name: <span class=\"token string\">&#034;02 vim file&#034;<\/span><br \/>\n  lineinfile:<br \/>\n    path: <span class=\"token string\">&#034;\/etc\/exports&#034;<\/span><br \/>\n    line: <span class=\"token string\">&#034;\/backup-nfs\/ 172.16.1.0\/24(rw,all_squash)&#034;<\/span><br \/>\n    create: <span class=\"token boolean\">true<\/span><br \/>\n  tags:<br \/>\n    &#8211; <span class=\"token string\">&#034;02 vim file&#034;<\/span><\/p>\n<p>&#8211; name: <span class=\"token string\">&#034;03 create dir&#034;<\/span><br \/>\n  file:<br \/>\n    path: <span class=\"token string\">&#034;\/backup-nfs&#034;<\/span><br \/>\n    owner: <span class=\"token string\">&#034;nfsnobody&#034;<\/span><br \/>\n    group: <span class=\"token string\">&#034;nfsnobody&#034;<\/span><br \/>\n    state: <span class=\"token string\">&#034;directory&#034;<\/span><br \/>\n  tags:<br \/>\n    &#8211; <span class=\"token string\">&#034;03 create dir&#034;<\/span>\n <\/li>\n<li>\n<p>\u7f16\u5199 \/roles\/nfs-server\/tasks\/start.yml  \u5267\u672c<\/p>\n<p> <span class=\"token punctuation\">[<\/span>root&#064;m01 roles<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim nfs-server\/tasks\/start.yml<\/span><br \/>\n&#8211; name: <span class=\"token string\">&#034;04 start rpc nfs&#034;<\/span><br \/>\n  systemd:<br \/>\n    name: <span class=\"token string\">&#034;{{ item }}&#034;<\/span><br \/>\n    enabled: <span class=\"token string\">&#034;yes&#034;<\/span><br \/>\n    state: <span class=\"token string\">&#034;started&#034;<\/span><br \/>\n  loop:<br \/>\n    &#8211; <span class=\"token string\">&#034;rpcbind&#034;<\/span><br \/>\n    &#8211; <span class=\"token string\">&#034;nfs&#034;<\/span><br \/>\n  tags:<br \/>\n    &#8211; <span class=\"token string\">&#034;04 start rpc nfs&#034;<\/span>\n <\/li>\n<li>\n<p>\u7f16\u5199 \/roles\/nfs-server\/tasks\/main.yml  \u5267\u672c<\/p>\n<p>\u53ef\u4ee5\u76f4\u63a5\u5728\u5267\u672c\u4e2d\u4f7f\u7528 inclued&#xff0c;\u4e0d\u4f7f\u7528 role<\/p>\n<p>   &#8212;<br \/>\n&#8211; hosts: backup<br \/>\n  tasks:<br \/>\n    &#8211; include_tasks: install.yml<br \/>\n    &#8211; include_tasks: config.yml<br \/>\n    &#8211; include_tasks: start.yml<\/p>\n<p>   <span class=\"token punctuation\">[<\/span>root&#064;m01 roles<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim nfs-server\/tasks\/main.yml<\/span><br \/>\n&#8212;<br \/>\n&#8211; include_tasks: install.yml<br \/>\n&#8211; include_tasks: config.yml<br \/>\n&#8211; include_tasks: start.yml\n <\/li>\n<\/ul>\n<h3>3&#xff09;\u7f16\u5199 nfs-server.yml \u5267\u672c\u6587\u4ef6<\/h3>\n<p><span class=\"token punctuation\">[<\/span>root&#064;m01 roles<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim nfs-server.yml<\/span><br \/>\n&#8211; hosts: backup<br \/>\n  roles:<br \/>\n    &#8211; role: nfs-server<\/p>\n<h3>4&#xff09;\u6267\u884c nfs-server.yml \u5267\u672c\u6587\u4ef6<\/h3>\n<p><span class=\"token punctuation\">[<\/span>root&#064;m01 roles<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># ansible-playbook nfs-server.yml<\/span><\/p>\n<hr \/>\n<h2>\u603b\u7ed3<\/h2>\n<p>1 \u6982\u8ff0 \u7528\u9014&#xff1a;\u6a21\u5757\u5316\u7ec4\u7ec7 Ansible \u5267\u672c&#xff0c;\u4fbf\u4e8e\u590d\u7528\u4e0e\u7ef4\u62a4 \u7ed3\u6784&#xff1a;tasks &#043; vars &#043; handlers &#043; templates &#043; files &#043; meta<\/p>\n<p>2 \u6838\u5fc3\u6848\u4f8b &#x1f195; \u521d\u59cb\u5316 Role&#xff1a;ansible-galaxy init &lt;role_name&gt; &#x1f4c2; \u7f16\u8f91 Role&#xff1a;\u5728 tasks\/main.yml \u4e2d\u7f16\u5199\u4efb\u52a1 &#x1f58b; \u7f16\u5199\u4e3b\u5267\u672c&#xff1a;nfs-server.yml \u8c03\u7528 role \u25b6 \u6267\u884c\u5267\u672c&#xff1a;ansible-playbook nfs-server.yml<\/p>\n<p>3 \u76ee\u5f55\u7ed3\u6784 &#x1f4c2; tasks&#xff1a;\u4e3b\u8981\u4efb\u52a1\u5217\u8868 &#x1f4c2; handlers&#xff1a;\u4e8b\u4ef6\u89e6\u53d1\u4efb\u52a1 &#x1f4c2; vars&#xff1a;\u53d8\u91cf\u5b9a\u4e49 &#x1f4c2; templates&#xff1a;\u6a21\u677f\u6587\u4ef6&#xff08;Jinja2&#xff09; &#x1f4c2; files&#xff1a;\u9759\u6001\u6587\u4ef6 &#x1f4c2; meta&#xff1a;\u4f9d\u8d56\u58f0\u660e<\/p>\n<p>4 \u6d41\u7a0b 1\ufe0f\u20e3 \u521b\u5efa Role \u76ee\u5f55 2\ufe0f\u20e3 \u521d\u59cb\u5316 Role 3\ufe0f\u20e3 \u7f16\u5199\u4efb\u52a1\u6587\u4ef6 4\ufe0f\u20e3 \u7f16\u5199\u4e3b\u5267\u672c 5\ufe0f\u20e3 \u6267\u884c\u9a8c\u8bc1<\/p>\n<p>5 \u63d0\u793a\u4e0e\u6280\u5de7 &#x1f6e0; \u4f7f\u7528 &#8211;syntax-check \u68c0\u67e5\u8bed\u6cd5 &#x1f680; \u4f7f\u7528 &#8211;step \u5355\u6b65\u6267\u884c &#x1f3af; \u4f7f\u7528 &#8211;tags \u53ea\u8fd0\u884c\u90e8\u5206\u4efb\u52a1 \u26a0 \u5ffd\u7565\u9519\u8bef&#xff1a;ignore_errors &#x1f504; \u5faa\u73af\u4e0e\u6761\u4ef6&#xff1a;loop\u3001when<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb125\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u672c\u6587\u662fAnsible\u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\u7cfb\u5217\u7684\u7b2c\u4e94\u7bc7\uff0c\u91cd\u70b9\u8bb2\u89e3Roles\u7684\u4f7f\u7528\u3002Roles\u63d0\u4f9b\u6a21\u5757\u5316\u7ec4\u7ec7Playbook\u7684\u673a\u5236\uff0c\u901a\u8fc7\u56fa\u5b9a\u76ee\u5f55\u7ed3\u6784\u5c06\u4efb\u52a1\u3001\u53d8\u91cf\u3001\u6a21\u677f\u7b49\u6253\u5305\u6210\u529f\u80fd\u6a21\u5757\uff0c\u63d0\u9ad8\u590d\u7528\u6027\u548c\u7ef4\u62a4\u6027\u3002\u6587\u7ae0\u8be6\u7ec6\u4ecb\u7ecd\u4e86Roles\u7684\u521d\u59cb\u5316\u65b9\u6cd5\uff08\u81ea\u52a8\u521b\u5efa\u548c\u624b\u52a8\u521b\u5efa\uff09\u3001\u6807\u51c6\u76ee\u5f55\u7ed3\u6784\uff0c\u5e76\u901a\u8fc7\u4e00\u4e2a\u5b8c\u6574\u7684nfs-server\u90e8\u7f72\u6848\u4f8b\uff0c\u6f14\u793a\u4e86\u5982\u4f55\u7f16\u5199Role\u4efb\u52a1\u6587\u4ef6\u3001\u4e3b\u5267\u672c\u6587\u4ef6\u4ee5\u53ca\u6267\u884c\u6d41\u7a0b\u3002\u8be5\u6848\u4f8b\u5c55\u793a\u4e86\u4ece\u521d\u59cb\u5316Role\u5230\u6700\u7ec8\u6267\u884c\u7684\u5b8c\u6574\u8fc7\u7a0b\uff0c\u4f53\u73b0\u4e86Roles\u5728\u7ec4\u7ec7\u590d\u6742Playbook\u65f6\u7684\u4f18\u52bf\u3002<\/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,395,44],"topic":[],"class_list":["post-54312","post","type-post","status-publish","format-standard","hentry","category-server","tag-ansible","tag-395","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Ansible \u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\u7cfb\u5217\uff08\u4e94\uff09\uff1aRoles\u8be6\u89e3 - \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\/54312.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ansible \u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\u7cfb\u5217\uff08\u4e94\uff09\uff1aRoles\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb125\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u672c\u6587\u662fAnsible\u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\u7cfb\u5217\u7684\u7b2c\u4e94\u7bc7\uff0c\u91cd\u70b9\u8bb2\u89e3Roles\u7684\u4f7f\u7528\u3002Roles\u63d0\u4f9b\u6a21\u5757\u5316\u7ec4\u7ec7Playbook\u7684\u673a\u5236\uff0c\u901a\u8fc7\u56fa\u5b9a\u76ee\u5f55\u7ed3\u6784\u5c06\u4efb\u52a1\u3001\u53d8\u91cf\u3001\u6a21\u677f\u7b49\u6253\u5305\u6210\u529f\u80fd\u6a21\u5757\uff0c\u63d0\u9ad8\u590d\u7528\u6027\u548c\u7ef4\u62a4\u6027\u3002\u6587\u7ae0\u8be6\u7ec6\u4ecb\u7ecd\u4e86Roles\u7684\u521d\u59cb\u5316\u65b9\u6cd5\uff08\u81ea\u52a8\u521b\u5efa\u548c\u624b\u52a8\u521b\u5efa\uff09\u3001\u6807\u51c6\u76ee\u5f55\u7ed3\u6784\uff0c\u5e76\u901a\u8fc7\u4e00\u4e2a\u5b8c\u6574\u7684nfs-server\u90e8\u7f72\u6848\u4f8b\uff0c\u6f14\u793a\u4e86\u5982\u4f55\u7f16\u5199Role\u4efb\u52a1\u6587\u4ef6\u3001\u4e3b\u5267\u672c\u6587\u4ef6\u4ee5\u53ca\u6267\u884c\u6d41\u7a0b\u3002\u8be5\u6848\u4f8b\u5c55\u793a\u4e86\u4ece\u521d\u59cb\u5316Role\u5230\u6700\u7ec8\u6267\u884c\u7684\u5b8c\u6574\u8fc7\u7a0b\uff0c\u4f53\u73b0\u4e86Roles\u5728\u7ec4\u7ec7\u590d\u6742Playbook\u65f6\u7684\u4f18\u52bf\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/54312.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-12T17:49:48+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\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/54312.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/54312.html\",\"name\":\"Ansible \u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\u7cfb\u5217\uff08\u4e94\uff09\uff1aRoles\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-12T17:49:48+00:00\",\"dateModified\":\"2025-08-12T17:49:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/54312.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/54312.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/54312.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Ansible \u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\u7cfb\u5217\uff08\u4e94\uff09\uff1aRoles\u8be6\u89e3\"}]},{\"@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":"Ansible \u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\u7cfb\u5217\uff08\u4e94\uff09\uff1aRoles\u8be6\u89e3 - \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\/54312.html","og_locale":"zh_CN","og_type":"article","og_title":"Ansible \u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\u7cfb\u5217\uff08\u4e94\uff09\uff1aRoles\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb125\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u672c\u6587\u662fAnsible\u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\u7cfb\u5217\u7684\u7b2c\u4e94\u7bc7\uff0c\u91cd\u70b9\u8bb2\u89e3Roles\u7684\u4f7f\u7528\u3002Roles\u63d0\u4f9b\u6a21\u5757\u5316\u7ec4\u7ec7Playbook\u7684\u673a\u5236\uff0c\u901a\u8fc7\u56fa\u5b9a\u76ee\u5f55\u7ed3\u6784\u5c06\u4efb\u52a1\u3001\u53d8\u91cf\u3001\u6a21\u677f\u7b49\u6253\u5305\u6210\u529f\u80fd\u6a21\u5757\uff0c\u63d0\u9ad8\u590d\u7528\u6027\u548c\u7ef4\u62a4\u6027\u3002\u6587\u7ae0\u8be6\u7ec6\u4ecb\u7ecd\u4e86Roles\u7684\u521d\u59cb\u5316\u65b9\u6cd5\uff08\u81ea\u52a8\u521b\u5efa\u548c\u624b\u52a8\u521b\u5efa\uff09\u3001\u6807\u51c6\u76ee\u5f55\u7ed3\u6784\uff0c\u5e76\u901a\u8fc7\u4e00\u4e2a\u5b8c\u6574\u7684nfs-server\u90e8\u7f72\u6848\u4f8b\uff0c\u6f14\u793a\u4e86\u5982\u4f55\u7f16\u5199Role\u4efb\u52a1\u6587\u4ef6\u3001\u4e3b\u5267\u672c\u6587\u4ef6\u4ee5\u53ca\u6267\u884c\u6d41\u7a0b\u3002\u8be5\u6848\u4f8b\u5c55\u793a\u4e86\u4ece\u521d\u59cb\u5316Role\u5230\u6700\u7ec8\u6267\u884c\u7684\u5b8c\u6574\u8fc7\u7a0b\uff0c\u4f53\u73b0\u4e86Roles\u5728\u7ec4\u7ec7\u590d\u6742Playbook\u65f6\u7684\u4f18\u52bf\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/54312.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-12T17:49:48+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/54312.html","url":"https:\/\/www.wsisp.com\/helps\/54312.html","name":"Ansible \u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\u7cfb\u5217\uff08\u4e94\uff09\uff1aRoles\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-12T17:49:48+00:00","dateModified":"2025-08-12T17:49:48+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/54312.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/54312.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/54312.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Ansible \u81ea\u52a8\u5316\u8fd0\u7ef4\u5b9e\u6218\u7cfb\u5217\uff08\u4e94\uff09\uff1aRoles\u8be6\u89e3"}]},{"@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\/54312","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=54312"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/54312\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=54312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=54312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=54312"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=54312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}