Demo of Automated Microservices Infrastructure Setup using Ansible, Docker, Consul and the friends. Demo is tested and uses AWS cloud, but can be adapted for other clouds.
-
Install Ansible
- On OS-X you can just run:
sudo -H pip install --ignore-installed ansible - For other platforms consult with Ansible installation notes
- On OS-X you can just run:
-
Install docker-py:
sudo -H pip install docker-py -
Install jq (sed for JSON):
- On OS-X you can just run:
brew install jq - For other platforms consult with jq installation notes
- On OS-X you can just run:
-
Install and configure AWS CLI Tools
-
Install and configure Boto:
-
Installation: http://boto.readthedocs.org/en/latest/getting_started.html
On OS-X El Capitan, you will have to ignore
sixthat is pre-installed and causes issues:sudo -H pip install --ignore-installed boto -
Configuration of Boto/AWS credentials: http://boto.readthedocs.org/en/latest/getting_started.html#configuring-boto-credentials
-
Please note that there's currently a major bug in Ansible/
epc_vpcwhich ignores profile parameter and uses default credentials, so you need to make sure that your default AWS credentials point to the environment where you need things created.
-
-
Clone this repo with:
git clone https://github.com/apiacademy/microservices-deployment.git -
Go into the cloned repo and run the included ec2 script, to make sure you properly installed and configured Boto:
cd inventory && ./ec2.py --list --boto-profile irakli-aws && cd --Make sure to replace
irakli-awswith your AWS profile name from~/.aws/credentials. You can omit the option if you are using default profile from that file.Please also note that in the version of ec2.ini file we ship, for the sake of speed, we restrict the AWS regions the script works with to North America ones. If you need access to any other zone, or all zones: please edit the ec2.ini file accordingly.
-
Save a private SSH key that you use/will use the root user on your AWS servers under:
ssh/private-key.pem. For security reasons,sshfolder is .gitignore-d in the demo repo, and you should ignore it, as well, if you build on top of the demo. NEVER check-in SSH keys into repos!ATTENTION: corresponding public key must be placed under
roles/aws-server-creation/ssh/public-key.pem!!! -
Make sure your private key permissions are valid:
chmod 700 ssh chmod 600 ssh/* -
If you have some EC2 servers tagged with [key=Name, value=cademo_consuls], and the AWS credentials profile you are using is still `irakli-aws, then you can ping the tagged servers from Ansible with a command like:
AWS_PROFILE=irakli-aws ansible -i ec2.py tag_Name_cademo_consuls -m pingYou can find more information about ec2 script and using dynamic EC2 inventories at: https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/
-
Please make sure you set up proper AWS Profile in
group_vars/all.ymlunderaws_profilevariabe and then you can create required servers as easily as running:
To create all the servers:
AWS_PROFILE=irakli-aws ansible-playbook play-010-create-servers.ymlTo run the entire thing:
AWS_PROFILE=irakli-aws ansible-playbook play-all.ymlConsul logs are under: /var/log/upstart/consul.log
To see current members of Consul cluster:
consul members
To make sure that consul leadership election succeeded (bootstrapping), you can run the following on a consul server:
consul info
and analyze the raft: section of the response.
If you are on a network that doesn't allow access to custom port you can create an SSH proxy:
ssh -D 12345 myuser@remote_ssh_server
and then in your browser proxu settings indicate SOCKS5 proxy with hostname: localhost, port: 12345.