我目前正在处理AWS实例,并且希望将当前运行在AWS主节点上的所有配置转移到多个只有Ansible的AWS从节点。从节点可以是2或3或更多。当从节点的“利用率”下降或上升时,ansible-pull模型能够自动缩放AWS实例吗?
如何分配节点的AWS群集?
发布于 2015-12-28 19:37:35
虽然这不是一个直接的答案,但在配置自动缩放的情况下,我使用引导模式。
在S3 (通过实例的IAM角色验证)上放置git存储库和ansible- role的密钥,并将剧本放在git存储库上。
EC2实例的用户数据为pip install ansible、get secret key from S3、get playbook from git repository和execute ansible-playbook。
如果存在EC2实例的某些角色,则可以拆分S3目录和git路径。
自举机构使自动刻度过程更简单.
Update01: Sample
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_keys3://mybucket/web/config示例:
Host github-bootstrap
User git
Port 22
HostName github.com
IdentityFile /root/.ssh/git_secret_key
TCPKeepAlive yes
IdentitiesOnly yesUpdate02:最简单的版本。(无S3/无保险库)
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.ymlhttps://stackoverflow.com/questions/34497447
复制相似问题