{"id":257,"date":"2017-01-15T22:23:24","date_gmt":"2017-01-15T14:23:24","guid":{"rendered":"http:\/\/www.rao-bing.cn\/?p=257"},"modified":"2020-01-06T16:13:33","modified_gmt":"2020-01-06T08:13:33","slug":"ansible-2-playbook-oracle-em13c-agent-prepare","status":"publish","type":"post","link":"http:\/\/www.rao-bing.cn\/index.php\/2017\/01\/15\/257\/","title":{"rendered":"Ansible \u5b66\u4e60\u7b14\u8bb02&#8211;\u81ea\u52a8\u5b8c\u6210Oracle EM13c Agent\u5b89\u88c5\u524d\u7684\u4e3b\u673a\u914d\u7f6e\u5de5\u4f5c"},"content":{"rendered":"<h3>\u524d\u8a00<\/h3>\n<p>\u6211\u89c9\u5f97\u5b66\u4e60\u4e00\u4e2a\u5de5\u5177\uff0c\u80fd\u591f\u8fb9\u5b66\u8fb9\u7528\u662f\u6700\u5e78\u8fd0\u7684\uff0c\u56e0\u4e3a\u8fd9\u6837\u5370\u8c61\u6df1\u523b\uff0c\u5982\u679c\u7528\u4e0d\u4e0a\uff0c\u53ea\u662f\u5b66\u4e60\u7f51\u4e0a\u7684\u4f8b\u5b50\uff0c\u4f30\u8ba1\u8fc7\u51e0\u5929\u4e5f\u5c31\u5fd8\u4e86\u3002<\/p>\n<p>Oracle Enterprise Manager 12c\uff0c13c\u5728\u90e8\u7f72agent\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528&#8221;push&#8221;\u65b9\u5f0f\u8fdb\u884c\uff0c\u7b80\u5355\u8bf4\uff0c\u5c31\u662f\u4eceEM Console\u53d1\u8d77\u4e00\u4e2a\u4efb\u52a1\uff0c&#8221;push&#8221;\u8f6f\u4ef6\u4ecb\u8d28\uff0c\u5b89\u88c5\u3001\u914d\u7f6e\u5168\u90e8\u81ea\u52a8\u5b8c\u6210\u3002\u542c\u8d77\u6765\u633a\u4e0d\u9519\uff0c\u4f46\u662f\u5b9e\u9645\u4e0a\uff0c\u4e3a\u4e86\u80fd\u591f\u81ea\u52a8\u5316\u3001\u6279\u91cf\u5316\u5b8c\u6210\u8fd9\u4e2aagent deploy\u7684\u5de5\u4f5c\uff0c\u5728\u9700\u8981\u5b89\u88c5agent\u7684\u4e3b\u673a\u4e0a\u8fd8\u662f\u8981\u505a\u4e00\u4e9b\u7410\u788e\u7684\u51c6\u5907\u5de5\u4f5c\u7684\uff0c\u4ee5\u524d\u4e00\u76f4\u89c9\u5f97\u673a\u5668\u591a\u4e86\u5f88\u9ebb\u70e6\uff0c\u4f46\u662f\u4e5f\u6ca1\u5565\u597d\u529e\u6cd5\uff0c\u73b0\u5728\u5b66\u4e86ansible\uff0c\u5c31\u60f3\u8bd5\u8bd5\u770b\u770b\u7528ansible\u80fd\u4e0d\u80fd\u81ea\u52a8\u5b8c\u6210agent\u5b89\u88c5\u524d\u7684\u90a3\u4e9b\u914d\u7f6e\u5de5\u4f5c\u3002<\/p>\n<p>\u6211\u4eec\u5148\u770b\u770b\u4e3a\u4e86\u5b89\u88c5agent\uff0c\u4e3b\u673a\u5177\u4f53\u9700\u8981\u505a\u54ea\u4e9b\u5de5\u4f5c\uff1a<\/p>\n<ol>\n<li>\n<div style=\"text-align: justify;\"><span style=\"font-size: 10pt;\">\u521b\u5efa\u7528\u6237\u548c\u7ec4\uff0c\u4e00\u822c\u7ec4\u662fdba\uff0c\u7528\u6237\u662foracle\uff0c\u5982\u679c\u4e3b\u673a\u5df2\u7ecf\u90e8\u7f72\u4e86Oracle\u8f6f\u4ef6\uff0c\u8fd9\u4e9b\u5e94\u8be5\u90fd\u5df2\u7ecf\u6709\u4e86\uff0c\u4f46\u662f\u5f88\u591a\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u80fd\u662f\u5728\u90e8\u7f72Oracle\u8f6f\u4ef6\u4e4b\u524d\u5c31\u8981\u90e8\u7f72agent\uff08\u6bd4\u5982\u4f7f\u7528EM13c\u81ea\u52a8\u90e8\u7f72Oracle\u8f6f\u4ef6\u7684\u573a\u666f\uff09<br \/>\n<\/span><\/div>\n<\/li>\n<li>\n<div style=\"text-align: justify;\"><span style=\"font-size: 10pt;\">\u4fee\u6539\/etc\/sudoers\u6587\u4ef6\uff0c\u4fee\u6539\u5176\u4e2d\u7684\u4e24\u4e2a\u9009\u9879\uff0c\u5e76\u628a\u5b89\u88c5agent\u7684\u7528\u6237\u52a0\u8fdb\u53bb\uff0c\u4e00\u822c\u662foracle<br \/>\n<\/span><\/div>\n<\/li>\n<li>\n<div style=\"text-align: justify;\"><span style=\"font-size: 10pt;\">\u5173\u6389\u9632\u706b\u5899\u6216\u589e\u52a0\u9632\u706b\u5899\u89c4\u5219<br \/>\n<\/span><\/div>\n<\/li>\n<li>\n<div style=\"text-align: justify;\"><span style=\"font-size: 10pt;\">\u4fee\u6539\/etc\/hosts\uff0c\u8ba9OMS\u548cagent\u6240\u5728\u7684\u673a\u5668\u4e92\u76f8\u53ef\u4ee5\u7528\u4e3b\u673a\u540d\u8bbf\u95ee<br \/>\n<\/span><\/div>\n<\/li>\n<\/ol>\n<p>\u4e0b\u9762\u6211\u4eec\u5c31\u770b\u4e00\u4e0b\u4f7f\u7528ansible\u600e\u4e48\u5b8c\u6210\u8fd9\u4e9b\u5de5\u4f5c\uff0c\u4e3a\u4e86\u7814\u7a76\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u51c6\u5907\u7684\u73af\u5883\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<div>\n<table style=\"border-collapse: collapse;\" border=\"0\">\n<colgroup>\n<col style=\"width: 103px;\" \/>\n<col style=\"width: 206px;\" \/>\n<col style=\"width: 310px;\" \/>\n<col style=\"width: 310px;\" \/><\/colgroup>\n<tbody valign=\"top\">\n<tr>\n<td style=\"padding-left: 7px; padding-right: 7px; border: solid 0.5pt;\"><span style=\"font-size: 10pt;\">\u4e3b\u673aIP\u5730\u5740<\/span><\/td>\n<td style=\"padding-left: 7px; padding-right: 7px; border-top: solid 0.5pt; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;\"><span style=\"font-size: 10pt;\">\u4e3b\u673a\u540d<\/span><\/td>\n<td style=\"padding-left: 7px; padding-right: 7px; border-top: solid 0.5pt; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;\"><span style=\"font-size: 10pt;\">\u4e3b\u673aOS &amp;Version<\/span><\/td>\n<td style=\"padding-left: 7px; padding-right: 7px; border-top: solid 0.5pt; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;\"><span style=\"font-size: 10pt;\">\u5b89\u88c5\u7684\u8f6f\u4ef6<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"padding-left: 7px; padding-right: 7px; border-top: none; border-left: solid 0.5pt; border-bottom: solid 0.5pt; border-right: solid 0.5pt;\"><span style=\"font-size: 10pt;\">192.168.0.39<\/span><\/td>\n<td style=\"padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;\"><span style=\"font-size: 10pt;\">&#8220;em13c.hthorizon.com&#8221;<\/span><\/td>\n<td style=\"padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;\"><span style=\"font-size: 10pt;\">Oracle Enterprise Linux 6.5<\/span><\/td>\n<td style=\"padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;\"><span style=\"font-size: 10pt;\">EM13cR2 OMS\uff0cAnsible<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"padding-left: 7px; padding-right: 7px; border-top: none; border-left: solid 0.5pt; border-bottom: solid 0.5pt; border-right: solid 0.5pt;\"><span style=\"font-size: 10pt;\">192.168.0.40<\/span><\/td>\n<td style=\"padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;\"><span style=\"font-size: 10pt;\">&#8220;ol71vmta.hthorizon.com&#8221;<\/span><\/td>\n<td style=\"padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;\"><span style=\"font-size: 10pt;\">Oracle Enterprise Linux 7.1<\/span><\/td>\n<td style=\"padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;\"><span style=\"font-size: 10pt;\">EM Agent 13cR2 \uff08\u51c6\u5907\u5b89\u88c5)<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"padding-left: 7px; padding-right: 7px; border-top: none; border-left: solid 0.5pt; border-bottom: solid 0.5pt; border-right: solid 0.5pt;\"><span style=\"font-size: 10pt;\">192.168.0.41<\/span><\/td>\n<td style=\"padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;\"><span style=\"font-size: 10pt;\">&#8220;ol71vm1.hthorizon.com&#8221;<\/span><\/td>\n<td style=\"padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;\"><span style=\"font-size: 10pt;\">Oracle Enterprise Linux 7.1<\/span><\/td>\n<td style=\"padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;\"><span style=\"font-size: 10pt;\">EM Agent 13cR2 \uff08\u51c6\u5907\u5b89\u88c5\uff09<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>192.168.0.40\u548c192.168.0.41\u90fd\u662f\u65b0\u5b89\u88c5\uff0c\u9664\u4e86\u5728\u5b89\u88c5\u65f6\u914d\u7f6e\u7684\u4e3b\u673a\u540d\u548cip\u5730\u5740\uff0c\u5176\u4ed6\u90fd\u662f\u7f3a\u7701\u8bbe\u7f6e\uff0c\u5b89\u88c5\u8f6f\u4ef6\u9009\u62e9\u7684\u662f\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/011517_1422_Ansible21.png\" alt=\"\" \/><\/p>\n<h3>Ansible playbook\u4ecb\u7ecd<\/h3>\n<p>\u4f7f\u7528ansible\u547d\u4ee4\u884c\u4e00\u6761\u4e00\u6761\u6267\u884c\u547d\u4ee4\uff0c\u88ab\u79f0\u4e3aadhoc\u65b9\u5f0f\uff0c\u4e5f\u5c31\u662f\u5373\u5e2d\u65b9\u5f0f\uff0c\u800c\u4f7f\u7528playbook\u5c31\u662f\u5c06\u591a\u6761\u547d\u4ee4\u6309\u4e00\u5b9a\u7684\u8bed\u6cd5\u7ec4\u5408\u6210\u4e00\u4e2a\u96c6\u5408\uff0c\u9664\u4e86\u5c06\u547d\u4ee4\u7ec4\u5408\u5728\u4e00\u8d77\u6309\u987a\u5e8f\u6267\u884c\u5916\uff0cplaybook\u8fd8\u63d0\u4f9b\u4e86\u66f4\u52a0\u590d\u6742\u7684\u529f\u80fd\uff0c\u6bd4\u5982\u6309\u4e00\u5b9a\u7684\u6761\u4ef6\u6267\u884c\uff0c\u6bd4\u5982\u4f7f\u7528\u53d8\u91cf\uff0cplaybook\u5c31\u662fansible\u7279\u6709\u7684\u811a\u672c\u8bed\u8a00\uff0c\u901a\u8fc7playbook\uff0c\u53ef\u4ee5\u5b8c\u6210\u5f88\u591a\u590d\u6742\u7684\u5de5\u4f5c\u3002<\/p>\n<p>\u5177\u4f53\u7684\u4ecb\u7ecd\u53ef\u4ee5\u53c2\u8003\uff1a<a href=\"http:\/\/ansible-tran.readthedocs.io\/en\/latest\/docs\/playbooks_intro.html\">http:\/\/ansible-tran.readthedocs.io\/en\/latest\/docs\/playbooks_intro.html<\/a><\/p>\n<p>\u6211\u4eec\u524d\u9762\u63d0\u5230\u7684\u4e8b\u60c5\uff0c\u4ece\u67d0\u79cd\u7a0b\u5ea6\u4e0a\u5c06\uff0c\u662f\u4f7f\u7528adhoc\u5b8c\u6210\u4e0d\u4e86\u7684\uff0c\u6216\u8005\u8bf4\u4e0d\u80fd\u81ea\u52a8\u5316\u5b8c\u6210\uff0c\u6240\u4ee5\u6211\u4eec\u5fc5\u987b\u5b66\u4e60playbook\u3002<\/p>\n<p>Playbook\u662fYAML\u683c\u5f0f\u7684\u6587\u672c\u6587\u4ef6\uff0c\u6700\u57fa\u672c\u7684\u6784\u6210\uff1a\u4e3b\u673a\uff0c\u7528\u6237\uff0c\u4efb\u52a1<\/p>\n<p>\u6bd4\u5982\uff1a<\/p>\n<pre class=\"wrap:true lang:yaml decode:true \" >- hosts: mygroup\r\n  remote_user: root\r\n  tasks:\r\n    - name: disable selinux\r\n      command: \/sbin\/setenforce 0<\/pre>\n<p>hosts: \u540e\u9762\u7ed9\u51fa\u7684\u662f\u76ee\u6807\u4e3b\u673a\u7684\u540d\u5b57\u6216inventory\u6587\u4ef6\u4e2d\u7684\u4e3b\u673a\u7ec4\u540d\uff0cremote_user\u5c31\u662f\u4f7f\u7528\u54ea\u4e2a\u7528\u6237\u6267\u884ctask\uff0ctasks\u662f\u4efb\u52a1\u5217\u8868\uff0c\u5f62\u5f0f\u4e00\u822c\u662f\u540d\u5b57+\u5177\u4f53\u4efb\u52a1\u3002<\/p>\n<p>\u5177\u4f53\u4efb\u52a1\u4e00\u822c\u662f\u6a21\u5757\u540d+\u6a21\u5757\u53c2\u6570\uff0c\u6bd4\u5982\u4e0a\u9762\u4f8b\u5b50\u4e2dcommand\u5c31\u662f\u4e00\u4e2a\u6a21\u5757\uff0cansible\u9884\u5148\u5b9a\u4e49\u4e86\u5f88\u591a\u4f7f\u7528\u7684\u6a21\u5757\uff0c\u5177\u4f53\u5217\u8868\u548c\u6761\u7528\u65b9\u6cd5\u53ef\u4ee5\u53c2\u89c1\uff1a<\/p>\n<p><a href=\"http:\/\/docs.ansible.com\/ansible\/list_of_all_modules.html\">http:\/\/docs.ansible.com\/ansible\/list_of_all_modules.html<\/a><\/p>\n<p>\u7528\u6237\u4e5f\u53ef\u4ee5\u81ea\u5df1\u5199\u6a21\u5757\uff0c\u6211\u4eec\u540e\u7eed\u518d\u7814\u7a76\u5427\uff0c\u4e00\u53e3\u6ca1\u6cd5\u5403\u6210\u80d6\u5b50\u554a\u3002<\/p>\n<p>playbook\u6267\u884c\u7684\u65b9\u6cd5\uff1a# ansible-playbook &lt;playbook\u6587\u4ef6\u540d&gt;<\/p>\n<p>Playbook\u7684\u7406\u8bba\u53ea\u662f\u8fd8\u6709\u5f88\u591a\uff0c\u5176\u5b9e\u6709\u5f88\u591a\u4eba\u90fd\u5df2\u7ecf\u5199\u8fc7\u76f8\u5173\u7684\u6587\u7ae0\uff0c\u5927\u5bb6\u53ef\u4ee5baidu\u6216google\uff0c\u6700\u6743\u5a01\u7684\u4ecb\u7ecd\uff1a<\/p>\n<p><a href=\"http:\/\/docs.ansible.com\/ansible\/playbooks.html\">http:\/\/docs.ansible.com\/ansible\/playbooks.html<\/a><\/p>\n<h3>prepare_emagent.yml<\/h3>\n<p>\u4e3a\u4e86\u6ee1\u8db3\u524d\u9762\u63d0\u5230\u7684\u9700\u6c42\uff0c\u5b66\u4e60\u7814\u7a76\u4e86\u597d\u4e45\uff0c\u5199\u6210\u4e86\u8fd9\u4e2aplaybook\u6587\u4ef6\uff1a<\/p>\n<pre class=\"lang:yaml decode:true \" ># cat prepare_emagent.yml \r\n- name: prepare em agent \r\n  hosts: mygroup\r\n  remote_user: root\r\n  gather_facts: yes\r\n  vars:\r\n     mypassword: '$6$rounds=656000$GgYWhqVPEO30bj9k$pANNLPscsN5rOxlG8gTvfiv.kGAb3EgUgkTPeGMWBTM3u.P5MhKQTTZtuSVIbtCb2Y2b2RE9kq\/eaUPapLC.G1'\r\n  tasks:\r\n   - name: modify requiretty in sudoers\r\n     lineinfile: dest=\/etc\/sudoers regexp='^Defaults(\\s+)requiretty' line='Defaults   !requiretty' backrefs=yes state=present\r\n   - name: modify visiblepw in sudoers\r\n     lineinfile: dest=\/etc\/sudoers regexp='^Defaults(\\s+)!visiblepw' line='Defaults   visiblepw' backrefs=yes state=present\r\n   - name: add oracle to sudoers\r\n     lineinfile: dest=\/etc\/sudoers line='oracle ALL=(ALL) ALL' state=present\r\n   - name: disable firewalld\r\n     raw: systemctl disable firewalld\r\n   - name: stop firewalld\r\n     raw: systemctl stop firewalld\r\n   - name: create dba group\r\n     group: name=dba state=present\r\n   - name: create oracle user\r\n     user: name=oracle password={{mypassword}} group=dba\r\n   - name: add self name in \/etc\/hosts\r\n     lineinfile: dest=\/etc\/hosts line='{{ansible_default_ipv4.address}}\\t{{ansible_hostname}}.hthorizon.com\\t{{ansible_hostname}}'\r\n   - name: add OMS name in \/etc\/hosts\r\n     lineinfile: dest=\/etc\/hosts line='192.168.0.39\\tem13c.hthorizon.com\\tem13c' state=present\r\n<\/pre>\n<p>\u4e0b\u9762\u9010\u6761\u4ecb\u7ecd\uff1a<\/p>\n<p><strong>hosts\uff1a<br \/>\n<\/strong><\/p>\n<p>\u540e\u9762\u5c31\u662finventory\u6587\u4ef6\u4e2d\u7684\u7ec4\u540d\uff0cinventory\u6587\u4ef6\u5185\u5bb9\uff1a<\/p>\n<pre class=\"lang:default decode:true \" ># cat \/etc\/ansible\/hosts\r\n[mygroup]\r\n192.168.0.40\r\n192.168.0.41<\/pre>\n<p><strong>gather_facts: yes<br \/>\n<\/strong><\/p>\n<p>\u4ee3\u8868\u6536\u96c6\u4e3b\u673a\u914d\u7f6e\u4fe1\u606f\uff0c\u8fd9\u4e9b\u914d\u7f6e\u4fe1\u606f\u5728\u540e\u9762\u53ef\u4ee5\u5f15\u7528\uff0c\u6765\u5b9e\u73b0\u6bcf\u4e2a\u4e3b\u673a\u4e0d\u540c\u7684\u4efb\u52a1\u5185\u5bb9\u3002<\/p>\n<p><strong>vars:<br \/>\n<\/strong><\/p>\n<p>\u540e\u9762\u662f\u5b9a\u4e49\u7684\u53d8\u91cf\uff0c\u5728\u8fd9\u91cc\uff0c\u6211\u53ea\u5b9a\u4e49\u4e86\u4e00\u4e2a\u53d8\u91cf\uff0c\u5c31\u662f\u521b\u5efa\u7528\u6237\u7684passwd\uff0c\u4e3a\u4e86\u65b9\u4fbf\uff0c\u4e00\u822c\u5728\u4f7f\u7528ansible\u521b\u5efa\u7528\u6237\u65f6\uff0c\u662f\u76f4\u63a5\u7528\u52a0\u5bc6\u540e\u7684\u53e3\u4ee4\u5b57\u7b26\u4e32\u66f4\u65b0shadow\u6587\u4ef6\uff0c\u5f53\u7136\u8fd9\u4e2a\u662fuser\u6a21\u5757\u5b8c\u6210\u7684\uff0c\u6211\u4eec\u4e0d\u7528\u64cd\u5fc3\u7ec6\u8282\u3002\u5f53\u7136\uff0c\u4e3a\u4e86\u751f\u6210\u8fd9\u4e2a\u52a0\u5bc6\u7684\u53e3\u4ee4\uff0c\u6211\u4eec\u9700\u8981\u6309\u7167<a href=\"http:\/\/docs.ansible.com\/ansible\/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module\">http:\/\/docs.ansible.com\/ansible\/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module<\/a>\u7684\u6307\u793a\uff0c\u5b89\u88c5passlib\uff0c\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"https:\/\/pypi.python.org\/pypi\/passlib\">https:\/\/pypi.python.org\/pypi\/passlib<\/a><\/p>\n<p>\u5b89\u88c5\u597dpasslib\u540e\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u751f\u6210\u52a0\u5bc6\u7684\u53e3\u4ee4\uff0c\u547d\u4ee4\u4f1a\u63d0\u793a\u4f60\u8f93\u5165\u53e3\u4ee4\uff0c\u7136\u540e\u8fd4\u56de\u52a0\u5bc6\u540e\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<p>python -c &#8220;from passlib.hash import sha512_crypt; import getpass; print sha512_crypt.encrypt(getpass.getpass())&#8221;<\/p>\n<p>\u4e0b\u9762\u662f\u6211\u4f7f\u7528\u8fd9\u4e2a\u547d\u4ee4\u751f\u6210\u7684\u52a0\u5bc6\u540e\u7684\u53e3\u4ee4\u5b57\u7b26\u4e32\uff1a<\/p>\n<p>$6$rounds=656000$GgYWhqVPEO30bj9k$pANNLPscsN5rOxlG8gTvfiv.kGAb3EgUgkTPeGMWBTM3u.P5MhKQTTZtuSVIbtCb2Y2b2RE9kq\/eaUPapLC.G1<\/p>\n<p>\u8fd9\u4e2a\u4e5f\u5c31\u662f\u53d8\u91cfmypassword\u7684\u503c\u3002<\/p>\n<p><strong>tasks\uff1a<br \/>\n<\/strong><\/p>\n<p>\u8fd9\u540e\u9762\u5c31\u662f\u5177\u4f53\u7684\u4efb\u52a1\u4e86\uff0c\u6bcf\u4e2a\u4efb\u52a1\u90fd\u662fname\uff0c\u6a21\u5757\u540d+\u6a21\u5757\u53c2\u6570\u7ec4\u6210\u3002\u8bed\u6cd5\u8981\u6c42\u5f88\u4e25\u683c\uff0c\u4e0d\u80fd\u6709\u6ca1\u5fc5\u8981\u7684\u7a7a\u683c\uff0c\u7f29\u8fdb\u4e5f\u5f88\u5173\u952e\u3002<\/p>\n<p>\u5177\u4f53\u7684\u8bed\u6cd5\u6211\u5c31\u4e0d\u89e3\u91ca\u4e86\uff0c\u5728\u5b98\u7f51\u90fd\u80fd\u67e5\u5230\uff0c\u6211\u53ea\u8bf4\u51e0\u4e2a\u5173\u952e\u70b9\uff1a<\/p>\n<ol>\n<li>\n<div style=\"text-align: justify;\"><span style=\"font-size: 10pt;\">lineinfile: dest=\/etc\/sudoers regexp=&#8217;^Defaults(\\s+)requiretty&#8217; line=&#8217;Defaults !requiretty&#8217; backrefs=yes state=present \uff0c \u8fd9\u884c\u91cc\u9762regexp\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\uff0c\uff08\\s+\uff09\u4ee3\u8868\u4efb\u610f\u591a\u4e2a\u7a7a\u683c\u7b26\uff1bbackrefs=yes\u548cstate=present\u662f\u914d\u5408\u4f7f\u7528\u7684\uff0c\u5982\u679c\u627e\u4e0d\u5230\u7b26\u5408\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5b57\u7b26\u4e32\uff0c\u90a3\u4e48\u4e5f\u4e0d\u6dfb\u52a0line\u540e\u9762\u7684\u5185\u5bb9\uff0c\u5426\u5219\u5f53\u8fd9\u4e2aplaybook\u591a\u6b21\u6267\u884c\u65f6\uff0c\u56e0\u4e3a\u9664\u4e86\u7b2c\u4e00\u6b21\u5916\uff0c\u540e\u7eed\u90fd\u627e\u4e0d\u5230\u7b26\u5408\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5b57\u7b26\u4e32\uff0c\u5c31\u4f1a\u6bcf\u6b21\u6267\u884c\uff0c\u90fd\u5728\u6587\u4ef6\u5c3e\u90e8\u589e\u52a0\u4e00\u884cline\u7684\u5185\u5bb9\u3002<br \/>\n<\/span><\/div>\n<\/li>\n<li>\n<div style=\"text-align: justify;\"><span style=\"font-size: 10pt;\">lineinfile: dest=\/etc\/sudoers line=&#8217;oracle ALL=(ALL) ALL&#8217; state=present\uff0c\u5982\u679c\u662f\u589e\u52a0\u884c\uff0c\u4e0d\u9700\u8981\u5199regexp<br \/>\n<\/span><\/div>\n<\/li>\n<li>\n<div style=\"text-align: justify;\"><span style=\"font-size: 10pt;\">lineinfile: dest=\/etc\/hosts line='{{ansible_default_ipv4.address}}\\t{{ansible_hostname}}.hthorizon.com\\t{{ansible_hostname}}&#8217;\uff0cansible_defualt_ipv4.address, ansible_hostname\u662f\u53d8\u91cf\uff0c\u5b83\u4eec\u7684\u503c\u662f\u524d\u9762gather_facts\u63a7\u5236\u6536\u96c6\u7684\u914d\u7f6e\u4fe1\u606f\uff0c\u5728\u8fd9\u91cc\u76f4\u63a5\u5f15\u7528\u53d8\u91cf\uff0c\u5982\u679c\u60f3\u5f97\u5230\u6240\u6709\u914d\u7f6e\u4fe1\u606f\u53ca\u53d8\u91cf\u540d\uff0c\u53ef\u4ee5\u6267\u884c\uff1aansible 192.168.0.40 \u2013m setup<br \/>\n\u53e6\u5916\uff0c\u5728\u8fd9\u91cc\u4e4b\u6240\u4ee5\u4e0d\u7528ansible_fqdn\uff0c\u800c\u76f4\u63a5\u7528ansible_hostname\uff0c\u662f\u56e0\u4e3aansible_fqdn\u662f\u7531\/etc\/hosts\u6587\u4ef6\u5185\u5bb9\u51b3\u5b9a\u7684\uff0c\u6211\u4eec\u6ca1\u914d\u7f6e\/etc\/hosts\u6587\u4ef6\u4e4b\u524d\uff0cansible_fqdn\u7684\u4fe1\u606f\u662f\u4e0d\u6b63\u786e\u7684\u3002<br \/>\n<\/span><\/div>\n<\/li>\n<li>\n<div style=\"text-align: justify;\"><span style=\"font-size: 10pt;\">lineinfile: dest=\/etc\/hosts line=&#8217;192.168.0.39\\tem13c.hthorizon.com\\tem13c&#8217; state=present, \\t\u4ee3\u8868tab\u7b26\u3002<br \/>\n<\/span><\/div>\n<\/li>\n<\/ol>\n<h3>\u6267\u884cplaybook<\/h3>\n<p>\u4e0b\u9762\u662f\u6267\u884c\u8fd9\u4e2aplaybook\u7684\u8f93\u51fa\uff1a<\/p>\n<pre class=\"wrap:true lang:sh decode:true \" >[root@em13c ansible]# ansible-playbook prepare_emagent.yml\r\n\r\nPLAY [prepare em agent] ********************************************************\r\n\r\nTASK [setup] *******************************************************************\r\nok: [192.168.0.40]\r\nok: [192.168.0.41]\r\n\r\nTASK [modify requiretty in sudoers] ********************************************\r\nok: [192.168.0.40]\r\nok: [192.168.0.41]\r\n\r\nTASK [modify visiblepw in sudoers] *********************************************\r\nok: [192.168.0.41]\r\nok: [192.168.0.40]\r\n\r\nTASK [add oracle to sudoers] ***************************************************\r\nok: [192.168.0.40]\r\nok: [192.168.0.41]\r\n\r\nTASK [disable firewalld] *******************************************************\r\nchanged: [192.168.0.41]\r\nchanged: [192.168.0.40]\r\n\r\nTASK [stop firewalld] **********************************************************\r\nchanged: [192.168.0.41]\r\nchanged: [192.168.0.40]\r\n\r\nTASK [create dba group] ********************************************************\r\nok: [192.168.0.40]\r\nok: [192.168.0.41]\r\n\r\nTASK [create oracle user] ******************************************************\r\nok: [192.168.0.40]\r\nok: [192.168.0.41]\r\n\r\nTASK [add self name in \/etc\/hosts] *********************************************\r\nok: [192.168.0.41]\r\nok: [192.168.0.40]\r\n\r\nTASK [add OMS name in \/etc\/hosts] **********************************************\r\nok: [192.168.0.40]\r\nok: [192.168.0.41]\r\n\r\nPLAY RECAP *********************************************************************\r\n192.168.0.40 : ok=10 changed=2 unreachable=0 failed=0\r\n192.168.0.41 : ok=10 changed=2 unreachable=0 failed=0<\/pre>\n<p>\u56e0\u4e3a\u591a\u6b21\u6267\u884c\uff0c\u72b6\u6001changed\u4ee3\u8868\u914d\u7f6e\/\u4fee\u6539\u5b8c\u6210\uff0c\u72b6\u6001 ok\u4ee3\u8868\u4fee\u6539\u5df2\u7ecf\u505a\u8fc7\u4e86\uff0c\u6240\u4ee5\u5c31\u4e0d\u91cd\u590d\u505a\u4e86\uff0c<\/p>\n<h3>&#8220;\u63a8\u9001&#8221; EM13c agent<\/h3>\n<p>\u4e0d\u8be6\u7ec6\u89e3\u91ca\u4e86\uff0c\u76f4\u63a5\u4e0a\u56fe\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/011517_1422_Ansible22.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/011517_1422_Ansible23.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/011517_1422_Ansible24.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/011517_1422_Ansible25.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/011517_1422_Ansible26.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/011517_1422_Ansible27.png\" alt=\"\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u6211\u89c9\u5f97\u5b66\u4e60\u4e00\u4e2a\u5de5\u5177\uff0c\u80fd\u591f\u8fb9\u5b66\u8fb9\u7528\u662f\u6700\u5e78\u8fd0\u7684\uff0c\u56e0\u4e3a\u8fd9\u6837\u5370\u8c61\u6df1\u523b\uff0c\u5982\u679c\u7528\u4e0d\u4e0a\uff0c\u53ea\u662f\u5b66\u4e60\u7f51\u4e0a\u7684\u4f8b\u5b50\uff0c\u4f30\u8ba1\u8fc7\u51e0\u5929\u4e5f\u5c31\u5fd8\u4e86\u3002 Oracle Enterprise M&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"http:\/\/www.rao-bing.cn\/index.php\/2017\/01\/15\/257\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":260,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[6,19],"tags":[20,12],"class_list":["post-257","post","type-post","status-publish","format-aside","has-post-thumbnail","hentry","category-oracle","category-tools","tag-ansible","tag-oracle-enterprise-manager","post_format-post-format-aside"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"http:\/\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/ansible_logo.jpg","jetpack_shortlink":"https:\/\/wp.me\/p8gSFq-49","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":848,"url":"http:\/\/www.rao-bing.cn\/index.php\/2018\/01\/11\/848\/","url_meta":{"origin":257,"position":0},"title":"\u4f7f\u7528Oracle EM13c\u7ba1\u7406\u6570\u636e\u5e93\u79c1\u6709\u4e91","author":"raobing","date":"2018-01-11","format":"aside","excerpt":"\u5b9e\u73b0Oracle\u6570\u636e\u5e93\u79c1\u6709\u4e91\u7684\u65b9\u5f0f\u6709\u4e24\u7c7b\uff1aIaaS\u548cPaaS\uff0c\u56e0\u4e3aIaaS\u4f1a\u4f7f\u7528\u57fa\u7840\u67b6\u6784\u865a\u62df\u5316\u6280\u672f\uff0c\u2026","rel":"","context":"\u5728\u201cOracle\u201d\u4e2d","block_context":{"text":"Oracle","link":"http:\/\/www.rao-bing.cn\/index.php\/category\/oracle\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2018\/01\/clip_image044_thumb.jpg?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2018\/01\/clip_image044_thumb.jpg?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2018\/01\/clip_image044_thumb.jpg?resize=525%2C300 1.5x"},"classes":[]},{"id":225,"url":"http:\/\/www.rao-bing.cn\/index.php\/2017\/01\/09\/225\/","url_meta":{"origin":257,"position":1},"title":"Ansible\u5b66\u4e60\u7b14\u8bb01","author":"raobing","date":"2017-01-09","format":"aside","excerpt":"\u56e0\u4e3aansible\u4e0d\u7528\u5728\u88ab\u7ba1\u7406\u673a\u5668\u7aef\u5b89\u88c5\u4efb\u4f55agent\u6216\u63d2\u4ef6\uff0c\u6240\u4ee5\u66f4\u5bb9\u6613\u88ab\u5ba2\u6237\u63a5\u53d7\uff0c\u6240\u4ee5\u82b1\u4e9b\u65f6\u95f4\u7814\u7a76\u2026","rel":"","context":"\u5728\u201cTools\u201d\u4e2d","block_context":{"text":"Tools","link":"http:\/\/www.rao-bing.cn\/index.php\/category\/tools\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/010917_1044_Ansible11.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":348,"url":"http:\/\/www.rao-bing.cn\/index.php\/2017\/01\/19\/348\/","url_meta":{"origin":257,"position":2},"title":"\u4f7f\u7528Zabbix\u76d1\u63a7Oracle\u6570\u636e\u5e93","author":"raobing","date":"2017-01-19","format":"aside","excerpt":"\u4f7f\u7528Zabbix\u76d1\u63a7Oracle\u6570\u636e\u5e93 Orabbix\u4ecb\u7ecd \u76d1\u63a7Oracle\u6570\u636e\u5e93\u6211\u4eec\u9700\u8981\u5b89\u88c5\u7b2c\u4e09\u65b9\u2026","rel":"","context":"\u5728\u201cOracle\u201d\u4e2d","block_context":{"text":"Oracle","link":"http:\/\/www.rao-bing.cn\/index.php\/category\/oracle\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/clip_image001.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/clip_image001.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/clip_image001.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/clip_image001.png?resize=700%2C400 2x"},"classes":[]},{"id":480,"url":"http:\/\/www.rao-bing.cn\/index.php\/2017\/01\/22\/480\/","url_meta":{"origin":257,"position":3},"title":"\u901a\u8fc7RDS\u5907\u4efd\uff1aOracle Secure Backup\u7b80\u4ecb","author":"raobing","date":"2017-01-22","format":"aside","excerpt":"\u00a0 \u80cc\u666f \u6700\u65e9\u542c\u8bf4\u8fd9\u4e2a\u540d\u5b57\u662f\u5728\u51e0\u5e74\u524d\u5b9e\u65bd\u7b2c\u4e00\u53f0EXADATA\u7684\u65f6\u5019\uff0c\u5f53\u65f6\u53ea\u662f\u5728\u6295\u6807\u6587\u4ef6\u91cc\u8ba4\u2026","rel":"","context":"\u5728\u201cOracle\u201d\u4e2d","block_context":{"text":"Oracle","link":"http:\/\/www.rao-bing.cn\/index.php\/category\/oracle\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/Oracle-Security-Backup.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":397,"url":"http:\/\/www.rao-bing.cn\/index.php\/2017\/01\/20\/397\/","url_meta":{"origin":257,"position":4},"title":"\u5728vSphere\u73af\u5883\u4e0b\u5b89\u88c5RUEI\u6d4b\u8bd5\u73af\u5883","author":"raobing","date":"2017-01-20","format":"aside","excerpt":"(\u6574\u7406\u4ee5\u524d\u5199\u8fc7\u7684\u8001\u6587\u7ae0\uff0c\u73b0\u5728\u4e5f\u8fd8\u6709\u4ef7\u503c\uff09 RUEI\u7684\u5b66\u4e60\u6d4b\u8bd5\u73af\u5883\u9700\u8981\u6709\u652f\u6301\u7aef\u53e3\u955c\u50cf\u7684\u4ea4\u6362\u673a\uff0c\u4ee5\u5f80\u6211\u4eec\u2026","rel":"","context":"\u5728\u201cOracle\u201d\u4e2d","block_context":{"text":"Oracle","link":"http:\/\/www.rao-bing.cn\/index.php\/category\/oracle\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/clip_image006_thumb.jpg?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/clip_image006_thumb.jpg?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/clip_image006_thumb.jpg?resize=525%2C300 1.5x"},"classes":[]},{"id":174,"url":"http:\/\/www.rao-bing.cn\/index.php\/2017\/01\/07\/174\/","url_meta":{"origin":257,"position":5},"title":"\u4f7f\u7528Oracle\u5b98\u65b9\u5de1\u68c0\u5de5\u5177ORAchk\u5de1\u68c0\u6570\u636e\u5e93","author":"raobing","date":"2017-01-07","format":false,"excerpt":"ORAchk\u6982\u8ff0 ORAchk\u662fOracle\u5b98\u65b9\u51fa\u54c1\u7684Oracle\u4ea7\u54c1\u5065\u5eb7\u68c0\u67e5\u5de5\u5177\uff0c\u53ef\u4ee5\u4eceMOS\uff08M\u2026","rel":"","context":"\u5728\u201cOracle\u201d\u4e2d","block_context":{"text":"Oracle","link":"http:\/\/www.rao-bing.cn\/index.php\/category\/oracle\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/010717_1313_OracleO14.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/010717_1313_OracleO14.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/010717_1313_OracleO14.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/010717_1313_OracleO14.png?resize=700%2C400 2x, https:\/\/i0.wp.com\/www.rao-bing.cn\/wp-content\/uploads\/2017\/01\/010717_1313_OracleO14.png?resize=1050%2C600 3x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/posts\/257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/comments?post=257"}],"version-history":[{"count":14,"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/posts\/257\/revisions"}],"predecessor-version":[{"id":275,"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/posts\/257\/revisions\/275"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/media\/260"}],"wp:attachment":[{"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/media?parent=257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/categories?post=257"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/tags?post=257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}