{"id":79601,"date":"2026-03-02T16:05:49","date_gmt":"2026-03-02T08:05:49","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/79601.html"},"modified":"2026-03-02T16:05:49","modified_gmt":"2026-03-02T08:05:49","slug":"ansible-100-%e5%8f%b0%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%b8%80%e9%94%ae%e7%ae%a1%e6%8e%a7%e5%ae%9e%e6%88%98-%e8%bf%9b%e9%98%b6%e7%89%88","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/79601.html","title":{"rendered":"Ansible 100 \u53f0\u670d\u52a1\u5668\u4e00\u952e\u7ba1\u63a7\u5b9e\u6218 \u8fdb\u9636\u7248"},"content":{"rendered":"<h2>Ansible 100\u53f0\u670d\u52a1\u5668\u4e00\u952e\u7ba1\u63a7\u5b9e\u6218&#xff08;\u5b8c\u6574\u7248&#xff09;<\/h2>\n<p>Ansible\u662f100\u53f0\u670d\u52a1\u5668\u6279\u91cf\u7ba1\u7406\u7684\u4f01\u4e1a\u7ea7\u6807\u51c6\u65b9\u6848\u2014\u2014\u65e0\u5ba2\u6237\u7aef\u3001SSH\u539f\u751f\u8fde\u63a5\u3001\u914d\u7f6e\u5373\u4ee3\u7801\u3001\u652f\u6301\u5e76\u53d1\/\u5206\u6279\/\u56de\u6eda&#xff0c;\u65e2\u80fd\u89e3\u51b3\u624b\u5de5\u64cd\u4f5c\u7684\u4f4e\u6548\u95ee\u9898&#xff0c;\u53c8\u80fd\u89c4\u907fShell\u811a\u672c\u7684\u7a33\u5b9a\u6027\u98ce\u9669\u3002\u672c\u6587\u4ece\u73af\u5883\u642d\u5efa\u3001\u6838\u5fc3\u529f\u80fd\u3001\u5b9e\u6218\u573a\u666f\u5230\u907f\u5751\u6307\u5357&#xff0c;\u5b8c\u6574\u8986\u76d6100\u53f0\u670d\u52a1\u5668\u7684\u4e00\u952e\u7ba1\u63a7\u5168\u6d41\u7a0b&#xff0c;\u6240\u6709\u811a\u672c\u53ef\u76f4\u63a5\u590d\u5236\u843d\u5730\u3002<\/p>\n<h3>\u4e00\u3001\u524d\u7f6e\u6761\u4ef6&#xff08;\u5fc5\u770b&#xff09;<\/h3>\n<h4>1. \u73af\u5883\u8981\u6c42<\/h4>\n<table>\n<tr>\u89d2\u8272\u914d\u7f6e\u8981\u6c42\u7cfb\u7edf\u8981\u6c42<\/tr>\n<tbody>\n<tr>\n<td>\u63a7\u5236\u8282\u70b9<\/td>\n<td>2\u68384G\u4ee5\u4e0a&#xff08;\u4efb\u610fLinux&#xff09;<\/td>\n<td>CentOS7&#043;\/Ubuntu18.04&#043;<\/td>\n<\/tr>\n<tr>\n<td>\u88ab\u63a7\u8282\u70b9<\/td>\n<td>\u65e0\u6700\u4f4e\u914d\u7f6e\u8981\u6c42<\/td>\n<td>\u4e3b\u6d41Linux\u53d1\u884c\u7248&#xff08;100\u53f0&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2. \u6838\u5fc3\u4f18\u52bf&#xff08;\u9002\u914d100\u53f0\u89c4\u6a21&#xff09;<\/h4>\n<ul>\n<li>\u2705 \u65e0\u5ba2\u6237\u7aef&#xff1a;\u88ab\u63a7\u7aef\u4ec5\u9700SSH\u548cPython&#xff08;Linux\u9ed8\u8ba4\u81ea\u5e26&#xff09;&#xff1b;<\/li>\n<li>\u2705 \u5e76\u884c\u6267\u884c&#xff1a;\u53ef\u6307\u5b9a\u5e76\u53d1\u6570&#xff08;100\u53f0\u5efa\u8bae50\u5e76\u53d1&#xff09;&#xff0c;\u79d2\u7ea7\u5b8c\u6210\u64cd\u4f5c&#xff1b;<\/li>\n<li>\u2705 \u5e42\u7b49\u6027&#xff1a;\u91cd\u590d\u6267\u884c\u540c\u4e00\u64cd\u4f5c\u4e0d\u4f1a\u5bfc\u81f4\u5f02\u5e38&#xff08;\u5982\u91cd\u590d\u5b89\u88c5\u8f6f\u4ef6&#xff09;&#xff1b;<\/li>\n<li>\u2705 \u53ef\u5ba1\u8ba1&#xff1a;\u6240\u6709\u64cd\u4f5c\u53ef\u901a\u8fc7Playbook\u811a\u672c\u8ffd\u6eaf&#xff0c;\u907f\u514d\u4eba\u5de5\u8bef\u64cd\u4f5c&#xff1b;<\/li>\n<li>\u2705 \u5168\u573a\u666f\u8986\u76d6&#xff1a;\u547d\u4ee4\u6267\u884c\u3001\u6587\u4ef6\u5206\u53d1\u3001\u8f6f\u4ef6\u5b89\u88c5\u3001\u914d\u7f6e\u7ba1\u7406\u3001\u670d\u52a1\u7ba1\u63a7\u3002<\/li>\n<\/ul>\n<h3>\u4e8c\u3001\u73af\u5883\u642d\u5efa&#xff08;\u63a7\u5236\u8282\u70b9&#043;100\u53f0\u88ab\u63a7\u8282\u70b9&#xff09;<\/h3>\n<h4>1. \u63a7\u5236\u8282\u70b9\u5b89\u88c5Ansible<\/h4>\n<p><span class=\"token comment\"># CentOS\/RHEL<\/span><br \/>\nyum <span class=\"token function\">install<\/span> -y epel-release <span class=\"token operator\">&amp;&amp;<\/span> yum <span class=\"token function\">install<\/span> -y ansible<br \/>\n<span class=\"token comment\"># Ubuntu\/Debian<\/span><br \/>\n<span class=\"token function\">apt<\/span> update <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> -y ansible<\/p>\n<p><span class=\"token comment\"># \u9a8c\u8bc1\u5b89\u88c5<\/span><br \/>\nansible &#8211;version  <span class=\"token comment\"># \u8f93\u51faansible 2.14&#043;\u7248\u672c\u5373\u53ef&#xff08;\u63a8\u83502.10&#043;&#xff09;<\/span><\/p>\n<h4>2. \u514d\u5bc6\u767b\u5f55\u914d\u7f6e&#xff08;\u6838\u5fc3&#xff01;\u907f\u514d100\u53f0\u670d\u52a1\u5668\u8f93\u5bc6\u7801&#xff09;<\/h4>\n<p>Ansible\u9ed8\u8ba4\u901a\u8fc7SSH\u8fde\u63a5&#xff0c;100\u53f0\u670d\u52a1\u5668\u5fc5\u987b\u914d\u7f6e\u514d\u5bc6&#xff0c;\u5426\u5219\u6279\u91cf\u64cd\u4f5c\u65e0\u610f\u4e49\u3002<\/p>\n<p><span class=\"token comment\"># \u6b65\u9aa41&#xff1a;\u63a7\u5236\u8282\u70b9\u751f\u6210SSH\u5bc6\u94a5&#xff08;\u65e0\u5bc6\u7801\u56de\u8f66&#xff09;<\/span><br \/>\nssh-keygen -t rsa -b <span class=\"token number\">2048<\/span> -N <span class=\"token string\">&#034;&#034;<\/span> -f ~\/.ssh\/id_rsa<\/p>\n<p><span class=\"token comment\"># \u6b65\u9aa42&#xff1a;\u6279\u91cf\u5206\u53d1\u516c\u94a5\u5230100\u53f0\u88ab\u63a7\u8282\u70b9&#xff08;\u4e24\u79cd\u65b9\u5f0f&#xff09;<\/span><br \/>\n<span class=\"token comment\">## \u65b9\u5f0f1&#xff1a;\u624b\u52a8&#xff08;\u9002\u5408\u5c11\u91cf\u670d\u52a1\u5668&#xff0c;\u793a\u4f8b&#xff09;<\/span><br \/>\nssh-copy-id root&#064;192.168.1.10<br \/>\nssh-copy-id root&#064;192.168.1.11<br \/>\n<span class=\"token comment\"># &#8230; \u91cd\u590d100\u6b21&#xff08;\u4e0d\u63a8\u8350&#xff0c;\u4ec5\u6f14\u793a&#xff09;<\/span><\/p>\n<p><span class=\"token comment\">## \u65b9\u5f0f2&#xff1a;\u811a\u672c\u6279\u91cf\u5206\u53d1&#xff08;\u63a8\u8350100\u53f0\u89c4\u6a21&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u65b0\u5efa\u670d\u52a1\u5668\u6e05\u5355\u6587\u4ef6&#xff1a;hosts.txt&#xff08;\u683c\u5f0f&#xff1a;IP:\u7528\u6237\u540d:\u5bc6\u7801&#xff09;<\/span><br \/>\n<span class=\"token function\">cat<\/span> <span class=\"token operator\">&gt;<\/span> hosts.txt <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">EOF<br \/>\n192.168.1.10:root:Passwd&#064;123<br \/>\n192.168.1.11:root:Passwd&#064;123<br \/>\n# &#8230; \u8865\u5145\u5269\u4f5998\u53f0\u670d\u52a1\u5668<br \/>\nEOF<\/span><\/p>\n<p><span class=\"token comment\"># \u6279\u91cf\u5206\u53d1\u516c\u94a5\u811a\u672c<\/span><br \/>\n<span class=\"token function\">cat<\/span> <span class=\"token operator\">&gt;<\/span> ssh_copy_batch.sh <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">EOF<br \/>\n#!\/bin\/bash<br \/>\n# \u5b89\u88c5sshpass&#xff08;\u514d\u4ea4\u4e92\u8f93\u5bc6\u7801&#xff09;<br \/>\nyum install -y sshpass &gt; \/dev\/null 2&gt;&amp;1 || apt install -y sshpass &gt; \/dev\/null 2&gt;&amp;1<\/p>\n<p># \u904d\u5386\u670d\u52a1\u5668\u6e05\u5355<br \/>\nwhile IFS&#061;&#034;:&#034; read -r IP USER PWD; do<br \/>\n    if [[ -z \\\\<span class=\"token variable\">$IP<\/span> || \\\\<span class=\"token variable\">$IP<\/span> &#061;~ ^# ]]; then<br \/>\n        continue<br \/>\n    fi<br \/>\n    echo &#034;&#061;&#061;&#061;&#061;&#061; \u5206\u53d1\u516c\u94a5\u5230 \\\\<span class=\"token variable\">$IP<\/span> &#061;&#061;&#061;&#061;&#061;&#034;<br \/>\n    sshpass -p &#034;\\\\<span class=\"token environment constant\">$PWD<\/span>&#034; ssh-copy-id -o StrictHostKeyChecking&#061;no \\\\<span class=\"token environment constant\">$USER<\/span>&#064;\\\\<span class=\"token variable\">$IP<\/span> &gt; \/dev\/null 2&gt;&amp;1<br \/>\n    if [ \\\\<span class=\"token variable\">$?<\/span> -eq 0 ]; then<br \/>\n        echo &#034;\\\\<span class=\"token variable\">$IP<\/span> \u516c\u94a5\u5206\u53d1\u6210\u529f&#034;<br \/>\n    else<br \/>\n        echo &#034;\\\\<span class=\"token variable\">$IP<\/span> \u516c\u94a5\u5206\u53d1\u5931\u8d25&#034;<br \/>\n    fi<br \/>\ndone &lt; hosts.txt<br \/>\nEOF<\/span><\/p>\n<p><span class=\"token comment\"># \u6267\u884c\u811a\u672c<\/span><br \/>\n<span class=\"token function\">chmod<\/span> &#043;x ssh_copy_batch.sh<br \/>\n.\/ssh_copy_batch.sh<\/p>\n<h4>3. \u914d\u7f6eAnsible\u4e3b\u673a\u6e05\u5355&#xff08;\u6838\u5fc3\u914d\u7f6e&#xff09;<\/h4>\n<p>Ansible\u901a\u8fc7\u4e3b\u673a\u6e05\u5355\u7ba1\u7406\u670d\u52a1\u5668&#xff0c;\u652f\u6301\u5206\u7ec4\u3001\u53d8\u91cf&#xff0c;\u9002\u914d100\u53f0\u670d\u52a1\u5668\u7684\u5206\u7c7b\u7ba1\u63a7&#xff08;\u5982\u6309\u4e1a\u52a1\/\u673a\u623f\u5206\u7ec4&#xff09;\u3002<\/p>\n<p><span class=\"token comment\"># \u7f16\u8f91\u9ed8\u8ba4\u6e05\u5355\u6587\u4ef6&#xff08;\u4e5f\u53ef\u81ea\u5b9a\u4e49&#xff09;<\/span><br \/>\n<span class=\"token function\">vim<\/span> \/etc\/ansible\/hosts<\/p>\n<p><span class=\"token comment\"># \u914d\u7f6e\u793a\u4f8b&#xff08;100\u53f0\u670d\u52a1\u5668\u5206\u7ec4\u7ba1\u7406&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>all_servers<span class=\"token punctuation\">]<\/span>  <span class=\"token comment\"># \u6240\u6709100\u53f0\u670d\u52a1\u5668\u603b\u7ec4<\/span><br \/>\n<span class=\"token number\">192.168<\/span>.1.<span class=\"token punctuation\">[<\/span><span class=\"token number\">10<\/span>:109<span class=\"token punctuation\">]<\/span>  <span class=\"token comment\"># \u6279\u91cf\u7b80\u5199&#xff08;192.168.1.10~192.168.1.109&#xff0c;\u5171100\u53f0&#xff09;<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>web_servers<span class=\"token punctuation\">]<\/span>  <span class=\"token comment\"># Web\u4e1a\u52a1\u7ec4&#xff08;\u793a\u4f8b&#xff1a;20\u53f0&#xff09;<\/span><br \/>\n<span class=\"token number\">192.168<\/span>.1.<span class=\"token punctuation\">[<\/span><span class=\"token number\">10<\/span>:29<span class=\"token punctuation\">]<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>db_servers<span class=\"token punctuation\">]<\/span>   <span class=\"token comment\"># \u6570\u636e\u5e93\u7ec4&#xff08;\u793a\u4f8b&#xff1a;10\u53f0&#xff09;<\/span><br \/>\n<span class=\"token number\">192.168<\/span>.1.<span class=\"token punctuation\">[<\/span><span class=\"token number\">30<\/span>:39<span class=\"token punctuation\">]<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>other_servers<span class=\"token punctuation\">]<\/span>  <span class=\"token comment\"># \u5176\u4ed6\u4e1a\u52a1\u7ec4&#xff08;\u793a\u4f8b&#xff1a;70\u53f0&#xff09;<\/span><br \/>\n<span class=\"token number\">192.168<\/span>.1.<span class=\"token punctuation\">[<\/span><span class=\"token number\">40<\/span>:109<span class=\"token punctuation\">]<\/span><\/p>\n<p><span class=\"token comment\"># \u5168\u5c40\u53d8\u91cf&#xff08;\u6240\u6709\u670d\u52a1\u5668\u901a\u7528&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>all_servers:vars<span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token assign-left variable\">ansible_ssh_user<\/span><span class=\"token operator\">&#061;<\/span>root  <span class=\"token comment\"># \u767b\u5f55\u7528\u6237<\/span><br \/>\n<span class=\"token assign-left variable\">ansible_ssh_port<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">22<\/span>    <span class=\"token comment\"># SSH\u7aef\u53e3<\/span><br \/>\n<span class=\"token assign-left variable\">ansible_python_interpreter<\/span><span class=\"token operator\">&#061;<\/span>\/usr\/bin\/python3  <span class=\"token comment\"># Python\u8def\u5f84&#xff08;\u907f\u514d\u6267\u884c\u62a5\u9519&#xff09;<\/span><\/p>\n<h4>4. \u6d4b\u8bd5\u8fde\u901a\u6027&#xff08;\u9a8c\u8bc1100\u53f0\u670d\u52a1\u5668&#xff09;<\/h4>\n<p><span class=\"token comment\"># \u6d4b\u8bd5\u6240\u6709\u670d\u52a1\u5668\u8fde\u901a\u6027&#xff08;\u5e76\u53d1\u657050&#xff0c;100\u53f0\u79d2\u7ea7\u5b8c\u6210&#xff09;<\/span><br \/>\nansible all_servers -f <span class=\"token number\">50<\/span> -m <span class=\"token function\">ping<\/span><\/p>\n<p><span class=\"token comment\"># \u8f93\u51fa\u793a\u4f8b&#xff08;\u6210\u529f\u4e3apong&#xff0c;\u5931\u8d25\u4f1a\u6807\u6ce8&#xff09;<\/span><br \/>\n<span class=\"token number\">192.168<\/span>.1.10 <span class=\"token operator\">|<\/span> SUCCESS <span class=\"token operator\">&#061;<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token string\">&#034;ansible_facts&#034;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token string\">&#034;discovered_interpreter_python&#034;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token string\">&#034;\/usr\/bin\/python3&#034;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span>,<br \/>\n    <span class=\"token string\">&#034;changed&#034;<\/span><span class=\"token builtin class-name\">:<\/span> false,<br \/>\n    <span class=\"token string\">&#034;ping&#034;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token string\">&#034;pong&#034;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token comment\"># &#8230; \u5269\u4f5999\u53f0\u8f93\u51fa<\/span><\/p>\n<h3>\u4e09\u3001100\u53f0\u670d\u52a1\u5668\u6838\u5fc3\u7ba1\u63a7\u64cd\u4f5c&#xff08;\u4e00\u952e\u6267\u884c&#xff09;<\/h3>\n<h4>1. \u6279\u91cf\u6267\u884c\u547d\u4ee4&#xff08;\u57fa\u7840\u64cd\u4f5c&#xff09;<\/h4>\n<p>\u652f\u6301\u4efb\u610fLinux\u547d\u4ee4&#xff0c;\u4e00\u952e\u4e0b\u53d1\u5230100\u53f0\u670d\u52a1\u5668&#xff0c;\u6309\u7ec4\/\u5168\u91cf\u6267\u884c\u5747\u53ef\u3002<\/p>\n<p><span class=\"token comment\"># \u8bed\u6cd5&#xff1a;ansible &lt;\u7ec4\u540d&gt; -f &lt;\u5e76\u53d1\u6570&gt; -m &lt;\u6a21\u5757&gt; -a &lt;\u547d\u4ee4&gt;<\/span><\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b1&#xff1a;\u6240\u6709100\u53f0\u670d\u52a1\u5668\u67e5\u770b\u5185\u5b58\u4f7f\u7528<\/span><br \/>\nansible all_servers -f <span class=\"token number\">50<\/span> -m <span class=\"token builtin class-name\">command<\/span> -a <span class=\"token string\">&#034;free -m&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b2&#xff1a;Web\u7ec420\u53f0\u670d\u52a1\u5668\u67e5\u770b\u78c1\u76d8\u5360\u7528<\/span><br \/>\nansible web_servers -f <span class=\"token number\">20<\/span> -m shell -a <span class=\"token string\">&#034;df -h | grep \/data&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b3&#xff1a;\u6240\u6709\u670d\u52a1\u5668\u540c\u6b65\u65f6\u95f4&#xff08;\u5173\u952e&#xff01;\u907f\u514d\u96c6\u7fa4\u65f6\u95f4\u4e0d\u4e00\u81f4&#xff09;<\/span><br \/>\nansible all_servers -f <span class=\"token number\">50<\/span> -m shell -a <span class=\"token string\">&#034;ntpdate ntp.aliyun.com &amp;&amp; hwclock -w&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b4&#xff1a;\u6267\u884c\u590d\u6742\u811a\u672c&#xff08;\u672c\u5730\u811a\u672c\u4e00\u952e\u4e0b\u53d1\u5e76\u6267\u884c&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u5148\u5199\u672c\u5730\u811a\u672c&#xff1a;test.sh<\/span><br \/>\n<span class=\"token function\">cat<\/span> <span class=\"token operator\">&gt;<\/span> test.sh <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">EOF<br \/>\n#!\/bin\/bash<br \/>\necho &#034;\u670d\u52a1\u5668IP&#xff1a;\\\\<span class=\"token variable\"><span class=\"token variable\">$(<\/span><span class=\"token function\">hostname<\/span> -I<span class=\"token variable\">)<\/span><\/span>&#034;<br \/>\necho &#034;\u5f53\u524d\u65f6\u95f4&#xff1a;\\\\<span class=\"token variable\"><span class=\"token variable\">$(<\/span><span class=\"token function\">date<\/span><span class=\"token variable\">)<\/span><\/span>&#034;<br \/>\necho &#034;CPU\u6838\u5fc3\u6570&#xff1a;\\\\<span class=\"token variable\"><span class=\"token variable\">$(<\/span>nproc<span class=\"token variable\">)<\/span><\/span>&#034;<br \/>\nEOF<\/span><\/p>\n<p><span class=\"token comment\"># \u4e00\u952e\u4e0b\u53d1\u5e76\u6267\u884c<\/span><br \/>\nansible all_servers -f <span class=\"token number\">50<\/span> -m copy -a <span class=\"token string\">&#034;src&#061;.\/test.sh dest&#061;\/tmp\/test.sh mode&#061;0755&#034;<\/span><br \/>\nansible all_servers -f <span class=\"token number\">50<\/span> -m shell -a <span class=\"token string\">&#034;\/tmp\/test.sh &gt; \/tmp\/server_info.log&#034;<\/span><\/p>\n<h4>2. \u6279\u91cf\u6587\u4ef6\u5206\u53d1&#xff08;\u914d\u7f6e\/\u5b89\u88c5\u5305&#xff09;<\/h4>\n<p>\u4e00\u952e\u5c06\u672c\u5730\u6587\u4ef6\/\u76ee\u5f55\u5206\u53d1\u5230100\u53f0\u670d\u52a1\u5668&#xff0c;\u652f\u6301\u6743\u9650\u3001\u6240\u6709\u8005\u914d\u7f6e\u3002<\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b1&#xff1a;\u5206\u53d1nginx\u914d\u7f6e\u6587\u4ef6\u5230\u6240\u6709Web\u670d\u52a1\u5668<\/span><br \/>\nansible web_servers -f <span class=\"token number\">20<\/span> -m copy -a <span class=\"token string\">&#034;src&#061;\/etc\/nginx\/nginx.conf dest&#061;\/etc\/nginx\/nginx.conf owner&#061;root group&#061;root mode&#061;0644&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b2&#xff1a;\u5206\u53d1\u5b89\u88c5\u5305&#xff08;\u5982jdk&#xff09;\u5230\u6240\u6709\u670d\u52a1\u5668<\/span><br \/>\nansible all_servers -f <span class=\"token number\">50<\/span> -m copy -a <span class=\"token string\">&#034;src&#061;\/opt\/jdk-17.tar.gz dest&#061;\/opt\/jdk-17.tar.gz&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b3&#xff1a;\u540c\u6b65\u76ee\u5f55&#xff08;\u5982\u9879\u76ee\u4ee3\u7801&#xff09;\u5230Web\u670d\u52a1\u5668<\/span><br \/>\nansible web_servers -f <span class=\"token number\">20<\/span> -m synchronize -a <span class=\"token string\">&#034;src&#061;\/var\/www\/html\/ dest&#061;\/var\/www\/html\/ delete&#061;yes&#034;<\/span><br \/>\n<span class=\"token comment\"># delete&#061;yes&#xff1a;\u4fdd\u6301\u8fdc\u7a0b\u76ee\u5f55\u548c\u672c\u5730\u4e00\u81f4&#xff08;\u5220\u9664\u591a\u4f59\u6587\u4ef6&#xff09;<\/span><\/p>\n<h4>3. \u6279\u91cf\u5b89\u88c5\/\u5378\u8f7d\u8f6f\u4ef6&#xff08;\u5168\u91cf\/\u5206\u7ec4&#xff09;<\/h4>\n<p>\u652f\u6301yum\/apt\/pip\u7b49\u5305\u7ba1\u7406\u5668&#xff0c;\u5e42\u7b49\u6267\u884c&#xff08;\u5df2\u5b89\u88c5\u5219\u8df3\u8fc7&#xff09;\u3002<\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b1&#xff1a;\u6240\u6709\u670d\u52a1\u5668\u5b89\u88c5docker<\/span><br \/>\nansible all_servers -f <span class=\"token number\">50<\/span> -m yum -a <span class=\"token string\">&#034;name&#061;docker state&#061;installed&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b2&#xff1a;Web\u670d\u52a1\u5668\u5b89\u88c5nginx&#043;php<\/span><br \/>\nansible web_servers -f <span class=\"token number\">20<\/span> -m yum -a <span class=\"token string\">&#034;name&#061;nginx,php-fpm state&#061;installed&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b3&#xff1a;\u5378\u8f7d\u591a\u4f59\u8f6f\u4ef6&#xff08;\u5982telnet&#xff09;<\/span><br \/>\nansible all_servers -f <span class=\"token number\">50<\/span> -m yum -a <span class=\"token string\">&#034;name&#061;telnet state&#061;absent&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b4&#xff1a;\u5b89\u88c5\u6307\u5b9a\u7248\u672c\u8f6f\u4ef6&#xff08;\u5982nginx-1.24&#xff09;<\/span><br \/>\nansible web_servers -f <span class=\"token number\">20<\/span> -m yum -a <span class=\"token string\">&#034;name&#061;nginx-1.24.0 state&#061;installed&#034;<\/span><\/p>\n<h4>4. \u6279\u91cf\u7ba1\u63a7\u670d\u52a1&#xff08;\u542f\u52a8\/\u91cd\u542f\/\u5f00\u673a\u81ea\u542f&#xff09;<\/h4>\n<p><span class=\"token comment\"># \u793a\u4f8b1&#xff1a;\u6240\u6709\u670d\u52a1\u5668\u542f\u52a8docker\u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f<\/span><br \/>\nansible all_servers -f <span class=\"token number\">50<\/span> -m <span class=\"token function\">service<\/span> -a <span class=\"token string\">&#034;name&#061;docker state&#061;started enabled&#061;yes&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b2&#xff1a;Web\u670d\u52a1\u5668\u91cd\u542fnginx&#xff08;\u5148\u9a8c\u8bc1\u914d\u7f6e\u518d\u91cd\u542f&#xff0c;\u907f\u514d\u62a5\u9519&#xff09;<\/span><br \/>\nansible web_servers -f <span class=\"token number\">20<\/span> -m shell -a <span class=\"token string\">&#034;nginx -t &amp;&amp; systemctl restart nginx&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b3&#xff1a;\u6570\u636e\u5e93\u670d\u52a1\u5668\u91cd\u542fmysql&#xff0c;\u5e76\u68c0\u67e5\u72b6\u6001<\/span><br \/>\nansible db_servers -f <span class=\"token number\">10<\/span> -m <span class=\"token function\">service<\/span> -a <span class=\"token string\">&#034;name&#061;mysqld state&#061;restarted&#034;<\/span><br \/>\nansible db_servers -f <span class=\"token number\">10<\/span> -m <span class=\"token builtin class-name\">command<\/span> -a <span class=\"token string\">&#034;systemctl status mysqld | grep Active&#034;<\/span><\/p>\n<h4>5. \u6279\u91cf\u914d\u7f6e\u7ba1\u7406&#xff08;\u66ff\u6362\u914d\u7f6e\/\u4fee\u6539\u53c2\u6570&#xff09;<\/h4>\n<p>\u901a\u8fc7lineinfile\/replace\u6a21\u5757\u4fee\u6539\u914d\u7f6e\u6587\u4ef6&#xff0c;\u907f\u514d\u624b\u52a8\u7f16\u8f91\u3002<\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b1&#xff1a;\u4fee\u6539\u6240\u6709\u670d\u52a1\u5668\u7684SSH\u7aef\u53e3&#xff08;\u4ece22\u6539\u4e3a2222&#xff09;<\/span><br \/>\nansible all_servers -f <span class=\"token number\">50<\/span> -m lineinfile -a <span class=\"token string\">&#034;path&#061;\/etc\/ssh\/sshd_config regexp&#061;&#039;^Port&#039; line&#061;&#039;Port 2222&#039;&#034;<\/span><br \/>\nansible all_servers -f <span class=\"token number\">50<\/span> -m <span class=\"token function\">service<\/span> -a <span class=\"token string\">&#034;name&#061;sshd state&#061;restarted&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b2&#xff1a;\u7981\u7528\u6240\u6709\u670d\u52a1\u5668\u7684root\u8fdc\u7a0b\u767b\u5f55<\/span><br \/>\nansible all_servers -f <span class=\"token number\">50<\/span> -m lineinfile -a <span class=\"token string\">&#034;path&#061;\/etc\/ssh\/sshd_config regexp&#061;&#039;^PermitRootLogin&#039; line&#061;&#039;PermitRootLogin no&#039;&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b3&#xff1a;\u66ff\u6362\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u53d8\u91cf&#xff08;\u5982\u66ff\u6362\u6570\u636e\u5e93\u5730\u5740&#xff09;<\/span><br \/>\nansible web_servers -f <span class=\"token number\">20<\/span> -m replace -a <span class=\"token string\">&#034;path&#061;\/etc\/php.ini regexp&#061;&#039;192.168.1.30&#039; replace&#061;&#039;192.168.1.31&#039;&#034;<\/span><\/p>\n<h3>\u56db\u3001\u8fdb\u9636\u5b9e\u6218&#xff1a;Playbook&#xff08;100\u53f0\u670d\u52a1\u5668\u6807\u51c6\u5316\u914d\u7f6e&#xff09;<\/h3>\n<p>\u5355\u6761\u547d\u4ee4\u9002\u5408\u4e34\u65f6\u64cd\u4f5c&#xff0c;Playbook\u9002\u5408\u6807\u51c6\u5316\u3001\u53ef\u590d\u7528\u3001\u590d\u6742\u573a\u666f&#xff08;\u5982100\u53f0\u670d\u52a1\u5668\u521d\u59cb\u5316\u3001\u4e1a\u52a1\u90e8\u7f72&#xff09;\u3002<\/p>\n<h4>1. \u7f16\u5199Playbook&#xff08;\u670d\u52a1\u5668\u521d\u59cb\u5316\u793a\u4f8b&#xff09;<\/h4>\n<p>\u65b0\u5efaserver_init.yml&#xff0c;\u5b9e\u73b0100\u53f0\u670d\u52a1\u5668\u4e00\u952e\u521d\u59cb\u5316&#xff08;\u5173\u95ed\u9632\u706b\u5899\u3001\u4f18\u5316\u5185\u6838\u3001\u5b89\u88c5\u57fa\u7840\u5de5\u5177&#xff09;&#xff1a;<\/p>\n<p><span class=\"token punctuation\">&#8212;<\/span><br \/>\n<span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">hosts<\/span><span class=\"token punctuation\">:<\/span> all_servers  <span class=\"token comment\"># \u9488\u5bf9\u6240\u6709100\u53f0\u670d\u52a1\u5668<\/span><br \/>\n  <span class=\"token key atrule\">remote_user<\/span><span class=\"token punctuation\">:<\/span> root   <span class=\"token comment\"># \u767b\u5f55\u7528\u6237<\/span><br \/>\n  <span class=\"token key atrule\">gather_facts<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token boolean important\">true<\/span>  <span class=\"token comment\"># \u6536\u96c6\u670d\u52a1\u5668\u4fe1\u606f&#xff08;\u5982\u7cfb\u7edf\u7248\u672c&#xff09;<\/span><br \/>\n  <span class=\"token key atrule\">serial<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">50<\/span>          <span class=\"token comment\"># \u5206\u6279\u6267\u884c&#xff08;\u6bcf\u627950\u53f0&#xff0c;\u907f\u514d\u8d1f\u8f7d\u8fc7\u9ad8&#xff09;<\/span><\/p>\n<p>  <span class=\"token key atrule\">tasks<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token comment\"># \u4efb\u52a11&#xff1a;\u5173\u95ed\u9632\u706b\u5899\u548cSELinux<\/span><br \/>\n    <span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> \u5173\u95edfirewalld<br \/>\n      <span class=\"token key atrule\">service<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> firewalld<br \/>\n        <span class=\"token key atrule\">state<\/span><span class=\"token punctuation\">:<\/span> stopped<br \/>\n        <span class=\"token key atrule\">enabled<\/span><span class=\"token punctuation\">:<\/span> no<\/p>\n<p>    <span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> \u5173\u95edSELinux<br \/>\n      <span class=\"token key atrule\">lineinfile<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token key atrule\">path<\/span><span class=\"token punctuation\">:<\/span> \/etc\/selinux\/config<br \/>\n        <span class=\"token key atrule\">regexp<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#039;^SELINUX&#061;&#039;<\/span><br \/>\n        <span class=\"token key atrule\">line<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#039;SELINUX&#061;disabled&#039;<\/span><br \/>\n    <span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> \u7acb\u5373\u751f\u6548SELinux<br \/>\n      <span class=\"token key atrule\">command<\/span><span class=\"token punctuation\">:<\/span> setenforce 0<br \/>\n      <span class=\"token key atrule\">ignore_errors<\/span><span class=\"token punctuation\">:<\/span> yes  <span class=\"token comment\"># \u5ffd\u7565\u5df2\u5173\u95ed\u7684\u62a5\u9519<\/span><\/p>\n<p>    <span class=\"token comment\"># \u4efb\u52a12&#xff1a;\u5b89\u88c5\u57fa\u7840\u5de5\u5177<\/span><br \/>\n    <span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> \u5b89\u88c5\u5e38\u7528\u5de5\u5177<br \/>\n      <span class=\"token key atrule\">yum<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">[<\/span>wget<span class=\"token punctuation\">,<\/span> vim<span class=\"token punctuation\">,<\/span> net<span class=\"token punctuation\">&#8211;<\/span>tools<span class=\"token punctuation\">,<\/span> ntpdate<span class=\"token punctuation\">]<\/span><br \/>\n        <span class=\"token key atrule\">state<\/span><span class=\"token punctuation\">:<\/span> installed<\/p>\n<p>    <span class=\"token comment\"># \u4efb\u52a13&#xff1a;\u4f18\u5316\u5185\u6838\u53c2\u6570<\/span><br \/>\n    <span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> \u6dfb\u52a0\u5185\u6838\u914d\u7f6e<br \/>\n      <span class=\"token key atrule\">copy<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token key atrule\">content<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">|<\/span><span class=\"token scalar string\"><br \/>\n          net.bridge.bridge-nf-call-ip6tables &#061; 1<br \/>\n          net.bridge.bridge-nf-call-iptables &#061; 1<br \/>\n          net.ipv4.ip_forward &#061; 1<\/span><br \/>\n        <span class=\"token key atrule\">dest<\/span><span class=\"token punctuation\">:<\/span> \/etc\/sysctl.d\/k8s.conf<br \/>\n        <span class=\"token key atrule\">mode<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">0644<\/span><br \/>\n    <span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> \u751f\u6548\u5185\u6838\u53c2\u6570<br \/>\n      <span class=\"token key atrule\">command<\/span><span class=\"token punctuation\">:<\/span> sysctl <span class=\"token punctuation\">&#8211;<\/span><span class=\"token punctuation\">&#8211;<\/span>system<\/p>\n<p>    <span class=\"token comment\"># \u4efb\u52a14&#xff1a;\u540c\u6b65\u65f6\u95f4<\/span><br \/>\n    <span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> \u540c\u6b65\u7cfb\u7edf\u65f6\u95f4<br \/>\n      <span class=\"token key atrule\">shell<\/span><span class=\"token punctuation\">:<\/span> ntpdate ntp.aliyun.com <span class=\"token important\">&amp;&amp;<\/span> hwclock <span class=\"token punctuation\">&#8211;<\/span>w<\/p>\n<p>    <span class=\"token comment\"># \u4efb\u52a15&#xff1a;\u7981\u7528swap<\/span><br \/>\n    <span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> \u5173\u95edswap<br \/>\n      <span class=\"token key atrule\">command<\/span><span class=\"token punctuation\">:<\/span> swapoff <span class=\"token punctuation\">&#8211;<\/span>a<br \/>\n    <span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> \u6c38\u4e45\u7981\u7528swap<br \/>\n      <span class=\"token key atrule\">lineinfile<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token key atrule\">path<\/span><span class=\"token punctuation\">:<\/span> \/etc\/fstab<br \/>\n        <span class=\"token key atrule\">regexp<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#039;swap&#039;<\/span><br \/>\n        <span class=\"token key atrule\">line<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#039;#\\\\0&#039;<\/span><br \/>\n        <span class=\"token key atrule\">backrefs<\/span><span class=\"token punctuation\">:<\/span> yes<\/p>\n<h4>2. \u6267\u884cPlaybook&#xff08;\u4e00\u952e\u521d\u59cb\u5316100\u53f0\u670d\u52a1\u5668&#xff09;<\/h4>\n<p><span class=\"token comment\"># \u6267\u884cPlaybook&#xff08;\u5e76\u53d1\u657050&#xff0c;\u5206\u6279\u6267\u884c&#xff09;<\/span><br \/>\nansible-playbook -f <span class=\"token number\">50<\/span> server_init.yml<\/p>\n<p><span class=\"token comment\"># \u6267\u884c\u7ed3\u679c\u8bf4\u660e&#xff1a;<\/span><br \/>\n<span class=\"token comment\"># PLAY [all_servers] &#xff1a;\u4efb\u52a1\u5f00\u59cb<\/span><br \/>\n<span class=\"token comment\"># TASK [Gathering Facts] &#xff1a;\u6536\u96c6\u670d\u52a1\u5668\u4fe1\u606f<\/span><br \/>\n<span class=\"token comment\"># TASK [\u5173\u95edfirewalld] &#xff1a;\u6267\u884c\u5bf9\u5e94\u4efb\u52a1<\/span><br \/>\n<span class=\"token comment\"># &#8230; \u6bcf\u4e2a\u4efb\u52a1\u4f1a\u663e\u793a\u6210\u529f\/\u5931\u8d25\u7684\u670d\u52a1\u5668\u6570\u91cf<\/span><br \/>\n<span class=\"token comment\"># PLAY RECAP &#xff1a;\u6c47\u603b&#xff08;\u5982100\u53f0\u6210\u529f&#xff0c;0\u53f0\u5931\u8d25&#xff09;<\/span><\/p>\n<h4>3. Playbook\u9ad8\u7ea7\u6280\u5de7&#xff08;\u9002\u914d100\u53f0\u89c4\u6a21&#xff09;<\/h4>\n<ul>\n<li>\u5206\u6279\u6267\u884c&#xff1a;serial: 20&#xff08;\u6bcf\u627920\u53f0&#xff0c;\u6838\u5fc3\u4e1a\u52a1\u5fc5\u7528&#xff0c;\u907f\u514d\u96ea\u5d29&#xff09;&#xff1b;<\/li>\n<li>\u5931\u8d25\u91cd\u8bd5&#xff1a;\u6dfb\u52a0retries: 3&#xff08;\u5931\u8d25\u91cd\u8bd53\u6b21&#xff09;&#xff1b;<\/li>\n<li>\u6761\u4ef6\u6267\u884c&#xff1a;\u6309\u7cfb\u7edf\u7248\u672c\u6267\u884c\u4e0d\u540c\u64cd\u4f5c&#xff08;\u5982CentOS7\/8\u533a\u5206&#xff09;&#xff1b;<\/li>\n<li>\u53d8\u91cf\u590d\u7528&#xff1a;\u901a\u8fc7vars\u5b9a\u4e49\u53d8\u91cf&#xff0c;\u907f\u514d\u786c\u7f16\u7801\u3002<\/li>\n<\/ul>\n<p>\u793a\u4f8b&#xff08;\u6761\u4ef6\u6267\u884c&#043;\u5931\u8d25\u91cd\u8bd5&#xff09;&#xff1a;<\/p>\n<p><span class=\"token key atrule\">tasks<\/span><span class=\"token punctuation\">:<\/span><br \/>\n  <span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> \u5b89\u88c5docker&#xff08;CentOS7&#xff09;<br \/>\n    <span class=\"token key atrule\">yum<\/span><span class=\"token punctuation\">:<\/span><br \/>\n      <span class=\"token key atrule\">name<\/span><span class=\"token punctuation\">:<\/span> docker<br \/>\n      <span class=\"token key atrule\">state<\/span><span class=\"token punctuation\">:<\/span> installed<br \/>\n    <span class=\"token key atrule\">when<\/span><span class=\"token punctuation\">:<\/span> ansible_distribution &#061;&#061; &#034;CentOS&#034; and ansible_distribution_major_version &#061;&#061; &#034;7&#034;<br \/>\n    <span class=\"token key atrule\">retries<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">3<\/span><br \/>\n    <span class=\"token key atrule\">delay<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token number\">5<\/span>  <span class=\"token comment\"># \u91cd\u8bd5\u95f4\u96945\u79d2<\/span><br \/>\n    <span class=\"token key atrule\">register<\/span><span class=\"token punctuation\">:<\/span> result<br \/>\n    <span class=\"token key atrule\">until<\/span><span class=\"token punctuation\">:<\/span> result is succeeded<\/p>\n<h3>\u4e94\u3001100\u53f0\u670d\u52a1\u5668\u7ba1\u63a7\u907f\u5751\u6307\u5357&#xff08;\u6838\u5fc3&#xff09;<\/h3>\n<h4>1. \u6027\u80fd\u4e0e\u6548\u7387\u5751<\/h4>\n<ul>\n<li>\u57511&#xff1a;\u5e76\u53d1\u6570\u8bbe\u7f6e\u8fc7\u9ad8&#xff08;\u5982100&#xff09;&#xff0c;\u5bfc\u81f4\u63a7\u5236\u8282\u70b9\/\u88ab\u63a7\u8282\u70b9\u8d1f\u8f7d\u8fc7\u9ad8\u3002<br \/>\n\u2705 \u907f\u5751\u65b9\u6848&#xff1a;\u5e76\u53d1\u6570\u8bbe\u4e3a50&#xff08;100\u53f0&#xff09;&#xff0c;\u6838\u5fc3\u4e1a\u52a1\u670d\u52a1\u5668\u8bbe\u4e3a20&#xff0c;\u907f\u514d\u540c\u65f6\u64cd\u4f5c\u6240\u6709\u670d\u52a1\u5668\u3002<\/li>\n<li>\u57512&#xff1a;\u6267\u884c\u957f\u8017\u65f6\u64cd\u4f5c&#xff08;\u5982\u5b89\u88c5\u8f6f\u4ef6&#xff09;\u65f6\u963b\u585e&#xff0c;\u65e0\u8fdb\u5ea6\u53cd\u9988\u3002<br \/>\n\u2705 \u907f\u5751\u65b9\u6848&#xff1a;\u4f7f\u7528ansible-playbook -v\u67e5\u770b\u8be6\u7ec6\u8fdb\u5ea6&#xff0c;\u6216\u62c6\u5206\u4efb\u52a1\u4e3a\u591a\u4e2aPlaybook\u3002<\/li>\n<\/ul>\n<h4>2. \u8fde\u63a5\u4e0e\u6743\u9650\u5751<\/h4>\n<ul>\n<li>\u57511&#xff1a;\u90e8\u5206\u670d\u52a1\u5668SSH\u7aef\u53e3\u975e22&#xff0c;\u5bfc\u81f4\u8fde\u63a5\u5931\u8d25\u3002<br \/>\n\u2705 \u907f\u5751\u65b9\u6848&#xff1a;\u5728\u4e3b\u673a\u6e05\u5355\u4e2d\u6309\u670d\u52a1\u5668\u914d\u7f6e\u7aef\u53e3\u53d8\u91cf&#xff1a;[special_servers]<br \/>\n192.168.1.20 ansible_ssh_port&#061;2222<br \/>\n192.168.1.21 ansible_ssh_port&#061;2222<\/p>\n<\/li>\n<li>\u57512&#xff1a;\u666e\u901a\u7528\u6237\u6267\u884c\u65e0\u6743\u9650&#xff0c;sudo\u63d0\u793a\u8f93\u5bc6\u7801\u3002<br \/>\n\u2705 \u907f\u5751\u65b9\u6848&#xff1a;\u88ab\u63a7\u7aef\u914d\u7f6esudo\u514d\u5bc6&#xff0c;\u6216Playbook\u4e2d\u6dfb\u52a0sudo: yes&#xff1a;<span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">hosts<\/span><span class=\"token punctuation\">:<\/span> all_servers<br \/>\n  <span class=\"token key atrule\">remote_user<\/span><span class=\"token punctuation\">:<\/span> ops<br \/>\n  <span class=\"token key atrule\">become<\/span><span class=\"token punctuation\">:<\/span> yes  <span class=\"token comment\"># \u7b49\u540c\u4e8esudo<\/span><br \/>\n  <span class=\"token key atrule\">become_method<\/span><span class=\"token punctuation\">:<\/span> sudo<\/p>\n<\/li>\n<\/ul>\n<h4>3. \u6267\u884c\u5b89\u5168\u5751<\/h4>\n<ul>\n<li>\u57511&#xff1a;\u6279\u91cf\u91cd\u542f\u670d\u52a1\u5bfc\u81f4\u4e1a\u52a1\u96ea\u5d29&#xff08;\u5982100\u53f0Web\u670d\u52a1\u5668\u540c\u65f6\u91cd\u542f&#xff09;\u3002<br \/>\n\u2705 \u907f\u5751\u65b9\u6848&#xff1a;<\/p>\n<ul>\n<li>\u4f7f\u7528serial\u5206\u6279\u91cd\u542f&#xff1a;serial: 10&#xff08;\u6bcf\u627910\u53f0&#xff0c;\u95f4\u96945\u5206\u949f&#xff09;&#xff1b;<\/li>\n<li>\u6838\u5fc3\u4e1a\u52a1\u6dfb\u52a0\u5065\u5eb7\u68c0\u67e5&#xff1a;\u91cd\u542f\u540e\u9a8c\u8bc1\u670d\u52a1\u53ef\u7528\u518d\u6267\u884c\u4e0b\u4e00\u6279\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u57512&#xff1a;\u8bef\u64cd\u4f5c\u5168\u91cf\u670d\u52a1\u5668&#xff08;\u5982\u8bef\u5220\u6587\u4ef6&#xff09;\u3002<br \/>\n\u2705 \u907f\u5751\u65b9\u6848&#xff1a;<\/p>\n<ul>\n<li>\u6267\u884c\u524d\u5148\u5728\u6d4b\u8bd5\u673a\u9a8c\u8bc1&#xff1a;ansible web_servers &#8211;limit 192.168.1.10 -m command -a &#034;rm -rf \/tmp\/test&#034;&#xff1b;<\/li>\n<li>Playbook\u4e2d\u6dfb\u52a0check_mode: yes&#xff08;\u6a21\u62df\u6267\u884c&#xff0c;\u4e0d\u5b9e\u9645\u64cd\u4f5c&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>4. \u7ed3\u679c\u8ffd\u6eaf\u5751<\/h4>\n<ul>\n<li>\u5751&#xff1a;\u6279\u91cf\u64cd\u4f5c\u540e\u65e0\u65e5\u5fd7&#xff0c;\u65e0\u6cd5\u5b9a\u4f4d\u5931\u8d25\u670d\u52a1\u5668\u3002<br \/>\n\u2705 \u907f\u5751\u65b9\u6848&#xff1a;<\/p>\n<ul>\n<li>\u6267\u884c\u547d\u4ee4\u65f6\u8f93\u51fa\u65e5\u5fd7\u5230\u6587\u4ef6&#xff1a;ansible all_servers -f 50 -m command -a &#034;free -m&#034; &gt; \/tmp\/server_mem.log&#xff1b;<\/li>\n<li>Playbook\u6267\u884c\u65e5\u5fd7&#xff1a;ansible-playbook server_init.yml &gt; \/tmp\/init_log.log 2&gt;&amp;1&#xff1b;<\/li>\n<li>\u63d0\u53d6\u5931\u8d25\u670d\u52a1\u5668&#xff1a;grep &#034;FAILED&#034; \/tmp\/init_log.log | awk &#039;{print $1}&#039; &gt; \/tmp\/fail_servers.txt\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>\u516d\u3001\u4f01\u4e1a\u7ea7\u4f18\u5316&#xff08;100\u53f0\u670d\u52a1\u5668\u751f\u4ea7\u73af\u5883\u5fc5\u914d&#xff09;<\/h3>\n<h4>1. \u914d\u7f6eAnsible\u52a0\u901f&#xff08;\u63d0\u5347\u6267\u884c\u6548\u7387&#xff09;<\/h4>\n<p><span class=\"token comment\"># \u7f16\u8f91ansible\u914d\u7f6e\u6587\u4ef6<\/span><br \/>\n<span class=\"token function\">vim<\/span> \/etc\/ansible\/ansible.cfg<\/p>\n<p><span class=\"token comment\"># \u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>defaults<span class=\"token punctuation\">]<\/span><br \/>\nhost_key_checking <span class=\"token operator\">&#061;<\/span> False  <span class=\"token comment\"># \u5173\u95ed\u4e3b\u673a\u5bc6\u94a5\u68c0\u67e5<\/span><br \/>\npipelining <span class=\"token operator\">&#061;<\/span> True          <span class=\"token comment\"># \u5f00\u542f\u7ba1\u9053\u6a21\u5f0f&#xff0c;\u51cf\u5c11SSH\u8fde\u63a5\u6b21\u6570<\/span><br \/>\nforks <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">50<\/span>                 <span class=\"token comment\"># \u9ed8\u8ba4\u5e76\u53d1\u657050<\/span><br \/>\n<span class=\"token function\">timeout<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">10<\/span>               <span class=\"token comment\"># SSH\u8fde\u63a5\u8d85\u65f610\u79d2<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>ssh_connection<span class=\"token punctuation\">]<\/span><br \/>\ncontrol_path <span class=\"token operator\">&#061;<\/span> %<span class=\"token punctuation\">(<\/span>directory<span class=\"token punctuation\">)<\/span>s\/%%h-%%r  <span class=\"token comment\"># \u4f18\u5316SSH\u63a7\u5236\u8def\u5f84<\/span><br \/>\ncontrol_master <span class=\"token operator\">&#061;<\/span> auto       <span class=\"token comment\"># \u5f00\u542fSSH\u957f\u8fde\u63a5<\/span><br \/>\ncontrol_persist <span class=\"token operator\">&#061;<\/span> 30s       <span class=\"token comment\"># \u957f\u8fde\u63a5\u4fdd\u630130\u79d2<\/span><\/p>\n<h4>2. \u642d\u5efaAnsible Tower\/AWX&#xff08;\u53ef\u89c6\u5316\u7ba1\u63a7&#xff09;<\/h4>\n<p>\u5bf9\u4e8e\u56e2\u961f\u4f7f\u7528\u573a\u666f&#xff0c;\u53ef\u642d\u5efaAWX&#xff08;Ansible Tower\u5f00\u6e90\u7248&#xff09;&#xff0c;\u5b9e\u73b0&#xff1a;<\/p>\n<ul>\n<li>Web\u754c\u9762\u4e00\u952e\u6267\u884cPlaybook&#xff1b;<\/li>\n<li>100\u53f0\u670d\u52a1\u5668\u53ef\u89c6\u5316\u5206\u7ec4&#xff1b;<\/li>\n<li>\u64cd\u4f5c\u5ba1\u8ba1\u65e5\u5fd7\u3001\u6743\u9650\u7ba1\u63a7&#xff1b;<\/li>\n<li>\u5b9a\u65f6\u4efb\u52a1&#xff08;\u5982\u6bcf\u65e5\u670d\u52a1\u5668\u5de1\u68c0&#xff09;\u3002<\/li>\n<\/ul>\n<h4>3. \u914d\u7f6e\u7ba1\u7406\u4e0e\u7248\u672c\u63a7\u5236<\/h4>\n<ul>\n<li>\u5c06Playbook\u3001\u914d\u7f6e\u6587\u4ef6\u7eb3\u5165Git\u7ba1\u7406&#xff0c;\u907f\u514d\u811a\u672c\u4e22\u5931&#xff1b;<\/li>\n<li>\u6309\u4e1a\u52a1\u5212\u5206Playbook&#xff08;\u5982web_init.yml\/db_init.yml&#xff09;&#xff0c;\u4fbf\u4e8e\u7ef4\u62a4&#xff1b;<\/li>\n<li>\u5b9a\u671f\u66f4\u65b0\u670d\u52a1\u5668\u6e05\u5355&#xff0c;\u786e\u4fdd\u548c\u5b9e\u9645\u96c6\u7fa4\u4e00\u81f4\u3002<\/li>\n<\/ul>\n<h3>\u4e03\u3001\u603b\u7ed3<\/h3>\n<h4>\u5173\u952e\u70b9\u56de\u987e<\/h4>\n<li>Ansible\u7ba1\u63a7100\u53f0\u670d\u52a1\u5668\u6838\u5fc3&#xff1a;\u514d\u5bc6\u767b\u5f55&#043;\u4e3b\u673a\u6e05\u5355&#043;\u5e76\u53d1\u63a7\u5236&#xff0c;\u4f18\u5148\u914d\u7f6e\u5206\u7ec4\u548c\u5168\u5c40\u53d8\u91cf&#xff1b;<\/li>\n<li>\u57fa\u7840\u64cd\u4f5c\u7528ansible\u547d\u4ee4&#xff08;\u4e34\u65f6\u6267\u884c&#xff09;&#xff0c;\u6807\u51c6\u5316\u64cd\u4f5c\u7528Playbook&#xff08;\u53ef\u590d\u7528\u3001\u53ef\u5ba1\u8ba1&#xff09;&#xff1b;<\/li>\n<li>\u907f\u5751\u6838\u5fc3&#xff1a;\u5206\u6279\u6267\u884c\u6838\u5fc3\u4e1a\u52a1\u3001\u6267\u884c\u524d\u6d4b\u8bd5\u3001\u5168\u91cf\u65e5\u5fd7\u8bb0\u5f55\u3001\u63a7\u5236\u5e76\u53d1\u6570\u3002<\/li>\n<p>\u901a\u8fc7\u672c\u6587\u7684\u65b9\u6848&#xff0c;\u4f60\u53ef\u5b9e\u73b0100\u53f0\u670d\u52a1\u5668\u7684\u4e00\u952e\u547d\u4ee4\u6267\u884c\u3001\u6587\u4ef6\u5206\u53d1\u3001\u8f6f\u4ef6\u5b89\u88c5\u3001\u914d\u7f6e\u6807\u51c6\u5316&#xff0c;\u517c\u987e\u6548\u7387\u4e0e\u5b89\u5168\u3002\u751f\u4ea7\u73af\u5883\u4e2d&#xff0c;\u5efa\u8bae\u7ed3\u5408AWX\u53ef\u89c6\u5316\u7ba1\u63a7&#043;Git\u7248\u672c\u63a7\u5236&#xff0c;\u5f62\u6210\u5b8c\u6574\u7684\u6279\u91cf\u8fd0\u7ef4\u4f53\u7cfb\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ansible 100\u53f0\u670d\u52a1\u5668\u4e00\u952e\u7ba1\u63a7\u5b9e\u6218&#xff08;\u5b8c\u6574\u7248&#xff09;<br \/>\nAnsible\u662f100\u53f0\u670d\u52a1\u5668\u6279\u91cf\u7ba1\u7406\u7684\u4f01\u4e1a\u7ea7\u6807\u51c6\u65b9\u6848\u2014\u2014\u65e0\u5ba2\u6237\u7aef\u3001SSH\u539f\u751f\u8fde\u63a5\u3001\u914d\u7f6e\u5373\u4ee3\u7801\u3001\u652f\u6301\u5e76\u53d1\/\u5206\u6279\/\u56de\u6eda&#xff0c;\u65e2\u80fd\u89e3\u51b3\u624b\u5de5\u64cd\u4f5c\u7684\u4f4e\u6548\u95ee\u9898&#xff0c;\u53c8\u80fd\u89c4\u907fShell\u811a\u672c\u7684\u7a33\u5b9a\u6027\u98ce\u9669\u3002\u672c\u6587\u4ece\u73af\u5883\u642d\u5efa\u3001\u6838\u5fc3\u529f\u80fd\u3001\u5b9e\u6218\u573a\u666f\u5230\u907f\u5751\u6307\u5357&#xff0c;\u5b8c\u6574\u8986\u76d6100\u53f0\u670d\u52a1\u5668\u7684\u4e00\u952e\u7ba1\u63a7\u5168\u6d41\u7a0b&#xff0c;\u6240\u6709\u811a\u672c\u53ef\u76f4\u63a5\u590d\u5236\u843d\u5730\u3002<br \/>\n\u4e00\u3001\u524d\u7f6e\u6761\u4ef6&#xff08;\u5fc5\u770b&#xff09;<\/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,89,43],"topic":[],"class_list":["post-79601","post","type-post","status-publish","format-standard","hentry","category-server","tag-ansible","tag-git","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Ansible 100 \u53f0\u670d\u52a1\u5668\u4e00\u952e\u7ba1\u63a7\u5b9e\u6218 \u8fdb\u9636\u7248 - \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\/79601.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ansible 100 \u53f0\u670d\u52a1\u5668\u4e00\u952e\u7ba1\u63a7\u5b9e\u6218 \u8fdb\u9636\u7248 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Ansible 100\u53f0\u670d\u52a1\u5668\u4e00\u952e\u7ba1\u63a7\u5b9e\u6218&#xff08;\u5b8c\u6574\u7248&#xff09; Ansible\u662f100\u53f0\u670d\u52a1\u5668\u6279\u91cf\u7ba1\u7406\u7684\u4f01\u4e1a\u7ea7\u6807\u51c6\u65b9\u6848\u2014\u2014\u65e0\u5ba2\u6237\u7aef\u3001SSH\u539f\u751f\u8fde\u63a5\u3001\u914d\u7f6e\u5373\u4ee3\u7801\u3001\u652f\u6301\u5e76\u53d1\/\u5206\u6279\/\u56de\u6eda&#xff0c;\u65e2\u80fd\u89e3\u51b3\u624b\u5de5\u64cd\u4f5c\u7684\u4f4e\u6548\u95ee\u9898&#xff0c;\u53c8\u80fd\u89c4\u907fShell\u811a\u672c\u7684\u7a33\u5b9a\u6027\u98ce\u9669\u3002\u672c\u6587\u4ece\u73af\u5883\u642d\u5efa\u3001\u6838\u5fc3\u529f\u80fd\u3001\u5b9e\u6218\u573a\u666f\u5230\u907f\u5751\u6307\u5357&#xff0c;\u5b8c\u6574\u8986\u76d6100\u53f0\u670d\u52a1\u5668\u7684\u4e00\u952e\u7ba1\u63a7\u5168\u6d41\u7a0b&#xff0c;\u6240\u6709\u811a\u672c\u53ef\u76f4\u63a5\u590d\u5236\u843d\u5730\u3002 \u4e00\u3001\u524d\u7f6e\u6761\u4ef6&#xff08;\u5fc5\u770b&#xff09;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/79601.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-03-02T08:05:49+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=\"7 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/79601.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/79601.html\",\"name\":\"Ansible 100 \u53f0\u670d\u52a1\u5668\u4e00\u952e\u7ba1\u63a7\u5b9e\u6218 \u8fdb\u9636\u7248 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-03-02T08:05:49+00:00\",\"dateModified\":\"2026-03-02T08:05:49+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/79601.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/79601.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/79601.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Ansible 100 \u53f0\u670d\u52a1\u5668\u4e00\u952e\u7ba1\u63a7\u5b9e\u6218 \u8fdb\u9636\u7248\"}]},{\"@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 100 \u53f0\u670d\u52a1\u5668\u4e00\u952e\u7ba1\u63a7\u5b9e\u6218 \u8fdb\u9636\u7248 - \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\/79601.html","og_locale":"zh_CN","og_type":"article","og_title":"Ansible 100 \u53f0\u670d\u52a1\u5668\u4e00\u952e\u7ba1\u63a7\u5b9e\u6218 \u8fdb\u9636\u7248 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Ansible 100\u53f0\u670d\u52a1\u5668\u4e00\u952e\u7ba1\u63a7\u5b9e\u6218&#xff08;\u5b8c\u6574\u7248&#xff09; Ansible\u662f100\u53f0\u670d\u52a1\u5668\u6279\u91cf\u7ba1\u7406\u7684\u4f01\u4e1a\u7ea7\u6807\u51c6\u65b9\u6848\u2014\u2014\u65e0\u5ba2\u6237\u7aef\u3001SSH\u539f\u751f\u8fde\u63a5\u3001\u914d\u7f6e\u5373\u4ee3\u7801\u3001\u652f\u6301\u5e76\u53d1\/\u5206\u6279\/\u56de\u6eda&#xff0c;\u65e2\u80fd\u89e3\u51b3\u624b\u5de5\u64cd\u4f5c\u7684\u4f4e\u6548\u95ee\u9898&#xff0c;\u53c8\u80fd\u89c4\u907fShell\u811a\u672c\u7684\u7a33\u5b9a\u6027\u98ce\u9669\u3002\u672c\u6587\u4ece\u73af\u5883\u642d\u5efa\u3001\u6838\u5fc3\u529f\u80fd\u3001\u5b9e\u6218\u573a\u666f\u5230\u907f\u5751\u6307\u5357&#xff0c;\u5b8c\u6574\u8986\u76d6100\u53f0\u670d\u52a1\u5668\u7684\u4e00\u952e\u7ba1\u63a7\u5168\u6d41\u7a0b&#xff0c;\u6240\u6709\u811a\u672c\u53ef\u76f4\u63a5\u590d\u5236\u843d\u5730\u3002 \u4e00\u3001\u524d\u7f6e\u6761\u4ef6&#xff08;\u5fc5\u770b&#xff09;","og_url":"https:\/\/www.wsisp.com\/helps\/79601.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-03-02T08:05:49+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"7 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/79601.html","url":"https:\/\/www.wsisp.com\/helps\/79601.html","name":"Ansible 100 \u53f0\u670d\u52a1\u5668\u4e00\u952e\u7ba1\u63a7\u5b9e\u6218 \u8fdb\u9636\u7248 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-03-02T08:05:49+00:00","dateModified":"2026-03-02T08:05:49+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/79601.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/79601.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/79601.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Ansible 100 \u53f0\u670d\u52a1\u5668\u4e00\u952e\u7ba1\u63a7\u5b9e\u6218 \u8fdb\u9636\u7248"}]},{"@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\/79601","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=79601"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/79601\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=79601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=79601"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=79601"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=79601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}