{"id":1210,"date":"2014-11-13T23:21:27","date_gmt":"2014-11-13T14:21:27","guid":{"rendered":"http:\/\/tech.akat.info\/?p=1210"},"modified":"2014-11-16T01:00:15","modified_gmt":"2014-11-15T16:00:15","slug":"ansible","status":"publish","type":"post","link":"https:\/\/tech.akat.info\/?p=1210","title":{"rendered":"Ansible"},"content":{"rendered":"<h1>\u6982\u8981<\/h1>\n<p>Ansible\u306b\u3064\u3044\u3066\u3084\u3063\u3066\u307f\u305f<br \/>\nhttp:\/\/dotinstall.com\/lessons\/basic_ansible<\/p>\n<h1>Ansible\u3068\u306f<\/h1>\n<p>\u30b5\u30fc\u30d0\u306e\u69cb\u6210\u7ba1\u7406\u30c4\u30fc\u30eb\u3002\u30b5\u30fc\u30d0\u306b\u8a2d\u5b9a\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306e\u4fee\u6b63\u3084\u7ba1\u7406\u304c\u3067\u304d\u308b<br \/>\nagent\u306a\u3069\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u7ba1\u7406\u306b\u3042\u305f\u308a\u7279\u5225\u306a\u30c4\u30fc\u30eb\u304c\u5fc5\u8981\u306a\u3044\u3002\u307e\u305f\u4e26\u5217\u3067\u5b9f\u884c\u3067\u304d\u3001\u9ad8\u901f\u306b\u52d5\u4f5c\u3059\u308b<br \/>\nPython\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u304a\u308a\u3001\u9375\u8a8d\u8a3c\u3067\u306eSSH\u304c\u5229\u7528\u3067\u304d\u308c\u3070OK<br \/>\nEnterprise\u30c4\u30fc\u30eb\u3084\u30b5\u30dd\u30fc\u30c8\u306a\u3069\u3082\u3042\u308a\u3001\u6709\u6599<\/p>\n<h1>\u69cb\u6210<\/h1>\n<p><a href=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-11-13_232015.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/tech.akat.info\/wp-content\/uploads\/2014\/11\/2014-11-13_232015.png\" alt=\"2014-11-13_232015\" width=\"642\" height=\"470\" class=\"alignnone size-full wp-image-1211\" \/><\/a><br \/>\n\u30db\u30b9\u30c8\u306b\u306fAnsible\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<br \/>\nInventory\uff1a\u3069\u306e\u30b5\u30fc\u30d0\u3092\u7ba1\u7406\u3059\u308b\u304b\u8a18\u8f09\u3059\u308b<br \/>\nansible.cfg\uff1aansible\u306e\u5168\u4f53\u7684\u306a\u8a2d\u5b9a\u3092\u8a18\u8f09\u3059\u308b<br \/>\nPlaybook\uff1a\u3069\u306e\u3088\u3046\u306a\u69cb\u6210\u3068\u3059\u308b\u304b\u3092\u8a18\u8f09\u3059\u308b<\/p>\n<h1>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h1>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hostname:\/home\/shimizu# aptitude install python-pip\r\n\u4ee5\u4e0b\u306e\u65b0\u898f\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3059:\r\n  python-pip python-setuptools{a}\r\n...\r\n\r\nroot@hostname:\/home\/shimizu# pip install ansible\r\n...\r\n\r\nroot@hostname:\/home\/shimizu# cat \/root\/.pip\/pip.log\r\n...\r\nsrc\/MD2.c:31:20: fatal error: Python.h: \u305d\u306e\u3088\u3046\u306a\u30d5\u30a1\u30a4\u30eb\u3084\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306f\u3042\u308a\u307e\u305b\u3093\r\ncompilation terminated.\r\nerror: command 'gcc' failed with exit status 1\r\n...\r\n\r\nroot@hostname:\/home\/shimizu# aptitude install python-dev\r\n\u4ee5\u4e0b\u306e\u65b0\u898f\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3059:\r\n  libexpat1-dev{a} python-dev python2.7-dev{a}\r\n...\r\n\r\n### \u518d\u5ea6\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u3068\u3053\u308d\u3046\u307e\u304f\u3044\u3063\u305f ###\r\nroot@hostname:\/home\/shimizu# pip install ansible\r\n...\r\nSuccessfully installed pycrypto ecdsa\r\nCleaning up...\r\nroot@hostname:\/home\/shimizu# ansible --version\r\nansible 1.7.2\r\n\r\n### SSH\u74b0\u5883\u4f5c\u6210 ###\r\n### \u30af\u30e9\u30a4\u30a2\u30f3\u30c8 ###\r\n&#x5B;root@ip-172-32-0-221 ec2-user]# useradd deploy\r\n&#x5B;root@ip-172-32-0-221 ec2-user]# cat \/etc\/passwd\r\n...\r\ndeploy  ALL=(ALL)       ALL\r\n...\r\n&#x5B;root@ip-172-32-0-221 ec2-user]# su deploy\r\n&#x5B;deploy@ip-172-32-0-221 ec2-user]$ cd \/home\/deploy\/\r\n&#x5B;deploy@ip-172-32-0-221 .ssh]$ ssh-keygen -t rsa\r\nGenerating public\/private rsa key pair.\r\nEnter file in which to save the key (\/home\/deploy\/.ssh\/id_rsa):\r\nEnter passphrase (empty for no passphrase):\r\nEnter same passphrase again:\r\nYour identification has been saved in \/home\/deploy\/.ssh\/id_rsa. # \u79d8\u5bc6\u9375\r\nYour public key has been saved in \/home\/deploy\/.ssh\/id_rsa.pub. # \u516c\u958b\u9375\r\nThe key fingerprint is:\r\n02:35:0c:37:22:21:06:61:53:50:5e:4f:42:d8:23:9d deploy@ip-172-32-0-221\r\nThe key's randomart image is:\r\n+--&#x5B; RSA 2048]----+\r\n|=**+B**.         |\r\n|o.o+.E=o         |\r\n|   .o ..         |\r\n|     .           |\r\n|      . S        |\r\n|       .         |\r\n|                 |\r\n|                 |\r\n|                 |\r\n+-----------------+\r\n&#x5B;deploy@ip-172-32-0-221 .ssh]$ chmod 600 id_rsa.pub\r\n&#x5B;deploy@ip-172-32-0-221 ~]$ chmod 700 .ssh\r\n&#x5B;deploy@ip-172-32-0-221 ~]$ mv id_rsa.pub authorized_keys\r\n### \u30b5\u30fc\u30d0 ###\r\n### \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3067\u4f5c\u6210\u3057\u305f\u79d8\u5bc6\u9375\u3092\u30b3\u30d4\u30fc\u3059\u308b ###\r\nroot@hostname:\/home\/shimizu# vi \/root\/.ssh\/aws_rsa\r\n...\r\nroot@hostname:\/home\/shimizu# chmod 600 \/root\/.ssh\/aws_rsa\r\nroot@hostname:\/home\/shimizu# ssh -i \/root\/.ssh\/aws_rsa deploy@tech.akat.info\r\nLast login: Fri Nov 14 01:14:47 2014 from hostname.sakura.ne.jp\r\n\r\n       __|  __|_  )\r\n       _|  (     \/   Amazon Linux AMI\r\n      ___|\\___|___|\r\n\r\nhttps:\/\/aws.amazon.com\/amazon-linux-ami\/2014.09-release-notes\/\r\n&#x5B;deploy@ip-172-32-0-221 ~]$\r\n<\/pre>\n<h1>\u5229\u7528\u65b9\u6cd5<\/h1>\n<pre class=\"brush: plain; highlight: [1,2,3,4,7,8,12,13,19,20,25,26,33,34,230,231,239,285,286,297,343,389,390,394,395,402,403,449,450,460,461,470,481,482,484,491,537,538,546]; title: ; notranslate\" title=\"\">\r\n### Inventory\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210 - \u6b63\u898f\u8868\u73fe\u3082\u5229\u7528\u53ef\u80fd###\r\nroot@hostname:\/home\/shimizu# mkdir \/etc\/ansible\r\nroot@hostname:\/home\/shimizu# cd \/etc\/ansible\/\r\nroot@hostname:\/etc\/ansible# cat hosts\r\n&#x5B;web] # \u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\u3067\u304d\u308b\r\n54.64.208.148\r\n### Inventory\u30d5\u30a1\u30a4\u30eb\u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u78ba\u8a8d ###\r\nroot@hostname:\/etc\/ansible# ansible all -i hosts -m ping -u deploy --private-key=\/root\/.ssh\/aws_rsa                                            54.64.208.148 | success &gt;&gt; {\r\n    &quot;changed&quot;: false,\r\n    &quot;ping&quot;: &quot;pong&quot;\r\n}\r\n### \u30ed\u30fc\u30ab\u30eb\u30db\u30b9\u30c8\u3067\u30c6\u30b9\u30c8\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd ###\r\nroot@hostname:\/etc\/ansible# ansible localhost -m ping\r\nlocalhost | success &gt;&gt; {\r\n    &quot;changed&quot;: false,\r\n    &quot;ping&quot;: &quot;pong&quot;\r\n}\r\n\r\n### \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b ###\r\nroot@hostname:\/etc\/ansible# ansible all -i hosts -m command -a &quot;ls \/etc\/php-fpm-5.5.d&quot; -u deploy --private-key=\/root\/.ssh\/aws_rsa\r\n54.64.208.148 | success | rc=0 &gt;&gt;\r\nphp-fpm.conf\r\nwww.conf\r\n\r\n### \u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b ###\r\nroot@hostname:\/etc\/ansible# vi \/etc\/ansible\/ansible.cfg\r\n&#x5B;defaults]\r\n# \u30ea\u30e2\u30fc\u30c9\u63a5\u7d9a\u3059\u308b\u3068\u304d\u306b\u4e26\u884c\u3057\u3066\u751f\u6210\u3059\u308b\u30d7\u30ed\u30bb\u30b9\u6570\r\nforks=10\r\n# \u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\r\nlog_path=\/var\/log\/ansible.log\r\n\r\n### \u30b5\u30fc\u30d0\u306e\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b ###\r\nroot@hostname:\/etc\/ansible# ansible all -i hosts -m setup -u deploy --private-key=\/root\/.ssh\/aws_rsa\r\n54.64.208.148 | success &gt;&gt; {\r\n    &quot;ansible_facts&quot;: {\r\n        &quot;ansible_all_ipv4_addresses&quot;: &#x5B;\r\n            &quot;172.32.0.221&quot;\r\n        ],\r\n        &quot;ansible_all_ipv6_addresses&quot;: &#x5B;\r\n            &quot;fe80::48d:e7ff:fe9f:8b8f&quot;\r\n        ],\r\n        &quot;ansible_architecture&quot;: &quot;x86_64&quot;,\r\n        &quot;ansible_bios_date&quot;: &quot;06\/02\/2014&quot;,\r\n        &quot;ansible_bios_version&quot;: &quot;4.2.amazon&quot;,\r\n        &quot;ansible_cmdline&quot;: {\r\n            &quot;console&quot;: &quot;ttyS0&quot;,\r\n            &quot;root&quot;: &quot;LABEL=\/&quot;\r\n        },\r\n        &quot;ansible_date_time&quot;: {\r\n            &quot;date&quot;: &quot;2014-11-14&quot;,\r\n            &quot;day&quot;: &quot;14&quot;,\r\n            &quot;epoch&quot;: &quot;1415977044&quot;,\r\n            &quot;hour&quot;: &quot;23&quot;,\r\n            &quot;iso8601&quot;: &quot;2014-11-14T14:57:24Z&quot;,\r\n            &quot;iso8601_micro&quot;: &quot;2014-11-14T14:57:24.426875Z&quot;,\r\n            &quot;minute&quot;: &quot;57&quot;,\r\n            &quot;month&quot;: &quot;11&quot;,\r\n            &quot;second&quot;: &quot;24&quot;,\r\n            &quot;time&quot;: &quot;23:57:24&quot;,\r\n            &quot;tz&quot;: &quot;JST&quot;,\r\n            &quot;tz_offset&quot;: &quot;+0900&quot;,\r\n            &quot;weekday&quot;: &quot;Friday&quot;,\r\n            &quot;year&quot;: &quot;2014&quot;\r\n        },\r\n        &quot;ansible_default_ipv4&quot;: {\r\n            &quot;address&quot;: &quot;172.32.0.221&quot;,\r\n            &quot;alias&quot;: &quot;eth0&quot;,\r\n            &quot;gateway&quot;: &quot;172.32.0.1&quot;,\r\n            &quot;interface&quot;: &quot;eth0&quot;,\r\n            &quot;macaddress&quot;: &quot;06:8d:e7:9f:8b:8f&quot;,\r\n            &quot;mtu&quot;: 9001,\r\n            &quot;netmask&quot;: &quot;255.255.255.0&quot;,\r\n            &quot;network&quot;: &quot;172.32.0.0&quot;,\r\n            &quot;type&quot;: &quot;ether&quot;\r\n        },\r\n        &quot;ansible_default_ipv6&quot;: {},\r\n        &quot;ansible_devices&quot;: {\r\n            &quot;xvda&quot;: {\r\n                &quot;holders&quot;: &#x5B;],\r\n                &quot;host&quot;: &quot;&quot;,\r\n                &quot;model&quot;: null,\r\n                &quot;partitions&quot;: {\r\n                    &quot;xvda1&quot;: {\r\n                        &quot;sectors&quot;: &quot;16773087&quot;,\r\n                        &quot;sectorsize&quot;: 512,\r\n                        &quot;size&quot;: &quot;8.00 GB&quot;,\r\n                        &quot;start&quot;: &quot;4096&quot;\r\n                    }\r\n                },\r\n                &quot;removable&quot;: &quot;0&quot;,\r\n                &quot;rotational&quot;: &quot;0&quot;,\r\n                &quot;scheduler_mode&quot;: &quot;noop&quot;,\r\n                &quot;sectors&quot;: &quot;16777216&quot;,\r\n                &quot;sectorsize&quot;: &quot;512&quot;,\r\n                &quot;size&quot;: &quot;8.00 GB&quot;,\r\n                &quot;support_discard&quot;: &quot;0&quot;,\r\n                &quot;vendor&quot;: null\r\n            }\r\n        },\r\n        &quot;ansible_distribution&quot;: &quot;Amazon&quot;,\r\n        &quot;ansible_distribution_major_version&quot;: &quot;NA&quot;,\r\n        &quot;ansible_distribution_release&quot;: &quot;NA&quot;,\r\n        &quot;ansible_distribution_version&quot;: &quot;2014.09&quot;,\r\n        &quot;ansible_domain&quot;: &quot;&quot;,\r\n        &quot;ansible_env&quot;: {\r\n            &quot;AWS_AUTO_SCALING_HOME&quot;: &quot;\/opt\/aws\/apitools\/as&quot;,\r\n            &quot;AWS_CLOUDWATCH_HOME&quot;: &quot;\/opt\/aws\/apitools\/mon&quot;,\r\n            &quot;AWS_ELB_HOME&quot;: &quot;\/opt\/aws\/apitools\/elb&quot;,\r\n            &quot;AWS_PATH&quot;: &quot;\/opt\/aws&quot;,\r\n            &quot;AWS_RDS_HOME&quot;: &quot;\/opt\/aws\/apitools\/rds&quot;,\r\n            &quot;EC2_AMITOOL_HOME&quot;: &quot;\/opt\/aws\/amitools\/ec2&quot;,\r\n            &quot;EC2_HOME&quot;: &quot;\/opt\/aws\/apitools\/ec2&quot;,\r\n            &quot;HOME&quot;: &quot;\/home\/deploy&quot;,\r\n            &quot;JAVA_HOME&quot;: &quot;\/usr\/lib\/jvm\/jre&quot;,\r\n            &quot;LANG&quot;: &quot;en_US.UTF-8&quot;,\r\n            &quot;LC_CTYPE&quot;: &quot;en_US.UTF-8&quot;,\r\n            &quot;LESSOPEN&quot;: &quot;||\/usr\/bin\/lesspipe.sh %s&quot;,\r\n            &quot;LESS_TERMCAP_mb&quot;: &quot;\\u001b&#x5B;01;31m&quot;,\r\n            &quot;LESS_TERMCAP_md&quot;: &quot;\\u001b&#x5B;01;38;5;208m&quot;,\r\n            &quot;LESS_TERMCAP_me&quot;: &quot;\\u001b&#x5B;0m&quot;,\r\n            &quot;LESS_TERMCAP_se&quot;: &quot;\\u001b&#x5B;0m&quot;,\r\n            &quot;LESS_TERMCAP_ue&quot;: &quot;\\u001b&#x5B;0m&quot;,\r\n            &quot;LESS_TERMCAP_us&quot;: &quot;\\u001b&#x5B;04;38;5;111m&quot;,\r\n            &quot;LOGNAME&quot;: &quot;deploy&quot;,\r\n            &quot;MAIL&quot;: &quot;\/var\/mail\/deploy&quot;,\r\n            &quot;PATH&quot;: &quot;\/usr\/local\/bin:\/bin:\/usr\/bin:\/opt\/aws\/bin&quot;,\r\n            &quot;PWD&quot;: &quot;\/home\/deploy&quot;,\r\n            &quot;SHELL&quot;: &quot;\/bin\/bash&quot;,\r\n            &quot;SHLVL&quot;: &quot;2&quot;,\r\n            &quot;SSH_CLIENT&quot;: &quot;49.212.204.46 35705 22&quot;,\r\n            &quot;SSH_CONNECTION&quot;: &quot;49.212.204.46 35705 172.32.0.221 22&quot;,\r\n            &quot;SSH_TTY&quot;: &quot;\/dev\/pts\/1&quot;,\r\n            &quot;TERM&quot;: &quot;xterm&quot;,\r\n            &quot;USER&quot;: &quot;deploy&quot;,\r\n            &quot;_&quot;: &quot;\/usr\/bin\/python&quot;\r\n        },\r\n        &quot;ansible_eth0&quot;: {\r\n            &quot;active&quot;: true,\r\n            &quot;device&quot;: &quot;eth0&quot;,\r\n            &quot;ipv4&quot;: {\r\n                &quot;address&quot;: &quot;172.32.0.221&quot;,\r\n                &quot;netmask&quot;: &quot;255.255.255.0&quot;,\r\n                &quot;network&quot;: &quot;172.32.0.0&quot;\r\n            },\r\n            &quot;ipv6&quot;: &#x5B;\r\n                {\r\n                    &quot;address&quot;: &quot;fe80::48d:e7ff:fe9f:8b8f&quot;,\r\n                    &quot;prefix&quot;: &quot;64&quot;,\r\n                    &quot;scope&quot;: &quot;link&quot;\r\n                }\r\n            ],\r\n            &quot;macaddress&quot;: &quot;06:8d:e7:9f:8b:8f&quot;,\r\n            &quot;mtu&quot;: 9001,\r\n            &quot;promisc&quot;: false,\r\n            &quot;type&quot;: &quot;ether&quot;\r\n        },\r\n        &quot;ansible_form_factor&quot;: &quot;Other&quot;,\r\n        &quot;ansible_fqdn&quot;: &quot;ip-172-32-0-221&quot;,\r\n        &quot;ansible_hostname&quot;: &quot;ip-172-32-0-221&quot;,\r\n        &quot;ansible_interfaces&quot;: &#x5B;\r\n            &quot;lo&quot;,\r\n            &quot;eth0&quot;\r\n        ],\r\n        &quot;ansible_kernel&quot;: &quot;3.14.20-20.44.amzn1.x86_64&quot;,\r\n        &quot;ansible_lo&quot;: {\r\n            &quot;active&quot;: true,\r\n            &quot;device&quot;: &quot;lo&quot;,\r\n            &quot;ipv4&quot;: {\r\n                &quot;address&quot;: &quot;127.0.0.1&quot;,\r\n                &quot;netmask&quot;: &quot;255.0.0.0&quot;,\r\n                &quot;network&quot;: &quot;127.0.0.0&quot;\r\n            },\r\n            &quot;ipv6&quot;: &#x5B;\r\n                {\r\n                    &quot;address&quot;: &quot;::1&quot;,\r\n                    &quot;prefix&quot;: &quot;128&quot;,\r\n                    &quot;scope&quot;: &quot;host&quot;\r\n                }\r\n            ],\r\n            &quot;mtu&quot;: 65536,\r\n            &quot;promisc&quot;: false,\r\n            &quot;type&quot;: &quot;loopback&quot;\r\n        },\r\n        &quot;ansible_machine&quot;: &quot;x86_64&quot;,\r\n        &quot;ansible_memfree_mb&quot;: 73,\r\n        &quot;ansible_memtotal_mb&quot;: 996,\r\n        &quot;ansible_mounts&quot;: &#x5B;\r\n            {\r\n                &quot;device&quot;: &quot;\/dev\/xvda1&quot;,\r\n                &quot;fstype&quot;: &quot;ext4&quot;,\r\n                &quot;mount&quot;: &quot;\/&quot;,\r\n                &quot;options&quot;: &quot;rw,noatime,data=ordered&quot;,\r\n                &quot;size_available&quot;: 5455257600,\r\n                &quot;size_total&quot;: 8318783488\r\n            }\r\n        ],\r\n        &quot;ansible_nodename&quot;: &quot;ip-172-32-0-221&quot;,\r\n        &quot;ansible_os_family&quot;: &quot;RedHat&quot;,\r\n        &quot;ansible_pkg_mgr&quot;: &quot;yum&quot;,\r\n        &quot;ansible_processor&quot;: &#x5B;\r\n            &quot;Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz&quot;\r\n        ],\r\n        &quot;ansible_processor_cores&quot;: 1,\r\n        &quot;ansible_processor_count&quot;: 1,\r\n        &quot;ansible_processor_threads_per_core&quot;: 1,\r\n        &quot;ansible_processor_vcpus&quot;: 1,\r\n        &quot;ansible_product_name&quot;: &quot;HVM domU&quot;,\r\n        &quot;ansible_product_serial&quot;: &quot;NA&quot;,\r\n        &quot;ansible_product_uuid&quot;: &quot;NA&quot;,\r\n        &quot;ansible_product_version&quot;: &quot;4.2.amazon&quot;,\r\n        &quot;ansible_python_version&quot;: &quot;2.6.9&quot;,\r\n        &quot;ansible_selinux&quot;: false,\r\n        &quot;ansible_ssh_host_key_dsa_public&quot;: &quot;...&quot;,\r\n        &quot;ansible_ssh_host_key_ecdsa_public&quot;: &quot;...&quot;,\r\n        &quot;ansible_ssh_host_key_rsa_public&quot;: &quot;...&quot;,\r\n        &quot;ansible_swapfree_mb&quot;: 0,\r\n        &quot;ansible_swaptotal_mb&quot;: 0,\r\n        &quot;ansible_system&quot;: &quot;Linux&quot;,\r\n        &quot;ansible_system_vendor&quot;: &quot;Xen&quot;,\r\n        &quot;ansible_user_id&quot;: &quot;deploy&quot;,\r\n        &quot;ansible_userspace_architecture&quot;: &quot;x86_64&quot;,\r\n        &quot;ansible_userspace_bits&quot;: &quot;64&quot;,\r\n        &quot;ansible_virtualization_role&quot;: &quot;guest&quot;,\r\n        &quot;ansible_virtualization_type&quot;: &quot;xen&quot;,\r\n        &quot;module_setup&quot;: true\r\n    },\r\n    &quot;changed&quot;: false\r\n}\r\n### IP\u30a2\u30c9\u30ec\u30b9\u3060\u3051\u3092\u53d6\u5f97\u3059\u308b ###\r\nroot@hostname:\/etc\/ansible# cat playbook1.yml\r\n---\r\n- hosts: all\r\n  sudo: yes\r\n  tasks:\r\n     - name: gathering ip address\r\n       command: echo {{ ansible_eth0.ipv4.address }}\r\n\r\nroot@hostname:\/etc\/ansible# ansible-playbook playbook1.yml -u deploy --private-key=\/root\/.ssh\/aws_rsa --ask-sudo-pass\r\nsudo password:\r\n ____________\r\n&lt; PLAY &#x5B;all] &gt;\r\n ------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\n _________________\r\n&lt; GATHERING FACTS &gt;\r\n -----------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\nok: &#x5B;54.64.208.148]\r\n ____________________________\r\n&lt; TASK: gathering ip address &gt;\r\n ----------------------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\nchanged: &#x5B;54.64.208.148]\r\n ____________\r\n&lt; PLAY RECAP &gt;\r\n ------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\n54.64.208.148              : ok=2    changed=1    unreachable=0    failed=0\r\n\r\n### Playbook\u3092\u5229\u7528\u3057\u3066\u3001\u30e6\u30fc\u30b6\u3092\u4f5c\u6210\u3057\u3066\u307f\u308b ###\r\nroot@hostname:\/etc\/ansible# cat playbook1.yml\r\n---\r\n- hosts: all\r\n  sudo: yes\r\n  tasks:\r\n    - name: add a new user\r\n      user: name=ansibletest\r\n\r\n### tasks\u306f\u3042\u308b\u3079\u304d\u72b6\u614b\u3092\u8a18\u8f09\u3057\u3066\u3044\u308b\r\n### \u3064\u307e\u308a\u3001\u3059\u3067\u306b\u30e6\u30fc\u30b6ansibletest\u304c\u3044\u308b\u5834\u5408\u306f\u4f55\u3082\u3057\u306a\u3044\r\n\r\nroot@hostname:\/etc\/ansible# ansible-playbook playbook1.yml -u deploy --private-key=\/root\/.ssh\/aws_rsa --ask-sudo-pass\r\nsudo password:\r\n ____________\r\n&lt; PLAY &#x5B;all] &gt;\r\n ------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\n _________________\r\n&lt; GATHERING FACTS &gt;\r\n -----------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\nok: &#x5B;54.64.208.148]\r\n ______________________\r\n&lt; TASK: add a new user &gt;\r\n ----------------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\nchanged: &#x5B;54.64.208.148]\r\n ____________\r\n&lt; PLAY RECAP &gt;\r\n ------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\n54.64.208.148              : ok=2    changed=1    unreachable=0    failed=0\r\n\r\nroot@hostname:\/etc\/ansible# ansible-playbook playbook1.yml -u deploy --private-key=\/root\/.ssh\/aws_rsa --ask-sudo-pass\r\nsudo password:\r\n ____________\r\n&lt; PLAY &#x5B;all] &gt;\r\n ------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\n _________________\r\n&lt; GATHERING FACTS &gt;\r\n -----------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\nok: &#x5B;54.64.208.148]\r\n ______________________\r\n&lt; TASK: add a new user &gt;\r\n ----------------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\nok: &#x5B;54.64.208.148]\r\n ____________\r\n&lt; PLAY RECAP &gt;\r\n ------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\n54.64.208.148              : ok=2    changed=0    unreachable=0    failed=0 # 2\u56de\u76ee\u306fchanged\u304c0\u3068\u306a\u3063\u3066\u3044\u308b\r\n\r\n### syntax check ###\r\nroot@hostname:\/etc\/ansible# ansible-playbook playbook1.yml --syntax-check\r\n\r\nplaybook: playbook1.yml\r\n\r\n### \u30bf\u30b9\u30af\u3092\u8868\u793a ###\r\nroot@hostname:\/etc\/ansible# ansible-playbook playbook1.yml --list-task\r\n\r\nplaybook: playbook1.yml\r\n\r\n  play #1 (all):\r\n    add a new user\r\n\r\n### dry run ###\r\nroot@hostname:\/etc\/ansible# ansible-playbook playbook1.yml -u deploy --private-key=\/root\/.ssh\/aws_rsa --ask-sudo-pass --check\r\nsudo password:\r\n ____________\r\n&lt; PLAY &#x5B;all] &gt;\r\n ------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\n _________________\r\n&lt; GATHERING FACTS &gt;\r\n -----------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\nok: &#x5B;54.64.208.148]\r\n ______________________\r\n&lt; TASK: add a new user &gt;\r\n ----------------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\nchanged: &#x5B;54.64.208.148]\r\n ____________\r\n&lt; PLAY RECAP &gt;\r\n ------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\n54.64.208.148              : ok=2    changed=1    unreachable=0    failed=0\r\n\r\n### \u5909\u6570\u3082\u5229\u7528\u53ef\u80fd ###\r\nroot@hostname:\/etc\/ansible# cat playbook1.yml\r\n---\r\n- hosts: all\r\n  sudo: yes\r\n  vars:\r\n      username: testuser\r\n  tasks:\r\n    - name: add a new user\r\n      user: name={{username}}\r\n\r\n### \u5909\u6570\u3092\u30e6\u30fc\u30b6\u306b\u5165\u529b\u3055\u305b\u308b\u3053\u3068\u3082\u53ef\u80fd ###\r\nroot@hostname:\/etc\/ansible# cat playbook1.yml\r\n---\r\n- hosts: all\r\n  sudo: yes\r\n  vars_prompt:\r\n      username: &quot;Enter username&quot;\r\n  tasks:\r\n    - name: add a new user\r\n      user: name={{username}}\r\nroot@hostname:\/etc\/ansible# ansible-playbook playbook1.yml -u deploy --private-key=\/root\/.ssh\/aws_rsa --ask-sudo-pass --check\r\nsudo password:\r\nEnter username: :\r\n ____________\r\n&lt; PLAY &#x5B;all] &gt;\r\n ------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n...\r\n\r\n### \u30d5\u30a1\u30a4\u30eb\u3092\u304a\u304f ###\r\nroot@hostname:\/etc\/ansible# cat test.txt\r\nthis is test\r\nroot@hostname:\/etc\/ansible# cat playbook1.yml\r\n---\r\n- hosts: all\r\n  sudo: yes\r\n  tasks:\r\n     - name: copy test.txt\r\n       copy: src=.\/test.txt dest=\/home\/ec2-user\/test.txt owner=root\r\nroot@hostname:\/etc\/ansible# ansible-playbook playbook1.yml -u deploy --private-key=\/root\/.ssh\/aws_rsa --ask-sudo-pass\r\nsudo password:\r\n ____________\r\n&lt; PLAY &#x5B;all] &gt;\r\n ------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\n _________________\r\n&lt; GATHERING FACTS &gt;\r\n -----------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\nok: &#x5B;54.64.208.148]\r\n _____________________\r\n&lt; TASK: copy test.txt &gt;\r\n ---------------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\nchanged: &#x5B;54.64.208.148]\r\n ____________\r\n&lt; PLAY RECAP &gt;\r\n ------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\n54.64.208.148              : ok=2    changed=1    unreachable=0    failed=0\r\n\r\n### \u72b6\u6cc1\u306b\u3088\u3063\u3066\u51e6\u7406\u3092\u5909\u66f4\u3059\u308b ###\r\nroot@hostname:\/etc\/ansible# cat playbook1.yml\r\n---\r\n- hosts: all\r\n  sudo: yes\r\n  tasks:\r\n     - name: &quot;command if debian&quot;\r\n       command: echo {{ ansible_eth0.ipv4.address }}\r\n       when: ansible_os_family == &quot;Debian&quot;\r\nroot@hostname:\/etc\/ansible# ansible-playbook playbook1.yml -u deploy --private-key=\/root\/.ssh\/aws_rsa --ask-sudo-pass\r\nsudo password:\r\n ____________\r\n&lt; PLAY &#x5B;all] &gt;\r\n ------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\n _________________\r\n&lt; GATHERING FACTS &gt;\r\n -----------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\nok: &#x5B;54.64.208.148]\r\n _________________________\r\n&lt; TASK: command if debian &gt;\r\n -------------------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\nskipping: &#x5B;54.64.208.148]\r\n ____________\r\n&lt; PLAY RECAP &gt;\r\n ------------\r\n        \\   ^__^\r\n         \\  (oo)\\_______\r\n            (__)\\       )\\\/\\\r\n                ||----w |\r\n                ||     ||\r\n\r\n\r\n54.64.208.148              : ok=1    changed=0    unreachable=0    failed=0\r\n\r\n\r\n<\/pre>\n<h1>\u305d\u306e\u4ed6<\/h1>\n<p>\u30fbhandlers\u3092\u5229\u7528\u3059\u308c\u3070\u3001\u30b5\u30fc\u30d0\u306b\u5909\u66f4\u304c\u3042\u3063\u305f\u3068\u304d\u306e\u307f\u6700\u5f8c\u306b1\u56de\u51e6\u7406\u3092\u3059\u308b\u306a\u3069\u53ef\u80fd\u3068\u306a\u308b<br \/>\n\u3000(\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5f8c\u306bapache\u3092\u518d\u8d77\u52d5\u3059\u308b\u306a\u3069)<br \/>\n\u30fbOS\u306b\u3088\u3063\u3066\u6319\u52d5\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd<br \/>\n\u3000(\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30d1\u30c3\u30b1\u30fc\u30b8\u540d\u3092\u5909\u66f4\u3059\u308b\u306a\u3069)<br \/>\n\u30fbansible-pull\u3068\u3044\u3046\u5fdc\u7528\u30b3\u30de\u30f3\u30c9\u3082\u3042\u308a\u3001push\u578b\u306eansible\u306bpull\u578b\u306e\u6a5f\u80fd\u3092\u3082\u305f\u305b\u3066\u3044\u308b<br \/>\n\u30fb\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u4f7f\u3044\u65b9\u78ba\u8a8d\u65b9\u6cd5 ansible-doc [\u30e2\u30b8\u30e5\u30fc\u30eb\u540d]<br \/>\n\u30fb\u4ed6\u306ePlayBook\u3092\u8aad\u307f\u8fbc\u3080\u3053\u3068\u3082\u53ef\u80fd(- include: other.yml)<\/p>\n<h1>\u53c2\u8003URL<\/h1>\n<p>ansible\u3092\u4f7f\u3063\u3066\u307f\u308b-\u5e45\u5e83\u304f\u4f7f\u3044\u65b9\u304c\u8a18\u8f09\u3055\u308c\u3066\u304a\u308a\u308f\u304b\u308a\u3084\u3059\u3044<br \/>\nhttp:\/\/tdoc.info\/blog\/2013\/04\/20\/ansible.html<br \/>\n\u5165\u9580ansible(\u672a\u767a\u8868\u7b87\u6240)<\/p>\n<div class=\"oceanwp-oembed-wrap clr\"><iframe loading=\"lazy\" src=\"https:\/\/www.slideshare.net\/slideshow\/embed_code\/key\/ro455i1kjLJh4y\" width=\"427\" height=\"356\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" style=\"border:1px solid #CCC; border-width:1px; margin-bottom:5px; max-width: 100%;\" allowfullscreen> <\/iframe> <\/p>\n<div style=\"margin-bottom:5px\"> <strong> <a href=\"https:\/\/www.slideshare.net\/takushimizu\/ansible-28951674\" title=\"\u5165\u9580Ansible(\u672a\u767a\u8868\u7b87\u6240)\" target=\"_blank\">\u5165\u9580Ansible(\u672a\u767a\u8868\u7b87\u6240)<\/a> <\/strong> from <strong><a href=\"http:\/\/www.slideshare.net\/takushimizu\" target=\"_blank\">Taku Shimizu<\/a><\/strong> <\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 Ansible\u306b\u3064\u3044\u3066\u3084\u3063\u3066\u307f\u305f http:\/\/dotinstall.com\/lessons\/basic_ansible Ansible\u3068\u306f \u30b5\u30fc\u30d0\u306e\u69cb\u6210\u7ba1\u7406\u30c4\u30fc\u30eb\u3002\u30b5\u30fc\u30d0\u306b\u8a2d\u5b9a\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306e\u4fee\u6b63\u3084\u7ba1\u7406\u304c\u3067\u304d\u308b a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[42],"tags":[],"_links":{"self":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/1210"}],"collection":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1210"}],"version-history":[{"count":14,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/1210\/revisions"}],"predecessor-version":[{"id":1225,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/1210\/revisions\/1225"}],"wp:attachment":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}