{"id":18600326,"url":"https://github.com/shintaro-abe/ansible-userdata","last_synced_at":"2026-05-07T14:38:17.815Z","repository":{"id":166937481,"uuid":"642490429","full_name":"Shintaro-Abe/Ansible-userdata","owner":"Shintaro-Abe","description":"Userdata for using Ansible on EC2.Scripts to retrieve sample code from other repositories are also available.","archived":false,"fork":false,"pushed_at":"2023-05-24T08:29:16.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-16T15:50:32.807Z","etag":null,"topics":["ansible","aws","ec2","shellscript","userdata"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Shintaro-Abe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-18T17:28:01.000Z","updated_at":"2023-05-31T09:57:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"598a2d00-b961-401e-9465-a6900ac8be00","html_url":"https://github.com/Shintaro-Abe/Ansible-userdata","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"8a786de1bafe8da38956a235a1be61e93a926758"},"previous_names":["shintaro-abe/ansible-userdata"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Shintaro-Abe/Ansible-userdata","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shintaro-Abe%2FAnsible-userdata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shintaro-Abe%2FAnsible-userdata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shintaro-Abe%2FAnsible-userdata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shintaro-Abe%2FAnsible-userdata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shintaro-Abe","download_url":"https://codeload.github.com/Shintaro-Abe/Ansible-userdata/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shintaro-Abe%2FAnsible-userdata/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32742083,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","aws","ec2","shellscript","userdata"],"created_at":"2024-11-07T02:03:40.926Z","updated_at":"2026-05-07T14:38:17.784Z","avatar_url":"https://github.com/Shintaro-Abe.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ansible-userdata\n## 使用について\n\n* __AmazonLinux2023は非対応。AmazonLinux2での使用を推奨。__\n    * amazon-linux-extrasを使用するため。\n* __EC2のインスタンスプロファイルにIAMロールを設定。__\n    * リソースの作成に必要な権限を付与。\n    * パラメータ取得のため、` ssm:GetParameter `ポリシーが必要。 \n## スクリプトについて\n以下の流れでインストールを実施し、インスタンスへ初めてログインした段階でAnsibleを使用できる環境を構築。\n* __SystemsManager ParameterStoreからパラメータの取得__\n* __Ansibleのインストール__\n* __RegionとOutputの設定__\n* __ssh公開鍵と秘密鍵の生成__\n* __ansible-vaultによる鍵の暗号化__\n* __ansible.cfgの設定__\n* __ansibleディレクトリの作成__\n\n## コマンドについて\n* __権限の変更__\n    * root権限で実行する性質を持つため、ec2-userで実行したいコマンドには` sudo -u ec2-user -i `、もしくは` sudo -u ec2-user `をつけて一時的にユーザーを変更。\n\n* __SystemsManager ParameterStoreのパラメータ取得__\n    * variableに` ssm get-parameter `コマンドで取得した値が入るので、スクリプトでパラメータを参照する箇所に` $variable `の形式で記述。\n    * パラメータのタイプはString、SecureString関係なく使用可能。\n```\nvariable=$(aws ssm get-parameter --name \"parameter_name\" --with-decryption --region current_region  --output text --query Parameter.Value)\n```\n\n## playbookについて\nサンプルのデータもインストールする場合は、` sudo -u ec2-user -i mkdir ansible `の箇所を以下のコマンドへ修正して使用。\n```\nsudo -u ec2-user -i wget https://github.com/Shintaro-Abe/Ansible/archive/refs/heads/main.zip\nsudo -u ec2-user -i unzip main.zip\nsudo -u ec2-user -i rm main.zip\n```\nplaybookの実行は、Ansible-mainディレクトリへ移動の上、以下のコマンドを使用。\n```\nansible-playbook -i hosts.ini main.yml\n```\nデータについては、以下のリポジトリを参照。\n\n\u003ca href=\"https://github.com/Shintaro-Abe/Ansible.git\"\u003e\u003cimg src=\"https://img.shields.io/badge/ShintaroAbe/Ansible-181717.svg?logo=github\u0026style=flat-square\"\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshintaro-abe%2Fansible-userdata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshintaro-abe%2Fansible-userdata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshintaro-abe%2Fansible-userdata/lists"}