The following article was written for the FiveRuns blog. FiveRuns makes Ruby on Rails performance and monitoring tools. With the release of Dash, they’ve extended the tool set to include more frameworks and social networking integration. Very cool stuff.
A few additional notes on the article:
Some potential future enhancements:
The Original Article Follows:
Welcome to the third installment of configuration-automation, a Ruby on Rails environment setup script. We’ll take a remote Linux server from first boot to fully configured, live Rails application server with just a hostname and password. This version includes a menu of Rails applications to choose from and replaces the nginx/mongrel servers with Phusion Passenger. Four popular Rails applications: Radiant, Spree, jobberRails and El Dorado are available to be deployed automatically.
All you need is Capistrano and git installed on your *nix client to download and execute the scripts. On the remote server, Ubuntu 8.04 or 8.10 with ssh listening is supported, such as a Slicehost VM or VMWare image.
Using The Script
Just download the files from github and run:
An ssh connection to the Ubuntu server updates core system libraries and installs dependencies such as Ruby and MySQL. The Rails application chosen is deployed via Capistrano with a second ssh connection. Each connection requires the target server’s password or you can install an ssh key pair to skip those prompts.
To install additional Rails applications to the newly configured server, run configure_rails_apps.sh from the same ./configuration-automation directory. The main script can also be rerun from the same directory against other blank Ubuntu targets.
Why Do This?
With no DSL to learn or manifests to build, this is a fast, simple way to bootstrap a Rails server. I built it to test (and quickly retest) compatibility with FiveRuns Manage and TuneUp product updates. As such, it makes a decent acceptance test environment builder. It is also a way to experiment with a functioning Ruby on Rails app server without working through every installation issue.
It’s not intended to meet the meet the same needs as more powerful tools like Puppet, or now Chef, though you could easily add these after running configuration-automation. For EC2 environments, also check out Matt Conway’s cool Rubber Capistrano/Rails plugin.
The Rails app versions are frozen to today to ensure their project updates don’t break the automation. I’ll refresh these in later updates to configuration-automation. Suggestions and feedback are welcome via comments below or on my blog.
The next puzzle is a variation on the original: You see some food dangling out of reach. Can you get it?
To avoid the need for stacking furniture and yet keep the food out reach, I added elastic to hang the corn. Kite string is still from the corn to the ground so the food can be easily pulled within reach. I figured once the squirrels had the corn, they could eat it there or store in their cheeks, similar to the original puzzle. But the main goal of the squirrels is to take the prize with them, so another battle and some interesting videos ensued.
Since the elastic connects the corn to the hanger, it feels like like the whole cob can be taken away. It took a couple tries for the rock squirrel in the video above to learn to dine in, rather than take it to go. The tree squirrel of course never even tries to eat the corn on the spot. In classic form, he immediately begins to chew the elastic until it breaks. In one case, in the movie below left, it breaks but gets tangled as he tries to abscond. I added a length of wire above the corn and the squirrels both figured out quickly to pull the cob down and strip it clean in a few minutes, without taking it with them. (bottom right video)
I decided to try a challenge where the squirrels must extract the prize from inside something. I took a spare piece of PVC pipe and ran a shoe string through it. A steel washer is tied to the center of the string and the ends are secured on each side. There is loose corn and sunflower seeds inside. Pulling the string in either direction spills out some food, but it only works once. For a second helping, the string needs to be pulled in the opposite direction.
The problems with the puzzle are 1) the tree squirrel prefers to eat through anything directly vs. figuring out a puzzle and 2) the rock squirrel does not like getting up on things so much. So this ended up being a being a can-you-eat-through-the-puzzle challenge. (and he could) He is a rodent after all, so the teeth never stop growing and it didn’t take long for this to degrade into a big mess.
Welcome to the second FiveRuns blog post to automate server configuration for Ruby on Rails. We received great feedback and suggestions about the original script, Automatic Rails at Slicehost, which installed the basics. This time we’ll use standards like Capistrano deployment, separate web and application layers and an active database backend. While the Hello World application surely dazzled your friends and family, this time we’ll take it up a notch and deploy a working, full stack community web application, Trevor Turk’s cool Rails app, Eldorado.
This script connects to a new Ubuntu 8.04 server and configures all necessary applications and libraries. Since we are installing a lot more this time, it’s a bit long to post here, so I’ve linked to it on Github. You still only need to provide 2 pieces of information: the target address of your server and the password. Execute the script locally which downloads Eldorado, the associated configuration files and then connects to your server to push the installation.
The previous script installed:
This time we use:
1. Download the script from Github. I’ve abbreviated the URL.
wget http://tinyurl.com/57sjce -O configure_ubuntu_eldorado.sh
2. Run the script.
That’s it! You’ll be asked for your password twice, once to set up the OS via ssh and once to run the Capistrano deployment tasks. Speaking of passwords, best practices include dedicated deployment and MySQL user accounts. This script uses the root account for simplicity.
The script originated as a DRY effort for Slicehost deployments. You can now point it at other providers, remote Ubuntu servers or virtual machines. It’s become a handy way to explore a working Rails environment without manually installing every component. Also, writing configuration automation is a great way to hone your deployment skills. Thanks go to Trotter Cashion for the suggestion to maintain the scripts on Github, where they’ve been forked and extended. Check out Jørgen Orehøj Erichsen’s blog adding support for Passenger and Ruby Enterprise Edition.
All the scripts and configuration files are on Github so feel free to post any feedback or suggestions.
We decided to get a bird feeder to entertain our herd of cats. This is commonly referred to as cat TV by pet owners and ours were quickly transfixed, often huddling around the window staring at the cardinals, finches and pigeons. The visitors soon expanded to squirrels and raccoons who the cats found even more interesting to watch, so I next included some larger animal feed like nuts and deer corn. We’re enjoying the interaction between our four (yes four) indoor only cats and the animals that come right up to the windows to feed, play and now solve puzzles.
I saw years ago in England on television show that broadcast the intelligence and creativity of birds retrieving a nut from a contraption. It was basically a modified bird feeder with clear plastic, moveable dowels and the like. The small but tireless creatures learned to solve complex, multi-step puzzles in seconds. I think these were submitted as contest entries and the winners were given prized or shown on the finale or something. I say “I think” because I cannot find any record of these clips on Google, YouTube, the BBC web site, etc. If you recall the show, please send me an email and let me know I didn’t dream it.
I put out a bird feeder and the cats loved it. But we had other visitors and they were even more interesting.
Dinner Is Served
The squirrels could empty a feeder in just a few minutes, so deer corn was offered instead. To start, the corn was tied down with string, allowing dine in but not take out. The audience enjoyed the show and our new visitors seemed happy to star on HD cat TV.
I raised the corn cob off the ground to give our guests some exercise and because standing and jumping would be more interesting to the indoor audience.
This time, I raised the corn further off the ground and out of reach to a squirrel. I left string dangling below the corn so it could be tugged over to a nearby table. The corn could then be pulled over to the table for easy eating. Unfortunately, the tree squirrel found it just as easy to jump and hang on the corn cob long enough to knock a few kernels off. He’d then hop down and eat them off the ground. The rock squirrel (the one with a black front half) didn’t want to jump and didn’t take the string onto the table to pull over the corn. When I tied the string to the table so it only needed to be pulled on slightly to bring the corn into reach, the rock squirrel figured it out.
The Faculty Answers
To block the high jumping squirrel, I raised the corn completely out of reach. I stacked deck furniture and tied the string to the top so the corn could be pulled over. There was a plenty of slack in the string again though so it was not immediately apparent that pulling it would bring the food closer. The tree squirrel investigated option for quite a while, but could still make the jump from the table over to the corn cob and so again and bypassed the puzzle.
To incent our students to learn and not jump, I again shortened the string between the table and the corn. Any motion or tugging on the string would bring the corn closer and perhaps show how the food more is more easily eaten without jumping. At first, I didn’t notice any activity and thought the test was too hard. The tree squirrel soon yanked the line firmly and retrieved the corn cob in one pull. He enjoyed the entire cob himself. I’ve moved to half cobs now!
Give them some slack
I still want to see if the freshmen can gather up the string in order to retrieve the corn. They’ll need some faith because there is a lot of slack in the line, so they’ll be pulling up string for a while, before the corn moves closer. The rock squirrel did this earlier so I think they’ll step up. Also rock squirrels don’t climb much, so I may need to include puzzles closer to the ground to keep our class enrollment high. Ultimately, I’d like to see if the string can be left on ground, carried to the top platform and then used to retrieve dinner.
Hmmm. More hints?
I have not seen much progress in recent days so I’ve added some clues to the loose string. Peanuts are attached along the line to see if pulling at those will help them discover how to pull the corn over, too. Eighth Stage: Playing hooky To be fair, I have not been the best instructor, since starting the squirrel training courses this fall. The blog has not been updated in a while. This tree squirrel decided not to wait and learned to jump, balance and wait out the spinning long enough to have a nice meal of bird seed. Photo courtesy of Jackie.
I decided to move forward with different puzzles. Having the squirrels climb while holding the string seems a bit challenging, so far, as is stacking up furniture every day. Also, climbing favors the tree squirrel over the black rock squirrel who seems more interested in solving the challenges and less in cheating. Stay tuned for the next challenge…
Copyright © 2017 MarkPReynolds.com - All Rights Reserved