{"id":1244,"date":"2023-05-16T09:29:40","date_gmt":"2023-05-16T00:29:40","guid":{"rendered":"https:\/\/symphonict.nesic.co.jp\/tech-blog\/?p=1244"},"modified":"2023-05-24T16:13:26","modified_gmt":"2023-05-24T07:13:26","slug":"%e3%82%b3%e3%83%b3%e3%83%86%e3%83%8a%e5%9f%ba%e7%9b%a4%e4%b8%8a%e3%81%a7zabbix%e3%82%92%e8%87%aa%e5%8b%95%e8%a8%ad%e5%ae%9a%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%80%ef%bc%88%e9%80%a3%e8%bc%89","status":"publish","type":"post","link":"https:\/\/symphonict.nesic.co.jp\/tech-blog\/1244\/","title":{"rendered":"\u30b3\u30f3\u30c6\u30ca\u57fa\u76e4\u4e0a\u3067Zabbix\u3092\u81ea\u52d5\u8a2d\u5b9a\u3057\u3066\u307f\u305f\uff08\u9023\u8f09\u2461\uff1aAnsible\u306ePlaybook\u3067Zabbix\u3078\u306e\u767b\u9332\u3092\u81ea\u52d5\u3067\u884c\u3048\u308b\u3088\u3046\u306b\u3059\u308b)"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u306f\u3058\u3081\u306b<\/h2>\n\n\n\n<p>\u3053\u3093\u306b\u3061\u306f\uff01<br><span style=\"border-bottom: solid 3px #4169e1\">\u4e8b\u696d\u958b\u767a\u63a8\u9032\u90e8\u30a4\u30f3\u30d5\u30e9\u904b\u7528SL\u30c1\u30fc\u30e0\u306e\u5009\u7530<\/span>\u3067\u3059\u3002<br>\u9023\u8f09\u7b2c2\u56de\u76ee\u3067\u306fZabbix\u3078\u76e3\u8996\u5bfe\u8c61\u30b5\u30fc\u30d0\u3092\u81ea\u52d5\u767b\u9332\u3067\u304d\u308b\u3088\u3046\u306a\u4ed5\u7d44\u307f\u3092Ansible\u306ePlaybook\u3092\u7528\u3044\u3066\u69cb\u7bc9\u3059\u308b\u6d41\u308c\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p><strong>\u76ee\u6b21<\/strong><br><strong><a href=\"#1\" title=\"\u2460\u30b3\u30f3\u30c6\u30ca\u306bAnsible\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\">\u2460\u30b3\u30f3\u30c6\u30ca\u306bAnsible\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/a><br><a href=\"#2\" title=\"\u2461Playbook\u5168\u4f53\u69cb\u6210\u306e\u8aac\u660e\">\u2461Playbook\u5168\u4f53\u69cb\u6210\u306e\u8aac\u660e<\/a><br><a href=\"#3\" title=\"\u2462Zabbix-agent\u3092\u76e3\u8996\u5bfe\u8c61\u30b5\u30fc\u30d0\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308bPlaybook\u306e\u4f5c\u6210\">\u2462Zabbix-agent\u3092\u76e3\u8996\u5bfe\u8c61\u30b5\u30fc\u30d0\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308bPlaybook\u306e\u4f5c\u6210<\/a><br><a href=\"#4\" title=\"\u2463\u76e3\u8996\u5bfe\u8c61\u30b5\u30fc\u30d0\u3092Zabbix\u306b\u81ea\u52d5\u767b\u9332\u3059\u308bPlaybook\u306e\u4f5c\u6210\">\u2463\u76e3\u8996\u5bfe\u8c61\u30b5\u30fc\u30d0\u3092Zabbix\u306b\u81ea\u52d5\u767b\u9332\u3059\u308bPlaybook\u306e\u4f5c\u6210<\/a><br><a href=\"#5\" title=\"\u2464Role\u7528\u306ePlaybook\u306e\u4f5c\u6210\u3001\u5b9f\u884c\">\u2464Role\u7528\u306ePlaybook\u306e\u4f5c\u6210\u3001\u5b9f\u884c<\/a><\/strong><\/p>\n\n\n\n<p><strong>\u7528\u8a9e\u8aac\u660e<\/strong><br>\u30fbAnsible:IT \u81ea\u52d5\u5316\u30c4\u30fc\u30eb\u3067\u3059\u3002 \u3053\u306e\u30c4\u30fc\u30eb\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u6210\u3001\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u306e\u5c55\u958b\u3001\u3088\u308a\u9ad8\u5ea6\u306aIT\u30bf\u30b9\u30af (\u7d99\u7d9a\u7684\u306a\u30c7\u30d7\u30ed\u30a4\u30e1\u30f3\u30c8\u3084\u30c0\u30a6\u30f3\u30bf\u30a4\u30e0\u306a\u3057\u306e\u30ed\u30fc\u30ea\u30f3\u30b0\u66f4\u65b0\u306a\u3069) \u306e\u30aa\u30fc\u30b1\u30b9\u30c8\u30ec\u30fc\u30b7\u30e7\u30f3\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<br>\u30fbPlaybook:Ansible \u306e\u8a2d\u5b9a\u3001\u30c7\u30d7\u30ed\u30a4\u30e1\u30f3\u30c8\u3001\u30aa\u30fc\u30b1\u30b9\u30c8\u30ec\u30fc\u30b7\u30e7\u30f3\u8a00\u8a9e\u3067\u3059\u3002\u30ea\u30e2\u30fc\u30c8\u306e\u30b7\u30b9\u30c6\u30e0\u304c\u5b9f\u65bd\u3059\u308b\u30dd\u30ea\u30b7\u30fc\u3001\u307e\u305f\u306f\u4e00\u822c\u7684\u306a IT \u30d7\u30ed\u30bb\u30b9\u306e\u4e00\u9023\u306e\u624b\u9806\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<br>\u30fbRole:\u65e2\u77e5\u306e\u30d5\u30a1\u30a4\u30eb\u69cb\u9020\u306b\u57fa\u3065\u3044\u3066\u7279\u5b9a\u306e vars_files\u3001\u30bf\u30b9\u30af\u3001\u304a\u3088\u3073\u30cf\u30f3\u30c9\u30e9\u30fc\u3092\u81ea\u52d5\u7684\u306b\u8aad\u307f\u8fbc\u3080\u65b9\u6cd5\u3067\u3059\u3002 \u30ed\u30fc\u30eb\u3067\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u30b0\u30eb\u30fc\u30d7\u5316\u3059\u308b\u3068\u3001\u4ed6\u306e\u30e6\u30fc\u30b6\u30fc\u3068\u306e\u30ed\u30fc\u30eb\u306e\u5171\u6709\u304c\u5bb9\u6613\u306b\u306a\u308a\u307e\u3059\u3002<br><a href=\"#s1\" title=\"\u203b\u53c2\u8003\u8a18\u4e8b\u2460\">\u203b\u53c2\u8003\u8a18\u4e8b\u2460<\/a><\/p>\n\n\n\n<p><strong>\u30b3\u30f3\u30c6\u30ca\u5b9f\u884c\u74b0\u5883<\/strong><br>\u30fbAWS EC2<\/p>\n\n\n\n<p><strong>\u524d\u63d0\u6761\u4ef6<\/strong><br>\u30fb\u76e3\u8996\u5bfe\u8c61\u30b5\u30fc\u30d0\u306e\u8a2d\u5b9a\u304cSSH\u63a5\u7d9a\u306e\u969b\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u8a8d\u8a3c\u3067\u63a5\u7d9a\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3053\u3068<br>\u30fbDocker\u304c\u4f7f\u3048\u308b\u74b0\u5883\u3067\u3042\u308b\u3053\u3068<\/p>\n\n\n\n<p><strong>\u30a4\u30e1\u30fc\u30b8\u56f3<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"465\" height=\"369\" src=\"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image.png\" alt=\"\" class=\"wp-image-1245\" srcset=\"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image.png 465w, https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-300x238.png 300w\" sizes=\"(max-width: 465px) 100vw, 465px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"1\"><strong>\u2460\u30b3\u30f3\u30c6\u30ca\u306bAnsible\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong><\/h2>\n\n\n\n<p>\u307e\u305a\u306fPlaybook\u304c\u5b9f\u884c\u53ef\u80fd\u306a\u74b0\u5883\u3092\u4f5c\u308b\u305f\u3081\u306bRocky Linux\u306e\u30b3\u30f3\u30c6\u30ca\u306bAnsible\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002Rocky Linux\u3092\u9078\u629e\u3057\u305f\u306e\u306fCentOS\u306e\u5f8c\u7d99\u306e\u4e00\u3064\u3067\u3042\u308a\u3001\u6c4e\u7528\u6027\u304c\u9ad8\u3044\u305f\u3081\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u30fbRocky Linux\u306e\u30b3\u30f3\u30c6\u30ca\u69cb\u7bc9<br>&lt;ssh\u3067\u63a5\u7d9a\u3057\u305fEC2\u4e0a\u3067\u64cd\u4f5c&gt;<br>\u4f8b\uff09Rocky Linux\u306e\u30b3\u30f3\u30c6\u30ca\u306e\u69cb\u7bc9<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run -d -t --name \uff1c\u4efb\u610f\u306e\u30b3\u30f3\u30c6\u30ca\u540d\uff1e rockylinux\/rockylinux:latest<\/code><\/pre>\n\n\n\n<p>docker run\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u5f8c\u3001\u30b3\u30f3\u30c6\u30ca\u304c\u4f5c\u6210\u3055\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3057\u3001 \u4f5c\u6210\u3067\u304d\u3066\u3044\u305f\u3089\u30b3\u30f3\u30c6\u30ca\u5185\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker ps<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>docker exec -it &lt;\u30b3\u30f3\u30c6\u30ca\u540d&gt; \/bin\/bash<\/code><\/pre>\n\n\n\n<p>\u30fbEPEL(Extra Packages for Enterprise Linux)\u306e\u8ffd\u52a0<br>EPEL\u3068\u306fRHEL\u306e\u516c\u5f0f\u30d1\u30c3\u30b1\u30fc\u30b8\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u542b\u307e\u308c\u3066\u3044\u306a\u3044\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u63d0\u4f9b\u3059\u308b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u3059\u3002\u3053\u3061\u3089\u306b\u542b\u307e\u308c\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u7528\u3044\u308b\u305f\u3081\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002\u203b\u53c2\u8003\u8a18\u4e8b\u2461<br>&lt;\u30b3\u30f3\u30c6\u30ca\u4e0a\u3067\u64cd\u4f5c&gt;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yum install epel-release<\/code><\/pre>\n\n\n\n<p>\u30fb\u69cb\u7bc9\u3057\u305fRocky Linux\u306e\u30b3\u30f3\u30c6\u30ca\u5185\u3067Ansible\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<br>yum\u30b3\u30de\u30f3\u30c9\u3092\u7528\u3044\u3066Ansible\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<br>&lt;\u30b3\u30f3\u30c6\u30ca\u4e0a\u3067\u64cd\u4f5c&gt;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yum install ansible<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0a\u3067Ansible\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2\"><strong>\u2461Playbook\u5168\u4f53\u69cb\u6210\u306e\u8aac\u660e<\/strong><\/h2>\n\n\n\n<p>\u4eca\u56de\u306e\u691c\u8a3c\u3067\u306fAnsible\u306erole\u3092\u4f7f\u3044\u307e\u3059\u3002\u203b\u53c2\u8003\u8a18\u4e8b\u2462<br>\u300cZabbix-agent\u3092\u76e3\u8996\u5bfe\u8c61\u306e\u30b5\u30fc\u30d0\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30ebPlaybook\u300d\u3068\u300c\u76e3\u8996\u5bfe\u8c61\u3067\u3042\u308b\u30b5\u30fc\u30d0\u3092Zabbix\u306b\u81ea\u52d5\u767b\u9332\u3059\u308bPlaybook\u300d\u306e2\u3064\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u5206\u3051\u3066role\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<br>Playbook\u306erole\u306e\u69cb\u6210\u56f3\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br>\uff1c\u69cb\u6210\u56f3\uff1e<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"368\" height=\"387\" src=\"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-2.png\" alt=\"\" class=\"wp-image-1247\" srcset=\"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-2.png 368w, https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-2-285x300.png 285w\" sizes=\"(max-width: 368px) 100vw, 368px\" \/><\/figure>\n\n\n\n<p>.ansible.cfg\u30d5\u30a1\u30a4\u30eb\u3068inventory\u30d5\u30a1\u30a4\u30eb\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>.ansible.cfg<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;defaults]\ninventory&nbsp;&nbsp; = \/root\/foransible\/inventory\/inventory #inventory\u306e\u30d1\u30b9\u6307\u5b9a \nroles_path = \/root\/foransible\/docker-ansible\/roles #role\u306e\u30d1\u30b9\u6307\u5b9a \nhost_key_checking = False #known_hosts\u306ekey\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u304b\u3092\u6307\u5b9a<\/code><\/pre>\n\n\n\n<p>.ansible.cfg\u306fAnsible\u306e\u8a2d\u5b9a\u3092\u5236\u5fa1\u3059\u308b\u5f79\u76ee\u304c\u3042\u308a\u307e\u3059\u3002\u203b\u53c2\u8003\u8a18\u4e8b\u2463<br><br>\/inventory<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;all:vars]\nansible_user=root #\u76e3\u8996\u5bfe\u8c61\u306b\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u3068\u304d\u306e\u30e6\u30fc\u30b6\u30fc\u540d \nansible_port=22 #\u76e3\u8996\u5bfe\u8c61\u306b\u63a5\u7d9a\u3059\u308b\u3068\u304d\u306e\u30dd\u30fc\u30c8\u756a\u53f7 &nbsp; \n\n#\u76e3\u8996\u5bfe\u8c61\u30b5\u30fc\u30d0\u306e\u60c5\u5831 \n&#91;Linux_Server] \n&lt;19*.***.***.**3&gt; hostname=&lt;AAA&gt; ansible_ssh_pass=&lt;pass&gt; &nbsp; \n\n#Playbook\u5185\u306e\u5024\u306e\u5909\u6570\u4e00\u89a7(\u76e3\u8996\u9805\u76ee\u3084\u30b0\u30eb\u30fc\u30d7\u306a\u3069zabbix\u5074\u306e\u8a2d\u5b9a)\n&#91;Linux_Server:vars] \nhostgroups=Linux servers \nlinktemplates=Linux by Zabbix agent \nzabbix_agent_package=zabbix-agent-6.0.10-release1.el8.x86_64.rpm \nzabbix_server_ip=&lt;1**.***.**1&gt; \nzabbix_host_name=Zabbix server \nserverurl=http:\/\/zabbix-web:**\/api_jsonrpc.php \nloginuser=&lt;BBB&gt; \nloginpassword=&lt;pass_BBB&gt;<\/code><\/pre>\n\n\n\n<p>inventory\u3067\u306f\u76e3\u8996\u5bfe\u8c61\u30b5\u30fc\u30d0\u306e\u63a5\u7d9a\u306b\u5fc5\u8981\u306a\u5024\u3084Playbook\u5185\u306e\u5909\u6570\u306e\u6307\u5b9a\u3067\u7528\u3044\u308b\u5024\u304c\u8a18\u8f09\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3\"><strong>\u2462Zabbix-agent\u3092\u76e3\u8996\u5bfe\u8c61\u30b5\u30fc\u30d0\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/strong><br>\u3000<strong>Playbook\u306e\u4f5c\u6210<\/strong><\/h2>\n\n\n\n<p><br>\u6b21\u306bZabbix-agent\u3092\u76e3\u8996\u5bfe\u8c61\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308bPlaybook\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<br>Zabbix-agent\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306erole\u69cb\u6210<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"368\" height=\"215\" src=\"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-3.png\" alt=\"\" class=\"wp-image-1249\" srcset=\"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-3.png 368w, https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-3-300x175.png 300w\" sizes=\"(max-width: 368px) 100vw, 368px\" \/><\/figure>\n\n\n\n<p>tasks\u306e\u4e0b\u306bmain.yml\u3067playbook\u3092\u914d\u7f6e\u3057\u307e\u3059\u3002files\u306e\u4e0b\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308bZabbix-agent\u30d5\u30a1\u30a4\u30eb\u3001templates\u306e\u4e0b\u306bZabbix-agent\u306e\u63a5\u7d9a\u8a2d\u5b9a\u6642\u306b\u5fc5\u8981\u306azabbix_agentd.conf\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u914d\u7f6e\u3057\u3066\u3044\u307e\u3059\u3002<br>\/docker-ansible\/roles\/zabbix-agent\/tasks\/main.yml<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>--- \n#files\u306b\u3042\u308bzabbix-agent\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u5bfe\u8c61\u30b5\u30fc\u30d0\u30fc\u306b\u30b3\u30d4\u30fc\n- name: Copy Package   \n  copy:     \n    src: \"{{ item }}\"     \n    dest: \/tmp\/   \n  loop:     \n     - \"{{ zabbix_agent_package }}\"\u3000#inventory\u30d5\u30a1\u30a4\u30eb\u3067\u6307\u5b9a  \n\n#zabbix-agent\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\n- name: Install Package   \n  yum:   \n   name:     \n    - \/tmp\/{{ zabbix_agent_package }}    \n   disable_gpg_check: yes    \n   state: present   \n\n#Zabbix\u306e\u76e3\u8996\u5bfe\u8c61\u8a2d\u5b9a\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8 \n- name: Configuration for Zabbix Agent   \n  template:     \n    src: zabbix-agent.j2     \n    dest: \/etc\/zabbix\/zabbix_agentd.conf     \n    owner: zabbix     \n    group: zabbix   \n\n#Zabbix Agent\u306e\u30d7\u30ed\u30bb\u30b9\u8d77\u52d5 \n- name: Start Zabbix Agent   \n  service:     \n    name: zabbix-agent     \n    state: restarted      \n    enabled: true<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0a\u306e\u3088\u3046\u306a\u69cb\u6210\u3068Playbook\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3067\u76e3\u8996\u5bfe\u8c61\u30b5\u30fc\u30d0\u3078zabbix-agent\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u7528Playbook\u304c\u5b8c\u4e86\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"4\"><strong>\u2463\u76e3\u8996\u5bfe\u8c61\u30b5\u30fc\u30d0\u3092Zabbix\u306b\u81ea\u52d5\u767b\u9332\u3059\u308bPlaybook\u306e\u4f5c\u6210<\/strong><\/h2>\n\n\n\n<p><br>\u6b21\u306bZabbix-agent\u3092\u76e3\u8996\u5bfe\u8c61\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308bPlaybook\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<br>Zabbix\u306b\u81ea\u52d5\u767b\u9332\u306erole\u69cb\u6210<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"372\" height=\"134\" src=\"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-4.png\" alt=\"\" class=\"wp-image-1250\" srcset=\"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-4.png 372w, https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-4-300x108.png 300w\" sizes=\"(max-width: 372px) 100vw, 372px\" \/><\/figure>\n\n\n\n<p>\u3053\u3061\u3089\u306erole\u3067\u306ftasks\u306e\u914d\u4e0b\u306bplaybook\u5b9f\u884c\u7528\u306emain.yml\u304c\u914d\u7f6e\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br>\/docker-ansible\/roles\/zabbix-create-host\/tasks\/main.yml<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>--- \n#Zabbix\u306e\u76e3\u8996\u8a2d\u5b9a\u81ea\u52d5\u767b\u9332 &nbsp; \n  - name: Create host on Zabbix &nbsp;&nbsp;&nbsp; \n    local_action: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n      module: zabbix_host &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n      server_url: \"{{ serverurl }}\"\u3000#Zabbix\u30b5\u30fc\u30d0\u306eURL \u4f8b)http:\/\/****\/api_jsonrpc.php &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n      login_user: \"{{ loginuser }}\"\u3000#Zabbix\u30b5\u30fc\u30d0\u306e\u30e6\u30fc\u30b6 \u4f8b)Admin &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n      login_password: \"{{ loginpassword }}\"\u3000#Zabbix\u30b5\u30fc\u30d0\u306e\u30d1\u30b9\u30ef\u30fc\u30c9 \u4f8b)Password &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n      host_name: \"{{ hostname }}\"\u3000#\u767b\u9332\u3059\u308b\u30db\u30b9\u30c8\u540d \u4f8b)host &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n      host_groups: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n        - \"{{ hostgroups }}\"\u3000 #\u767b\u9332\u3059\u308b\u30db\u30b9\u30c8\u30b0\u30eb\u30fc\u30d7 \u4f8b)linux server &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n      link_templates: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n        - \"{{ linktemplates }}\"\u3000#\u30db\u30b9\u30c8\u306b\u5272\u308a\u5f53\u3066\u308b\u76e3\u8996\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8 \u4f8b)Linux by Zabbix agent &nbsp;&nbsp;&nbsp;\n      status: enabled\u3000#\u76e3\u8996\u306e\u6709\u52b9\u5316\u30fb\u7121\u52b9\u5316\u306e\u9078\u629e &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n      state: present\u3000#\u30db\u30b9\u30c8\u306e\u8a2d\u5b9a\u306e\u6709\u7121 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n      interfaces:\u3000#\u76e3\u8996\u5bfe\u8c61\u30db\u30b9\u30c8\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u8a2d\u5b9a &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n        - type: 1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n          main: 1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n          useip: 1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n          ip: \"{{ ansible_default_ipv4.address }}\"\u3000#\u5bfe\u8c61\u30b5\u30fc\u30d0\u30fc\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306eIP\u30a2\u30c9\u30ec\u30b9 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n          dns: \"\" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \n          port: 10050<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0a\u306e\u3088\u3046\u306a\u69cb\u6210\u3068Playbook\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3067\u76e3\u8996\u5bfe\u8c61\u3067\u3042\u308b\u30b5\u30fc\u30d0\u3092Zabbix\u306b\u81ea\u52d5\u767b\u9332\u7528Playbook\u304c\u5b8c\u4e86\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"5\"><strong>\u2464Role\u7528\u306ePlaybook\u306e\u4f5c\u6210\u3001\u5b9f\u884c<\/strong><\/h2>\n\n\n\n<p><br>\u2460\u306e\u69cb\u6210\u56f3\u3092\u53c2\u8003\u306bplaybook\u3092\u4f5c\u6210\u3057\u3001role\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\u5b9f\u969b\u306b\u5b9f\u884c\u3059\u308b\u306e\u306fansible-docker.yml\u3067\u3059\u3002<br>\/docker-ansible\/ansible-docker.yml<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>---\n- hosts: test_server\n  gather_facts: true\n  roles:\n    - zabbix-agent\n    - zabbix-create-host<\/code><\/pre>\n\n\n\n<p>\u4e0a\u8a18\u306e\u3088\u3046\u306bplaybook\u5185\u3092\u4f5c\u6210\u3057\u3001ansible-playbook\u306e\u30b3\u30de\u30f3\u30c9\u3067\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ansible-playbook ansible-docker.yml<\/code><\/pre>\n\n\n\n<p>Zabbix\u306eGUI\u753b\u9762\u4e0a\u306b\u3066\u300c\u8a2d\u5b9a\u300d\u2192\u300c\u30db\u30b9\u30c8\u300d\u306e\u753b\u9762\u3092\u958b\u304d\u3001\u540d\u524d\u306e\u6b04\u306b\u30a4\u30f3\u30d9\u30f3\u30c8\u30ea\u30d5\u30a1\u30a4\u30eb\u5185\u306bhostname\u3068\u3057\u3066\u8a18\u8f09\u3057\u305f\u540d\u524d\u304c\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u3053\u3068\uff08\u753b\u50cf\u4e00\u679a\u76ee\uff09\u3001\u540c\u753b\u9762\u306e\u53f3\u5074\u306e\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u306e\u72b6\u614b\u306e\u6b04\u304c\u7dd1\u8272\u306b\u306a\u3063\u3066\u3044\u308b\u3053\u3068\uff08\u753b\u50cf\u4e8c\u679a\u76ee\uff09\u304c\u78ba\u8a8d\u51fa\u6765\u305f\u3089\u767b\u9332\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-10.png\" alt=\"\" class=\"wp-image-1261\" width=\"644\" height=\"474\" srcset=\"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-10.png 844w, https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-10-300x221.png 300w, https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-10-768x565.png 768w\" sizes=\"(max-width: 644px) 100vw, 644px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"338\" height=\"90\" src=\"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-9.png\" alt=\"\" class=\"wp-image-1258\" srcset=\"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-9.png 338w, https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-content\/uploads\/2023\/05\/image-9-300x80.png 300w\" sizes=\"(max-width: 338px) 100vw, 338px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u4e0a\u8a18\u306e\u624b\u9806\u3088\u308a\u3001\u30b3\u30f3\u30c6\u30ca\u5185\u3067playbook\u3092\u5b9f\u884c\u3059\u308b\u3068zabbix\u306b\u76e3\u8996\u5bfe\u8c61\u30b5\u30fc\u30d0\u306e\u767b\u9332\u304c\u81ea\u52d5\u3067\u884c\u308f\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6b21\u56de\u306f<strong>\u300cDockerfile\u3092\u7528\u3044\u3066\u30b3\u30f3\u30c6\u30ca\u306e\u30a4\u30e1\u30fc\u30b8\u306e\u4f5c\u6210\u300d<\/strong>\u306b\u3064\u3044\u3066\u6295\u7a3f\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u53c2\u8003\u8a18\u4e8b<\/h2>\n\n\n\n<p id=\"s1\">\u53c2\u8003\u8a18\u4e8b\u2460<br><a href=\"https:\/\/www.redhat.com\/ja\/technologies\/management\/ansible\/what-is-ansible\">Ansible \u3068\u306f | Red Hat<\/a><br><a href=\"https:\/\/www.redhat.com\/ja\/topics\/automation\/what-is-an-ansible-playbook\">Ansible Playbook \u3068\u306f | Red Hat<\/a><br><a href=\"https:\/\/docs.ansible.com\/ansible\/2.9_ja\/user_guide\/playbooks_reuse_roles.html\">\u30ed\u30fc\u30eb \u2014 Ansible Documentation<\/a><\/p>\n\n\n\n<p>\u53c2\u8003\u8a18\u4e8b\u2461<br><a href=\"https:\/\/docs.fedoraproject.org\/en-US\/epel\/\">Extra Packages for Enterprise Linux (EPEL) :: Fedora Docs (fedoraproject.org)<\/a><\/p>\n\n\n\n<p>\u53c2\u8003\u8a18\u4e8b\u2462<br><a href=\"https:\/\/tech-blog.rakus.co.jp\/entry\/20220608\/ansible\">\u3010Ansible\u3011 Role \u4f7f\u7528\u65b9\u6cd5 \u307e\u3068\u3081 &#8211; RAKUS Developers Blog | \u30e9\u30af\u30b9 \u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0<\/a><\/p>\n\n\n\n<p>\u53c2\u8003\u8a18\u4e8b\u2463<br><a href=\"https:\/\/qiita.com\/_croissant_\/items\/33f06298d7d05bf1e295\">ansible.cfg\u306e\u9805\u76ee\u3092\u30ea\u30b9\u30c8\u5316\u3057\u3066\u307f\u305f &#8211; Qiita<\/a><br>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"\u306f\u3058\u3081\u306b \u3053\u3093\u306b\u3061\u306f\uff01\u4e8b\u696d\u958b\u767a\u63a8\u9032\u90e8\u30a4\u30f3\u30d5\u30e9\u904b\u7528SL\u30c1\u30fc\u30e0\u306e\u5009\u7530\u3067\u3059\u3002\u9023\u8f09\u7b2c2\u56de\u76ee\u3067\u306fZabbix\u3078\u76e3\u8996\u5bfe\u8c61\u30b5\u30fc\u30d0\u3092\u81ea\u52d5\u767b\u9332\u3067\u304d\u308b\u3088\u3046\u306a\u4ed5\u7d44\u307f\u3092Ansible\u306ePlaybook\u3092\u7528\u3044\u3066\u69cb\u7bc9\u3059\u308b\u6d41\u308c\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002 \u76ee\u6b21\u2460\u30b3 [&hellip;]","protected":false},"author":30,"featured_media":111,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[1],"tags":[32,21,33,12,30],"class_list":["post-1244","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-categry-cloud","tag-ansible","tag-kubernetes","tag-zabbix","tag-tag-agile","tag-30"],"_links":{"self":[{"href":"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-json\/wp\/v2\/posts\/1244"}],"collection":[{"href":"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-json\/wp\/v2\/users\/30"}],"replies":[{"embeddable":true,"href":"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-json\/wp\/v2\/comments?post=1244"}],"version-history":[{"count":18,"href":"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-json\/wp\/v2\/posts\/1244\/revisions"}],"predecessor-version":[{"id":1313,"href":"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-json\/wp\/v2\/posts\/1244\/revisions\/1313"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-json\/wp\/v2\/media\/111"}],"wp:attachment":[{"href":"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-json\/wp\/v2\/media?parent=1244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-json\/wp\/v2\/categories?post=1244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/symphonict.nesic.co.jp\/tech-blog\/wp-json\/wp\/v2\/tags?post=1244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}