{"id":651,"date":"2020-03-17T09:26:53","date_gmt":"2020-03-17T01:26:53","guid":{"rendered":"https:\/\/www.linuxdevops.cn\/?p=651"},"modified":"2020-03-17T09:26:54","modified_gmt":"2020-03-17T01:26:54","slug":"ansible-mass-deploy-zabbix-agent","status":"publish","type":"post","link":"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/","title":{"rendered":"Ansible \u6279\u91cf\u90e8\u7f72 Zabbix-agent"},"content":{"rendered":"\n

1.\u5b89\u88c5ansible<\/h2>\n\n\n\n
\nsudo apt update\nsudo apt-get install software-properties-common\nsudo apt-add-repository --yes  ppa:ansible\/ansible:2.7.6\nsudo apt update\nsudo apt-get install ansible\n\n<\/pre>\n\n\n\n

2.\u6dfb\u52a0ansible \u4e3b\u673a<\/h2>\n\n\n\n
\u4e24\u79cd\u4e0d\u540c\u7684\u7cfb\u7edf\u5b89\u88c5\u65b9\u6cd5\u7565\u5fae\u4e0d\u540c\uff0c\u5206\u4e3a\u4e24\u7ec4\u91c7\u7528\u4e0d\u540cplaybook\nvim \/etc\/ansible\/hosts\n [ubuntu_groups] \n 192.168.0.30 ansible_ssh_private_key_file=\/root\/test.pem\n 192.168.0.10 ansible_ssh_private_key_file=\/root\/test.pem\n [centos7_groups]\n 192.168.0.29 ansible_ssh_private_key_file=\/root\/test.pem\n 192.168.0.28 ansible_ssh_private_key_file=\/root\/test.pem\n 192.168.0.27 ansible_ssh_private_key_file=\/root\/test.pem<\/pre>\n\n\n\n

3.\u7f16\u5199playbook<\/h2>\n\n\n\n
vim  \/etc\/ansible\/ubuntu.yml (ubuntu \u64cd\u4f5c\u7cfb\u7edf)\n---\n name: ubuntu playbook\n hosts:  ubuntu_groups \n remote_user: root\n gather_facts: False\n ignore_errors: True\n tasks:\n name: install zabbix-agent\n shell: apt-get install -y zabbix-agent\n name: Server\n lineinfile:\n   backrefs: yes\n   path: \/etc\/zabbix\/zabbix_agentd.conf\n   regexp: '^Server=127.0.0.1'\n   line: 'Server=192.168.0.30'\n name: ServerActive\n lineinfile:\n   backrefs: yes\n   path: \/etc\/zabbix\/zabbix_agentd.conf\n   regexp: '^ServerActive=127.0.0.1'\n   line: 'ServerActive=192.168.0.30'\n name: restart\n service:\n   name=zabbix-agent\n   enabled=yes\n   state=restarted <\/pre>\n\n\n\n
vim \/etc\/ansible\/centos7.yml   (centos7\u64cd\u4f5c\u7cfb\u7edf)\n---\n name: centos7 playbook\n #  hosts: centos7_groups\n hosts: fugong\n remote_user: root\n gather_facts: False\n ignore_errors: True\n tasks:\n name: install rpm\n yum:\n   name=https:\/\/repo.zabbix.com\/zabbix\/3.2\/rhel\/7\/x86_64\/zabbix-release-3.2-1.el7.noarch.rpm\n   state=present\n name: yum makecache\n yum:\n   name=*\n   update_cache=yes\n name: install agent\n yum:\n   name=zabbix-agent\n   state=latest\n name: install agent-get\n yum:\n   name=zabbix-get\n   state=latest\n name: install agent-sender\n yum:\n    name=zabbix-sender\n    state=latest\n name: Server\n lineinfile:\n   backrefs: yes\n   path: \/etc\/zabbix\/zabbix_agentd.conf\n   regexp: '^Server=127.0.0.1'\n   line: 'Server=192.168.0.30'\n name: ServerActive\n lineinfile:\n   backrefs: yes\n   path: \/etc\/zabbix\/zabbix_agentd.conf\n   regexp: '^ServerActive=127.0.0.1'\n   line: 'ServerActive=192.168.0.30'\n name: restart\n service:\n   name=zabbix-agent\n   enabled=yes\n   state=restarted <\/pre>\n\n\n\n

4.\u68c0\u67e5\u8bed\u6cd5<\/h2>\n\n\n\n
 --syntax-check   #\u68c0\u67e5Playbook\u4e2d\u7684\u8bed\u6cd5\u4e66\u5199,\u5e76\u4e0d\u5b9e\u9645\u6267\u884c\n --check   #\u6a21\u62df\u6267\u884c\uff0c\u4e0d\u4f1a\u771f\u6b63\u5728\u673a\u5668\u4e0a\u6267\u884c(\u67e5\u770b\u6267\u884c\u4f1a\u4ea7\u751f\u4ec0\u4e48\u53d8\u5316)<\/code><\/pre>\n\n\n\n
ansible-playbook --syntax-check  centos7.yml\nansible-playbook --syntax-check   ubuntu.yml  \nansible-playbook --check  centos7.yml\nansible-playbook --check   ubuntu.yml   <\/pre>\n\n\n\n

5.\u6267\u884c\u5b89\u88c5<\/h2>\n\n\n\n
ansible-playbook  centos7.yml \nansible-playbook  ubuntu.yml  \n<\/pre>\n\n\n\n

6. \u5b8c\u6210<\/h2>\n\n\n\n

\u5982\u679c\u4e00\u5207\u987a\u5229\u7684\u8bddzabbix-agent \u5df2\u7ecf\u5b89\u88c5\u5b8c\u6210\uff0c\u767b\u5f55\u5b89\u88c5\u4e3b\u673a\u68c0\u67e5\u67e5\u770b\u4e0b\u8fdb\u7a0b\u5373\u53ef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

1.\u5b89\u88c5ansible sudo apt update sudo apt-get install softwa<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,18,33],"tags":[],"yoast_head":"\nAnsible \u6279\u91cf\u90e8\u7f72 Zabbix-agent - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4<\/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.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ansible \u6279\u91cf\u90e8\u7f72 Zabbix-agent - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\" \/>\n<meta property=\"og:description\" content=\"1.\u5b89\u88c5ansible sudo apt update sudo apt-get install softwa\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-17T01:26:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-03-17T01:26:54+00:00\" \/>\n<meta name=\"author\" content=\"\u7ba1\u7406\u5458\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/\"},\"author\":{\"name\":\"\u7ba1\u7406\u5458\",\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1\"},\"headline\":\"Ansible \u6279\u91cf\u90e8\u7f72 Zabbix-agent\",\"datePublished\":\"2020-03-17T01:26:53+00:00\",\"dateModified\":\"2020-03-17T01:26:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/\"},\"wordCount\":6,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1\"},\"articleSection\":[\"Linux\",\"Linux\u670d\u52a1\",\"zabbix\"],\"inLanguage\":\"zh-CN\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/\",\"url\":\"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/\",\"name\":\"Ansible \u6279\u91cf\u90e8\u7f72 Zabbix-agent - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\",\"isPartOf\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/#website\"},\"datePublished\":\"2020-03-17T01:26:53+00:00\",\"dateModified\":\"2020-03-17T01:26:54+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/#breadcrumb\"},\"inLanguage\":\"zh-CN\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.linuxdevops.cn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\",\"item\":\"https:\/\/www.linuxdevops.cn\/linux\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Ansible \u6279\u91cf\u90e8\u7f72 Zabbix-agent\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.linuxdevops.cn\/#website\",\"url\":\"https:\/\/www.linuxdevops.cn\/\",\"name\":\"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\",\"description\":\"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\u7b14\u8bb0\",\"publisher\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1\"},\"alternateName\":\"linuxdevops\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.linuxdevops.cn\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-CN\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1\",\"name\":\"\u7ba1\u7406\u5458\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-CN\",\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.linuxdevops.cn\/wp-content\/uploads\/2019\/07\/cropped-index.jpg\",\"contentUrl\":\"https:\/\/www.linuxdevops.cn\/wp-content\/uploads\/2019\/07\/cropped-index.jpg\",\"width\":512,\"height\":512,\"caption\":\"\u7ba1\u7406\u5458\"},\"logo\":{\"@id\":\"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/image\/\"},\"description\":\"\u7ba1\u7406\u5458\",\"url\":\"https:\/\/www.linuxdevops.cn\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Ansible \u6279\u91cf\u90e8\u7f72 Zabbix-agent - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4","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.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/","og_locale":"zh_CN","og_type":"article","og_title":"Ansible \u6279\u91cf\u90e8\u7f72 Zabbix-agent - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4","og_description":"1.\u5b89\u88c5ansible sudo apt update sudo apt-get install softwa","og_url":"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/","og_site_name":"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4","article_published_time":"2020-03-17T01:26:53+00:00","article_modified_time":"2020-03-17T01:26:54+00:00","author":"\u7ba1\u7406\u5458","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/#article","isPartOf":{"@id":"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/"},"author":{"name":"\u7ba1\u7406\u5458","@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1"},"headline":"Ansible \u6279\u91cf\u90e8\u7f72 Zabbix-agent","datePublished":"2020-03-17T01:26:53+00:00","dateModified":"2020-03-17T01:26:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/"},"wordCount":6,"commentCount":0,"publisher":{"@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1"},"articleSection":["Linux","Linux\u670d\u52a1","zabbix"],"inLanguage":"zh-CN","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/","url":"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/","name":"Ansible \u6279\u91cf\u90e8\u7f72 Zabbix-agent - Linux\u81ea\u52a8\u5316\u8fd0\u7ef4","isPartOf":{"@id":"https:\/\/www.linuxdevops.cn\/#website"},"datePublished":"2020-03-17T01:26:53+00:00","dateModified":"2020-03-17T01:26:54+00:00","breadcrumb":{"@id":"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/#breadcrumb"},"inLanguage":"zh-CN","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.linuxdevops.cn\/2020\/03\/ansible-mass-deploy-zabbix-agent\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.linuxdevops.cn\/"},{"@type":"ListItem","position":2,"name":"Linux","item":"https:\/\/www.linuxdevops.cn\/linux\/"},{"@type":"ListItem","position":3,"name":"Ansible \u6279\u91cf\u90e8\u7f72 Zabbix-agent"}]},{"@type":"WebSite","@id":"https:\/\/www.linuxdevops.cn\/#website","url":"https:\/\/www.linuxdevops.cn\/","name":"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4","description":"Linux\u81ea\u52a8\u5316\u8fd0\u7ef4\u7b14\u8bb0","publisher":{"@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1"},"alternateName":"linuxdevops","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.linuxdevops.cn\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-CN"},{"@type":["Person","Organization"],"@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/3e206335d5796fdd8679e449df72a0d1","name":"\u7ba1\u7406\u5458","image":{"@type":"ImageObject","inLanguage":"zh-CN","@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/image\/","url":"https:\/\/www.linuxdevops.cn\/wp-content\/uploads\/2019\/07\/cropped-index.jpg","contentUrl":"https:\/\/www.linuxdevops.cn\/wp-content\/uploads\/2019\/07\/cropped-index.jpg","width":512,"height":512,"caption":"\u7ba1\u7406\u5458"},"logo":{"@id":"https:\/\/www.linuxdevops.cn\/#\/schema\/person\/image\/"},"description":"\u7ba1\u7406\u5458","url":"https:\/\/www.linuxdevops.cn\/author\/root\/"}]}},"_links":{"self":[{"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/posts\/651"}],"collection":[{"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/comments?post=651"}],"version-history":[{"count":1,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/posts\/651\/revisions"}],"predecessor-version":[{"id":652,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/posts\/651\/revisions\/652"}],"wp:attachment":[{"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/media?parent=651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/categories?post=651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxdevops.cn\/wp-json\/wp\/v2\/tags?post=651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}