Auto-scale using AWS instances using Ansible-Pull with master and slave configuration

I am currently working with AWS instances and want to transfer the entire configuration that is currently running on the AWS master node to several AWS subordinate nodes with only Ansible. Slave nodes may be 2 or 3 or may be larger. Is it possible for the model to ansible-pullautomatically scale the AWS instance when the “Disposal” of the slave node goes down or up?

How can I assign an AWS cluster of nodes?

+4
source share
1 answer

, Bootstrap.

git ansible-vault S3 ( IAM ) 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
+5

Source: https://habr.com/ru/post/1621987/


All Articles