{"id":979,"date":"2024-10-28T08:55:12","date_gmt":"2024-10-27T23:55:12","guid":{"rendered":"https:\/\/race-ss.co.jp\/blog\/?p=979"},"modified":"2025-12-17T19:32:52","modified_gmt":"2025-12-17T10:32:52","slug":"ansible%e3%81%a7compute-engine%e3%81%ae%e5%88%9d%e6%9c%9f%e6%a7%8b%e7%af%89%e4%bd%9c%e6%a5%ad%e3%82%92%e8%87%aa%e5%8b%95%e5%8c%96%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/race-ss.co.jp\/blog\/?p=979","title":{"rendered":"Ansible\u3067Compute Engine\u306e\u521d\u671f\u69cb\u7bc9\u4f5c\u696d\u3092\u81ea\u52d5\u5316\u3059\u308b"},"content":{"rendered":"\n<p>\u3053\u3093\u306b\u3061\u306f\u3001RSS\u3067\u30af\u30e9\u30a6\u30c9\u57fa\u76e4\u3092\u62c5\u5f53\u3057\u3066\u3044\u308bH.D\u3067\u3059\u3002<br>\u5f0a\u793e\u3067\u306f\u3001 Compute Engine \u306e\u69cb\u7bc9\u4f5c\u696d\u3092\u884c\u3046\u969b\u3001\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30fb\u8a2d\u5b9a\u3092\u624b\u52d5\u3067\u884c\u3063\u3066\u3044\u307e\u3057\u305f\u3002<br>\u3057\u304b\u3057\u3001\u6700\u8fd1 Ansible \u3092\u5c0e\u5165\u3057\u3066\u521d\u671f\u69cb\u7bc9\u306e\u4f5c\u696d\u3092\u81ea\u52d5\u5316\u3057\u307e\u3057\u305f\u3002<br>\u4eca\u56de\u306fCompute Engine\u306e\u521d\u671f\u69cb\u7bc9\u4f5c\u696d\u3092\u81ea\u52d5\u5316\u3059\u308b\u307e\u3067\u306e\u624b\u9806\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Ansible \u3068\u306f<\/h2>\n\n\n\n<p>Ansible \u306f\u3001\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u306e\u69cb\u6210\u7ba1\u7406\u30c4\u30fc\u30eb\u306e\uff11\u7a2e\u3067\u3059\u3002<br>\u69cb\u6210\u7ba1\u7406\u30c4\u30fc\u30eb\u3068\u306f\u3001\u4e8b\u524d\u306b\u7528\u610f\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u3082\u3068\u306b\u3057\u3066\u3001\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3084\u30b5\u30fc\u30d0\u30fc\u306e\u8a2d\u5b9a\u5909\u66f4\u3092\u81ea\u52d5\u3067\u5b9f\u884c\u3067\u304d\u308b\u30c4\u30fc\u30eb\u306e\u3053\u3068\u3067\u3059\u3002<\/p>\n\n\n\n<p>Ansible \u3068\u3088\u304f\u6bd4\u8f03\u3055\u308c\u308b\u30c4\u30fc\u30eb\u3068\u3057\u3066\u3001\u300cChef\u300d\u300cPuppet\u300d\u304c\u6319\u3052\u3089\u308c\u307e\u3059\u304c\u3001<br>Ansible \u306f\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u5fc5\u8981\u3068\u305b\u305a\u3001<br>\u51e6\u7406\u3092\u884c\u3044\u305f\u3044\u30b5\u30fc\u30d0\u30fc\u306bSSH\u63a5\u7d9a\u304c\u3067\u304d\u308b\u74b0\u5883\u3092\u7528\u610f\u3059\u308c\u3070\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305f\u3001\u300cChef\u300d\u306fRuby\u3001\u300cPuppet\u300d\u306f\u72ec\u81ea\u306e\u8a00\u8a9e\u3067\u69cb\u6210\u30d5\u30a1\u30a4\u30eb\u3092\u8a18\u8ff0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u304c\u3001Ansible\u306fYAML\u3092\u4f7f\u7528\u3057\u3066Playbook \u3068\u547c\u3070\u308c\u308b\u30d5\u30a1\u30a4\u30eb\u306b\u51e6\u7406\u5185\u5bb9\u3092\u8a18\u8ff0\u3059\u308b\u306e\u3067\u3001<br>\u51e6\u7406\u3057\u305f\u5185\u5bb9\u304c\u308f\u304b\u308a\u3084\u3059\u304f\u3001\u5b66\u7fd2\u30b3\u30b9\u30c8\u304c\u4f4e\u3044\u3053\u3068\u304c\u30e1\u30ea\u30c3\u30c8\u3067\u3059\u3002<br>\u4e00\u65b9\u3067\u3001YAML\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u305f\u3081\u306b\u8907\u96d1\u306a\u51e6\u7406\u3092\u66f8\u304d\u3065\u3089\u304f\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5c0e\u5165\u3057\u305f\u80cc\u666f<\/h2>\n\n\n\n<p>\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u69cb\u7bc9\u3092\u884c\u3046\u969b\u3001<br>\u624b\u52d5\u3067\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3084\u8a2d\u5b9a\u5909\u66f4\u3092\u3059\u308b\u3068\u6642\u9593\u304c\u304b\u304b\u308a\u307e\u3059\u3002<br>\u307e\u305f\u3001\u4f5c\u696d\u624b\u9806\u66f8\u306f\u5b58\u5728\u3059\u308b\u3082\u306e\u306e\u4eba\u304c\u4f5c\u696d\u3059\u308b\u305f\u3081\u3001\u4eba\u7684\u30df\u30b9\u304c\u767a\u751f\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<br>\u5b9f\u969b\u306b\u3001\u300c\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u9055\u3046\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u305f\u300d\u300c\u30b5\u30fc\u30d3\u30b9\u81ea\u52d5\u8d77\u52d5\u306e\u6709\u52b9\u5316\u30fb\u7121\u52b9\u5316\u304c\u793e\u5185\u6a19\u6e96\u901a\u308a\u306e\u8a2d\u5b9a\u306b\u306a\u3063\u3066\u3044\u306a\u304b\u3063\u305f\u300d<br>\u306a\u3069\u306e\u5f0a\u5bb3\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u305d\u3053\u3067\u69cb\u6210\u7ba1\u7406\u30c4\u30fc\u30eb\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30fb\u8a2d\u5b9a\u306e\u81ea\u52d5\u5316\u3092\u884c\u3044\u3001\u4f5c\u696d\u52b9\u7387\u306e\u5411\u4e0a\u3068\u4eba\u7684\u30df\u30b9\u3092\u306a\u304f\u3059\u3053\u3068\u3092\u76ee\u6307\u3057\u307e\u3057\u305f\u3002<br><br>\u69cb\u6210\u7ba1\u7406\u30c4\u30fc\u30eb\u306e\u4e2d\u3067Ansible\u3092\u9078\u3093\u3060\u7406\u7531\u3068\u3057\u3066\u306f\u3001<br>\u4ee5\u4e0b\uff13\u70b9\u304c\u6319\u3052\u3089\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u521d\u671f\u69cb\u7bc9\u306e\u307b\u3068\u3093\u3069\u304c\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u3042\u308a\u3001\u8907\u96d1\u306a\u51e6\u7406\u304c\u4e0d\u8981\u3067\u3042\u308b\u3002<\/li>\n\n\n\n<li>\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30fb\u8a2d\u5b9a\u304c\u4e0d\u8981\u3067\u3042\u308a\u3001\u5c0e\u5165\u30b3\u30b9\u30c8\u304c\u4f4e\u3044\u3002<\/li>\n\n\n\n<li>YAML\u3067\u306e\u8a18\u8ff0\u3067\u3042\u308b\u305f\u3081\u3001\u793e\u5185\u3067\u7406\u89e3\u3067\u304d\u308b\u4eba\u304c\u591a\u3044\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u74b0\u5883\u60c5\u5831<\/h2>\n\n\n\n<p>Anbile core 2.15.9<br>Python 3.10.12<br>pip 22.0.2<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u69cb\u6210\u56f3<\/h2>\n\n\n\n<p>\u307e\u305a\u3001Google Cloud \u3067 Ansible\u7528\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<br>\u305d\u306e\u5f8c\u3001Ansible\u7528\u306e\u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u5272\u308a\u5f53\u3066\u305f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u69cb\u7bc9\u3057\u3001\u305d\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306bAnsible\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>Ansible\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304b\u3089\u5bfe\u8c61\u3068\u306a\u3063\u3066\u3044\u308b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u63a5\u7d9a\u3059\u308b\u305f\u3081\u306b\u3001SSH\u30d7\u30ed\u30c8\u30b3\u30eb\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<br>\u5f0a\u793e\u3067\u306fGoogle Cloud \u3067\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u300cIdentity-Aware Proxy\uff08IAP\uff09\u300d\u3068\u3044\u3046\u30b5\u30fc\u30d3\u30b9\u3092\u5229\u7528\u3057\u3066Compute Engine\u3092\u4fdd\u8b77\u3057\u3066\u3044\u307e\u3059\u3002<br>\u305d\u306e\u305f\u3081\u3001Ansible \u30b5\u30fc\u30d3\u30b9 \u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u8a8d\u8a3c\u3055\u305b\u3066\u304b\u3089\u5bfe\u8c61\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u63a5\u7d9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"860\" height=\"467\" src=\"https:\/\/race-ss.co.jp\/blog\/wp-content\/uploads\/2024\/10\/image-1.png\" alt=\"\" class=\"wp-image-988\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8b\u524d\u6e96\u5099<\/h2>\n\n\n\n<p>\u305d\u308c\u3067\u306f\u3001\u4eca\u56de\u306e\u69cb\u6210\u3067Ansible \u3092\u4f7f\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u304d\u307e\u3059\u3002<br>\u63a5\u7d9a\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a\u3053\u3068\u306f\u4ee5\u4e0b\uff14\u3064\u3067\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ansible \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/li>\n\n\n\n<li>Ansible\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/li>\n\n\n\n<li>\u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u306b\u5bfe\u3057\u3066IAM\u306e\u8a2d\u5b9a<\/li>\n\n\n\n<li>Ansible\u30d5\u30a1\u30a4\u30eb\u306e\u8a2d\u5b9a<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Ansible \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n\n\n\n<p>\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3060\u3051\u306a\u306e\u3067\u3001\u5177\u4f53\u7684\u306a\u30b3\u30de\u30f3\u30c9\u306f\u7701\u7565\u3057\u307e\u3059\u3002<br>\u304a\u4f7f\u3044\u306eOS\u306b\u5408\u308f\u305b\u3066\u4ee5\u4e0b\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u53c2\u8003\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.ansible.com\/ansible\/2.9_ja\/installation_guide\/intro_installation.html\">https:\/\/docs.ansible.com\/ansible\/2.9_ja\/installation_guide\/intro_installation.html<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Ansible \u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n\n\n\n<p>Ansible \u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3068\u3057\u3066\u3001<br>\u30af\u30e9\u30a6\u30c9\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u3001<br>Dynamic Inventory \u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u63a8\u5968\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>Ansible \u3092\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u3060\u3051\u3067\u306f\u3001Dynamic Inventory \u3092 Google Cloud \u3067\u4f7f\u7528\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002<br>\u4f7f\u7528\u3059\u308b\u305f\u3081\u306b\u306f\u3001Google Cloud\u306b\u63a5\u7d9a\u3059\u308b\u305f\u3081\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001\u305d\u308c\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305a\u3001\u4e8b\u524d\u6e96\u5099\u3068\u3057\u3066\u3001<br>\u305d\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306b\u3001Python\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install requests google-auth<\/code><\/pre>\n\n\n\n<p>\u305d\u306e\u5f8c\u3001Google Cloud\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ansible-galaxy collection install google.cloud<\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/collections\/google\/cloud\/gcp_compute_inventory.html\">https:\/\/docs.ansible.com\/ansible\/latest\/collections\/google\/cloud\/gcp_compute_inventory.html<\/a><br><a href=\"https:\/\/docs.ansible.com\/ansible\/2.9_ja\/scenario_guides\/guide_gce.html\">https:\/\/docs.ansible.com\/ansible\/2.9_ja\/scenario_guides\/guide_gce.html<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u306b\u5bfe\u3057\u3066IAM\u306e\u8a2d\u5b9a<\/h3>\n\n\n\n<p>Ansible \u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u5bfe\u8c61\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u3001\u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u306bIAM\u3092\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306f\u4e8b\u524d\u5b9a\u7fa9\u30ed\u30fc\u30eb\u3092\u4f7f\u7528\u3057\u3001\u4e0b\u8a18\uff14\u3064\u306e\u30ed\u30fc\u30eb\u3092\u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u306b\u4ed8\u4e0e\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>IAP\u3067\u4fdd\u8b77\u3055\u308c\u305f\u30c8\u30f3\u30cd\u30eb\u30e6\u30fc\u30b6\u30fc<\/li>\n\n\n\n<li>Compute \u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u95b2\u89a7\u8005<\/li>\n\n\n\n<li>Compute OS \u7ba1\u7406\u8005\u30ed\u30b0\u30a4\u30f3<\/li>\n\n\n\n<li>\u30b5\u30fc\u30d3\u30b9 \u30a2\u30ab\u30a6\u30f3\u30c8 \u30e6\u30fc\u30b6\u30fc<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Ansible\u30d5\u30a1\u30a4\u30eb\u306e\u8a2d\u5b9a<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u6210<\/h4>\n\n\n\n<p>\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u6210\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"248\" height=\"279\" src=\"https:\/\/race-ss.co.jp\/blog\/wp-content\/uploads\/2024\/10\/image.png\" alt=\"\" class=\"wp-image-987\" style=\"width:210px;height:auto\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">ansible.conf<\/h4>\n\n\n\n<p>inventory \u306b\u8a18\u8ff0\u3057\u3066\u3044\u308b\u300cenable_plugins\u300d\u306f\u3001Google Cloud\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306b\u5fc5\u9808\u3067\u66f8\u304b\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<br>\u305d\u308c\u4ee5\u5916\u306e\u8a18\u8ff0\u306f\u5fc5\u9808\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306f\u3001\u5171\u901a\u306e\u51e6\u7406\u3092\u8a18\u8ff0\u3059\u308b\u300ccommon\u300d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306bPlaybook\u3092\u914d\u7f6e\u3057\u3066\u3044\u308b\u305f\u3081\u3001<br>\u300cdefaults\u300d\u3067\u30d1\u30b9\u3092\u901a\u3059\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;defaults]<br>roles_path = ..\/common\/roles<br><br>&#91;inventory]<br>enable_plugins = gcp_compute<br><br>&#91;ssh_connection]<br>private_key_file = ~\/.ssh\/your_key<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">gcp.yml<\/h4>\n\n\n\n<p>\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3067\u306f\u3001\u300cauth_kind\u300d\u306b\u300cserviceaccount\u300d\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001<br>\u4eca\u56de\u306f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u5272\u308a\u5f53\u3066\u305fAnsible\u7528\u306e\u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u4f7f\u7528\u3057\u305f\u3044\u305f\u3081\u3001<br>\u300cauth_kind\u300d\u306f\u300cmachineaccount\u300d\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>plugin: gcp_compute<br>#GCP\u30d7\u30ed\u30b8\u30a7\u30af\u30c8ID<br>projects:<br>&nbsp;&nbsp;- test-project<br>auth_kind: machineaccount<br>groups:<br>&nbsp;&nbsp;gce_instance: yes<br>service_account_email: default<br>hostnames:<br>&nbsp;&nbsp;- name<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">group_vars\/all.yml<\/h4>\n\n\n\n<p>Ansible \u306b\u306f\u3001 group \u3068\u3044\u3046\u8003\u3048\u65b9\u304c\u3042\u308a\u3001<br>Playbook \u3092\u5b9f\u884c\u3059\u308b\u5bfe\u8c61\u306e\u30b5\u30fc\u30d0\u30fc\u3092\u30b0\u30eb\u30fc\u30d7\u5316\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br>group_vars \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306f\u3001\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u305f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u7279\u5b9a\u306e\u5909\u6570\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br>\u4eca\u56de\u306f\u5168\u3066\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u5bfe\u3057\u3066\u5171\u901a\u3067\u4f7f\u7528\u3059\u308b\u5909\u6570\u3092\u8a2d\u5b9a\u3057\u305f\u3044\u305f\u3081\u3001<br>all.yml \u3092\u4f5c\u6210\u3057\u3001\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u300cansible_ssh_common_args\u300d\u300cansible_connection\u300d\u306fIAP\u306e\u4fdd\u8b77\u304c\u304b\u304b\u3063\u3066\u3044\u308b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306bSSH\u63a5\u7d9a\u3092\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u3067\u3059\u3002<br>\u305d\u308c\u4ee5\u5916\u306f\u3001\u4f7f\u7528\u3057\u3066\u3044\u308b\u74b0\u5883\u306b\u5408\u308f\u305b\u3066\u8a2d\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ansible_ssh_common_args: \"-o ProxyCommand='gcloud compute start-iap-tunnel {{ inventory_hostname }} 22 --listen-on-stdin --zone {{ zone }} --project {{ hostvars&#91;inventory_hostname]&#91;'project'] }}'\"<br>ansible_connection: ssh<br>ansible_user: \"Ansible Service Account User\"<br>ansible_ssh_private_key_file: ~\/.ssh\/your_key<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">host_vars<\/h4>\n\n\n\n<p>host_vars \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306f\u3001\u63a5\u7d9a\u3059\u308b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u5bfe\u3057\u3066\u500b\u5225\u3067\u5909\u6570\u3092\u5272\u308a\u5f53\u3066\u308b\u3068\u304d\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<br>\u4eca\u56de\u306f\u3001\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068\u304d\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u6307\u5b9a\u3067\u4e00\u90e8\u4f7f\u7528\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u63a5\u7d9a\u78ba\u8a8d<\/h3>\n\n\n\n<p>\u57fa\u672c\u7684\u306b\u3069\u3093\u306aPlayBook\u3092\u7528\u610f\u3057\u3066\u3082\u554f\u984c\u306a\u3044\u306e\u3067\u3059\u304c\u3001<br>\u4eca\u56de\u306f\u300cconnection_test.yml\u300d\u3068\u3044\u3046 Playbook \u306b ls \u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3059\u308b \u51e6\u7406\u3092\u8a18\u8ff0\u3057\u3066\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">connection_test.yml<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>- hosts: all<br>&nbsp;&nbsp;roles:<br>&nbsp;&nbsp;&nbsp;&nbsp;- role: connection_test<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">roles\/connection_test<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>- name: ls command<br>&nbsp;&nbsp;ansible.builtin.command:<br>&nbsp;&nbsp;&nbsp;&nbsp;cmd: ls<\/code><\/pre>\n\n\n\n<p>\u63a5\u7d9a\u78ba\u8a8d\u304c\u3067\u304d\u3001\u7121\u4e8b\u306b ls \u30b3\u30de\u30f3\u30c9\u304c\u5b9f\u884c\u3067\u304d\u3066\u3044\u308c\u3070\u3001<br>\u3042\u3068\u306f\u81ea\u52d5\u5316\u3057\u305f\u3044\u51e6\u7406\u3092 Playbook \u306b\u8a18\u8ff0\u3057\u3066\u3044\u304f\u3060\u3051\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u3053\u3067\u306f\u8aac\u660e\u3057\u307e\u305b\u3093\u304c\u3001<br>\u300c\u30ed\u30fc\u30eb\u300d\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u51e6\u7406\u3092\u518d\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u3001\u3088\u308a\u7ba1\u7406\u3057\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u793e\u5185\u3067\u884c\u3063\u305f\u81ea\u52d5\u5316\u4e8b\u4f8b<\/h2>\n\n\n\n<p>\u6700\u5f8c\u306b\u3001\u793e\u5185\u3067\u7528\u610f\u3057\u305fPlaybook\u306e\u4e00\u89a7\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<br>\u793e\u5185\u3067\u306f\u3001\u521d\u671f\u69cb\u7bc9\u6642\u306b\u4ee5\u4e0b\u306e\u4f5c\u696d\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30fb\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3084\u76e3\u8996\u95a2\u9023\u306e\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304a\u3088\u3073\u8a2d\u5b9a<br>\u30fbgcsfuse \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<br>\u30fb\u30bf\u30a4\u30e0\u30be\u30fc\u30f3\u306e\u8a2d\u5b9a<br>\u30fb\u518d\u8d77\u52d5<br>\u30fbWeb \u30b5\u30fc\u30d0\u30fc\u30bd\u30d5\u30c8\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<br>\u30fbGit, PHP \u7b49\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n\n\n\n<p>\u4ee5\u524d\u306f\u521d\u671f\u69cb\u7bc9\u4f5c\u696d\u306b30\u5206\u301c1\u6642\u9593\u7a0b\u5ea6\u304b\u304b\u3063\u3066\u3044\u307e\u3057\u305f\u304c\u3001<br>\u3053\u308c\u3089\u306e Playbook \u3092\u7528\u610f\u3059\u308b\u3053\u3068\u3067\u3001\u300chost_vars\u300d\u3067\u5909\u6570\u3055\u3048\u8a2d\u5b9a\u3059\u308c\u3070\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u4f5c\u696d\u304c\u5b8c\u4e86\u3057\u3001\u5b9f\u4f5c\u696d\u6642\u9593\u306f10\u5206\u7a0b\u5ea6\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7d42\u308f\u308a\u306b<\/h2>\n\n\n\n<p>\u6700\u5f8c\u307e\u3067\u8aad\u3093\u3067\u304f\u3060\u3055\u3063\u3066\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\u3002<br>\u793e\u5185\u3067\u306f\u307e\u3060\u307e\u3060\u81ea\u52d5\u5316\u3067\u304d\u308b\u3082\u306e\u304c\u591a\u304f\u3042\u308b\u3068\u611f\u3058\u3066\u3044\u308b\u306e\u3067\u3001<br>\u4eca\u5f8c\u306f\u521d\u671f\u69cb\u7bc9\u3060\u3051\u3067\u306a\u304f\u3044\u308d\u3044\u308d\u3068\u30c1\u30e3\u30ec\u30f3\u30b8\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<a href=\"https:\/\/race-ss.co.jp\/\" class=\"corp-link-btn\" target=\"_blank\" rel=\"noopener\">\n  <div class=\"corp-link-img\">\n    <img decoding=\"async\" src=\"https:\/\/race-ss.co.jp\/blog\/wp-content\/uploads\/2025\/11\/\u30a8\u30f3\u30b8\u30cb\u30a2\u52df\u96c6\u753b\u50cf-2.jpg\">\n  <\/div>\n  <div class=\"corp-link-text\">\n    <div class=\"corp-link-title\">\u30a8\u30f3\u30b8\u30cb\u30a2\u52df\u96c6\u4e2d\uff01<\/div>\n    <div class=\"corp-link-desc\">\n      \u30ec\u30a4\u30b9\u30b7\u30b9\u30c6\u30e0\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u30ba\uff08\u30b3\u30fc\u30dd\u30ec\u30fc\u30c8\u30b5\u30a4\u30c8\uff09\n    <\/div>\n  <\/div>\n<\/a>\n\n<div class=\"contact-section-compact\">\n  <p class=\"contact-compact-text\">\n    \u30ec\u30a4\u30b9\u30b7\u30b9\u30c6\u30e0\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u30ba\u682a\u5f0f\u4f1a\u793e\u306e\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u958b\u767a\u3084\u3001<br>\n    \u63a1\u7528\u306b\u95a2\u3059\u308b\u304a\u554f\u3044\u5408\u308f\u305b\u306b\u3064\u3044\u3066\u306f\u3001\u4e0b\u8a18\u306e\u30ea\u30f3\u30af\u306b\u3066\u304a\u554f\u3044\u5408\u308f\u305b\u304f\u3060\u3055\u3044\u3002\n  <\/p>\n  \n  <a href=\"https:\/\/docs.google.com\/forms\/d\/e\/1FAIpQLSdZuEol6gkLjICDDsr9JsYTjmJMOllj7ew4aQZOilqQinCuzw\/viewform\" class=\"contact-compact-btn\" target=\"_blank\" rel=\"noopener\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"currentColor\" style=\"margin-right:8px; vertical-align:middle;\">\n      <path d=\"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z\"\/>\n    <\/svg>\n    \u304a\u554f\u3044\u5408\u308f\u305b\n  <\/a>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3001RSS\u3067\u30af\u30e9\u30a6\u30c9\u57fa\u76e4\u3092\u62c5\u5f53\u3057\u3066\u3044\u308bH.D\u3067\u3059\u3002\u5f0a\u793e\u3067\u306f\u3001 Compute Engine \u306e\u69cb\u7bc9\u4f5c\u696d\u3092\u884c\u3046\u969b\u3001\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30fb\u8a2d\u5b9a\u3092\u624b\u52d5\u3067\u884c\u3063\u3066\u3044\u307e\u3057\u305f\u3002\u3057\u304b\u3057\u3001\u6700\u8fd1 Ansible \u3092\u5c0e\u5165\u3057\u3066\u521d\u671f [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":984,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"footnotes":""},"categories":[168,35],"tags":[50,53,51,169],"class_list":["post-979","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ci-cddevops","category-35","tag-ansible","tag-gcp","tag-iac","tag-169"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/979","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=979"}],"version-history":[{"count":6,"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/979\/revisions"}],"predecessor-version":[{"id":1514,"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/979\/revisions\/1514"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/media\/984"}],"wp:attachment":[{"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=979"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=979"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}