- EC2にssm-agentをインストール
1 2 3 | $ sudo yum install https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm $ systemctl enable amazon-ssm-agent $ systemctl start amazon-ssm-agent |
- EC2にSSHの公開鍵を設定
- static_ec2.ini
1 2 3 4 5 6 7 8 9 10 | [instance] app01 ansible_host=i-xxxxxxxxxxx app02 ansible_host=i-xxxxxxxxxxx [all:vars] ansible_ssh_common_args=-o StrictHostKeyChecking=no -o ProxyCommand="sh -c \"aws --profile=hoge ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p'\"" ansible_user='hoge' ansible_port=xxxx ansible_become=true ansible_ssh_private_key_file='~/.ssh/conf.d/hoge' |
- hoge.yml
1 2 3 4 5 6 7 8 9 | - hosts: app01 roles: - hoge - hogehoge - hosts: app02 roles: - hoge - hogehoge |
- 実行
1 | $ ansible-playbook -i static_ec2.ini -l app01 hoge.yml |
Was this helpful?
0 / 0
1989年生まれのSRE。ホスティングから大規模なアドテクなどのインフラエンジニアとして携わる。現在はサービスの信頼性向上、DevOps、可用性、レイテンシ、パフォーマンス、モニタリング、オブザーバビリティ、緊急対応、AWS/Azureでのインフラ構築、Docker開発環境の提供、Kubernetes保守、インフラコード化、新技術の検証、リファクタリング、セキュリティ強化などを担当している。個人事業主では数社サーバー保守とベンチャー企業のSREインフラコンサルティングやMENTA/CloudTech Academyで未経験者にインフラのコーチング/コミュニティの運用を実施している。また、「脆弱性スキャナVuls」のOSS活動もしており、自称エバンジェリスト/技術広報/テクニカルサポート/コントリビュータでもある。