{"id":120,"date":"2017-11-27T08:00:47","date_gmt":"2017-11-26T23:00:47","guid":{"rendered":"http:\/\/www.itc109.com\/knowledge\/?p=120"},"modified":"2021-09-30T09:00:03","modified_gmt":"2021-09-30T00:00:03","slug":"ansible-aws-cli-remote-install","status":"publish","type":"post","link":"https:\/\/www.itc109.com\/knowledge\/aws\/ansible-aws-cli-remote-install","title":{"rendered":"Ansible &#8211; AWS CLI \u30ea\u30e2\u30fc\u30c8\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb"},"content":{"rendered":"<h4><strong>\u6982\u8981<\/strong><\/h4>\n<hr \/>\n<p>Ansible\u3092\u4f7f\u7528\u3057\u3066\u4ed6\u306e\u30b5\u30fc\u30d0\u30fc\u306baws cli\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u624b\u9806\u306b\u3064\u3044\u3066\u8a18\u8f09\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>\u624b\u9806<\/strong><\/h4>\n<hr \/>\n<p><strong>1.hosts\u3092\u7de8\u96c6\u3057\u307e\u3059\u3002<\/strong><\/p>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre>sudo vi \/etc\/ansible\/hosts\r\n<\/pre>\n<p>\u521d\u671f\u5185\u5bb9<\/p>\n<pre># This is the default ansible 'hosts' file.\r\n#\r\n# It should live in \/etc\/ansible\/hosts\r\n#\r\n#   - Comments begin with the '#' character\r\n#   - Blank lines are ignored\r\n#   - Groups of hosts are delimited by [header] elements\r\n#   - You can enter hostnames or ip addresses\r\n#   - A hostname\/ip can be a member of multiple groups\r\n\r\n# Ex 1: Ungrouped hosts, specify before any group headers.\r\n\r\n## green.example.com\r\n## blue.example.com\r\n## 192.168.100.1\r\n## 192.168.100.10\r\n\r\n# Ex 2: A collection of hosts belonging to the 'webservers' group\r\n\r\n## [webservers]\r\n## alpha.example.org\r\n## beta.example.org\r\n## 192.168.1.100\r\n## 192.168.1.110\r\n\r\n# If you have multiple hosts following a pattern you can specify\r\n# them like this:\r\n\r\n## www[001:006].example.com\r\n\r\n# Ex 3: A collection of database servers in the 'dbservers' group\r\n\r\n## [dbservers]\r\n##\r\n## db01.intranet.mydomain.net\r\n## db02.intranet.mydomain.net\r\n## 10.25.1.56\r\n## 10.25.1.57\r\n\r\n# Here's another example of host ranges, this time there are no\r\n# leading 0s:\r\n\r\n## db-[99:101]-node.example.com\r\n<\/pre>\n<p>\u6b21\u306e\u30b3\u30fc\u30c9\u3092\u633f\u5165\u3059\u308b\u3002<span style=\"color: #ff0000;\">\u203b\u30b5\u30f3\u30d7\u30eb<\/span><\/p>\n<pre># \u30b0\u30eb\u30fc\u30d7\u3092\u4f7f\u7528\u3057\u3066\u30db\u30b9\u30c8\u540d\u3068\u3057\u3066\u7ba1\u7406\u3059\u308b\u65b9\u6cd5\r\n[EC2-WEB01]\r\nxxx.xxx.xxx.xxx\r\n\r\n[EC2-WEB02]\r\nxxx.xxx.xxx.xxx\r\n\r\n[EC2-WEB03]\r\nxxx.xxx.xxx.xxx\r\n\r\n[EC2-WEB04]\r\nxxx.xxx.xxx.xxx\r\n\r\n[EC2-BAT01]\r\nxxx.xxx.xxx.xxx\r\n\r\n[EC2-BAT02]\r\nxxx.xxx.xxx.xxx\r\n\r\n[EC2-SRV01]\r\nxxx.xxx.xxx.xxx\r\n\r\n[EC2-SRV02]\r\nxxx.xxx.xxx.xxx\r\n\r\n[EC2-SQL01]\r\nxxx.xxx.xxx.xxx\r\n\r\n[EC2-SQL02]\r\nxxx.xxx.xxx.xxx\r\n\r\n\r\n# \u30b0\u30eb\u30fc\u30d7\u3092\u30b0\u30eb\u30fc\u30d7\u3067\u7e8f\u3081\u308b\u65b9\u6cd5\r\n[web:children]\r\nEC2-WEB01\r\nEC2-WEB02\r\nEC2-WEB03\r\nEC2-WEB04\r\n\r\n[bat:children]\r\nEC2-BAT01\r\nEC2-BAT02\r\n\r\n[srv:children]\r\nEC2-SRV01\r\nEC2-SRV02\r\n\r\n[sql:children]\r\nEC2-SQL01\r\nEC2-SQL02\r\n\r\n# \u3059\u3066\u3079\u306e\u30b0\u30eb\u30fc\u30d7\u3092\u7e8f\u3081\u308b\u65b9\u6cd5\r\n[all:children]\r\nweb\r\nbat\r\nsrv\r\nsql\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>2.\u30ea\u30e2\u30fc\u30c8\u3067AWS CLI\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002<\/strong><\/p>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n<pre>ansible all -s -a 'curl \"https:\/\/bootstrap.pypa.io\/get-pip.py\" -o \"get-pip.py\"'\r\n<\/pre>\n<pre>ansible all -s -a \"python get-pip.py\"\r\n<\/pre>\n<pre>ansible all -s -a \"pip install awscli\"\r\n<\/pre>\n<p>\u203b\u300call\u300d\u3092\u4f7f\u7528\u305b\u305a\u306b\u3001\u500b\u5225\u306bIP\u30a2\u30c9\u30ec\u30b9\u3067\u6307\u5b9a(xxx.xxx.xxx.xxx)\u3059\u308b\u65b9\u6cd5\u3084\u3001\u30b0\u30eb\u30fc\u30d7\u540d\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>\u88dc\u8db3<\/strong><\/h4>\n<hr \/>\n<p>sudo\u3092\u4f7f\u7528\u3059\u308b\u3068\u8b66\u544a\u304c\u8868\u793a\u3055\u308c\u308b\u3002<\/p>\n<pre>[WARNING]: Consider using 'become', 'become_method', and 'become_user' rather than running sudo\r\n<\/pre>\n<div class=\"tw-swapa\"><span lang=\"ja\">[\u8b66\u544a]\uff1asudo\u3092\u5b9f\u884c\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001 &#8216;become&#8217;\u3001 &#8216;become_method&#8217;\u3001\u304a\u3088\u3073 &#8216;become_user&#8217;\u306e\u4f7f\u7528\u3092\u691c\u8a0e\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/span><\/div>\n<p>&nbsp;<\/p>\n<p>\u203b\u300c-s\u300d\u3092\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u4f7f\u7528\u3059\u308c\u3070sudo\u3068\u540c\u69d8\u306e\u6a29\u9650\u3067\u5b9f\u884c\u3067\u304d\u308b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 Ansible\u3092\u4f7f\u7528\u3057\u3066\u4ed6\u306e\u30b5\u30fc\u30d0\u30fc\u306baws cli\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u624b\u9806\u306b\u3064\u3044\u3066\u8a18\u8f09\u3057\u3066\u3044\u307e\u3059\u3002 &nbsp; \u624b\u9806 1.hosts\u3092\u7de8\u96c6\u3057\u307e\u3059\u3002 \u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002 sudo vi \/etc\/ansi&#8230;<\/p>\n","protected":false},"author":3,"featured_media":177,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_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":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[2,3],"tags":[60],"class_list":["post-120","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aws","category-linux","tag-ansible"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/logo-ansible.png","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pacZwp-1W","_links":{"self":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts\/120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/comments?post=120"}],"version-history":[{"count":10,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts\/120\/revisions"}],"predecessor-version":[{"id":1788,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts\/120\/revisions\/1788"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/media\/177"}],"wp:attachment":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/media?parent=120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/categories?post=120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/tags?post=120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}