我目前正在使用AWS实例,并且希望将当前在AWS主节点上运行的所有配置传输到仅具有Ansible的多个AWS从属节点.从节点可以是2或3或可以更多.ansible-pull
当从属节点的"利用率"下降或上升时,模型是否可以自动扩展AWS实例?
如何分配节点的AWS群集?
虽然不是直接的答案,但在配置自动缩放的情况下,我使用Bootstrap Pattern.
将git存储库和ansible-vault的密钥放在S3上(由实例的IAM角色进行身份验证),并将playbooks放在git存储库中.
EC2实例的用户数据pip install ansible
,get secret key from S3
,get playbook from git repository
和execute ansible-playbook
.
如果有EC2实例的某个角色,则可以拆分S3目录和git路径.
自举机制使自动缩放过程更加简单.
Update01:样本
EC2用户数据样本(尚未测试,作为图像):
#!/bin/bash yum update -y pip install -y ansible aws s3 cp s3://mybucket/web/git_secret_key /root/.ssh/git_secret_key chmod 600 /root/.ssh/git_secret_key aws s3 cp s3://mybucket/web/config /root/.ssh/config chmod 600 /root/.ssh/config aws s3 cp s3://mybucket/web/ansible_vault_secret_key /root/ansible_vault_secret_key git clone git://github.com/foo/playbook.git ansible-playbook -i playbook/inventory/web playbook/web.yml --vault-password-file /root/ansible_vault_secret_key
s3:// mybucket/web/config示例:
Host github-bootstrap User git Port 22 HostName github.com IdentityFile /root/.ssh/git_secret_key TCPKeepAlive yes IdentitiesOnly yes
Update02:最简单的版本.(没有S3/ansible-vault)
EC2用户数据样本(尚未测试,作为图像):
#!/bin/bash yum update -y pip install -y ansible echo "YOUR GIT SECRET KEY" > /root/.ssh/git_secret_key chmod 600 /root/.ssh/git_secret_key cat << EOT > /root/.ssh/config Host github-bootstrap User git Port 22 HostName github.com IdentityFile /root/.ssh/git_secret_key TCPKeepAlive yes IdentitiesOnly yes EOT chmod 600 /root/.ssh/config git clone git://github.com/foo/playbook.git ansible-playbook -i playbook/inventory/web playbook/web.yml