You’d think at this point I’d just look for that file and find out for myself… The little things are killing me right now… Thank you for those links. They should help me simplify the code .
I’m going to create a forked repo of Bedrock-Ansible with the ec2.py and ec2.ini scripts included, along with detailed instructions on how to easily deploy to either a single Amazon EC2 Instance, or an Auto Scaling Group. The beauty of doing it this way is, even if you were to start with a single instance, if your site ever gets big and has a spike in traffic, you’re already set up to expand just by creating more instances with the same tag that you defined. Nothing else to change or set up at all.
For anyone else that might be interested in what this accomplishes without having to look over the other 25 replies in this thread, heres an example-
So, the Amazon EC2 Instances for the site I’m building all have a tag attached to them to distinguish them from other Instances for other sites. I used the tag “Site = Nameofthesite” in this case. You can add multiple tags to further refine things. It doesn’t matter what the tag is, its just a way to tell Ansible what Instances you’d like to provision/deploy to. It also doesn’t matter how many Instances you have, or how many are created in the future, as long as they have the tag(s) you defined, the script will find the correct ones and allow you to provision or deploy to them without having to enter individual details about each one.
In my case, right now I have two EC2 Instances created to start, with the “Site = Mysitename” tag given to both within AWS. Without having to input any other details about them within Bedrock-Ansible, when I run ansible-playbook -i ec2.py server.yml
it automatically finds the IP’s of all the Instances with the tag I defined and provisions them. Its cool in the way that when it provisions or deploys, it performs each step on all of the Instances at the same time, so you can easily see the progress, like this-
TASK: [php | Add PHP 5.6 PPA] *************************************************
ok: [52.7.246.149]
changed: [52.7.246.150]
TASK: [php | Install PHP 5.6] *************************************************
ok: [52.7.246.149] => (item=php5-common,php5-fpm,php5-mysqlnd,php5-xmlrpc,php5-mcrypt,php5-curl,php5-gd,php5-cli,php-pear,php5-dev,php5-imap)
changed: [52.7.246.150] => (item=php5-common,php5-fpm,php5-mysqlnd,php5-xmlrpc,php5-mcrypt,php5-curl,php5-gd,php5-cli,php-pear,php5-dev,php5-imap)
TASK: [php | Start php5-fpm service] ******************************************
ok: [52.7.246.150]
ok: [52.7.246.149]
You can see in the example above that the Instance with the IP ending in .149 already had PHP installed, so it outputted “ok”, whereas the IP ending in .150 didn’t have it installed yet, so it was “changed”. This is great, as I don’t have to worry about excluding Instances that have already been provisioned. When new Instances are created automatically within an Auto Scaling Group, all I have to do is run the command again, and it will provision those that need it, or update anything I might of changed on others. I could even set up a Bootstrap script, or an Automation to do this automatically when new Instances are spun up in the Auto Scaling Group to ensure they have they have the latest provisioning right off the bat. I’ll be adding this step to my workflow for sure.
If you’re interested in provisioning or deploying Bedrock to an AWS Auto Scaling Group, or even just a single EC2 Instance, this is a fantastic route to take. I have a few kinks to work out in order to simplify and enhance some of my code, but like I said, I’m going to upload a forked version of Bedrock-Ansible with all the necessary scripts and settings, along with detailed instructions on how to set it all up. I’ll be sure to post a link.
Scott, I really can’t thank you enough… You have no idea how much you’ve helped me, and how much this will continue to help me. The project I needed to create this for is my biggest client to date. I couldn’t rely on my old way of deploying, and I wanted to have a rock solid workflow set up from the beginning to prevent having to change things later. The fact that you took the amount of time you did to guide me through this over the last 24 hrs says a lot about you and the Roots team as a whole. In all, this proves just how amazingly flexible and adaptable Bedrock/Bedrock-Ansible really is.
-P.J.