Provisioning EC2 instances
Here, we will be provisioning instances in us-west-1
, but depending on where you have your AWS instances set up, you will need to change your knife.rb
configuration to specify the region of your choice.
In order for them to communicate securely, we will construct a security group so that all traffic between them is permitted. This is outside the scope of this book, but it would be something to make sure you configure for production systems, as you probably do not want the public on the Internet to have direct access to your database server.
Here, we will assume that you have your AWS credentials and other critical components configured, as we covered in previous chapters.
To provision our database server, we will use the following command:
knife ec2 server create -d ubuntu14.04 -I ami-ee4f77ab -f m1.small -Z us-west-1a -S jewartec2 -N db00 --ssh-user ubuntu
And to provision the web server, we will use the following command:
knife ec2 server create -d ubuntu14.04 -I ami-ee4f77ab -f m1.small -Z us-west-1a -S jewartec2 -N web00 --ssh-user ubuntu
Once your instances are up and running, you can now move on to configuring them with the roles and configuration data required!
Configuring the database host
In order to apply the PostgreSQL role to our database host, we need to make sure it's in the run list. We can accomplish this with the following command:
knife node run_list add db00 "role[base_server]" knife node run_list add db00 "role[postgresql_server]"
After ensuring that your node has the base_server
and postgresql_server
roles added to the run list, you can run chef-client
on the newly created host:
[jewart]% knife ssh 'name:db00' -x ubuntu 'sudo chef-client'
Once this is complete, assuming that everything went well, your new EC2 instance will have:
Now that we have our database server configured, which can be verified by logging onto the server and ensuring that the service is running, let's take a look at setting up our web application.