by Michiel on May 18, 2010
I’ve heard a lot of stuff about Chef by Opscode some time ago but never actually gave it a try. Chef is a bundle of software that allows you to configure and install your servers by coding, not by entering commands. I fiddled with it one time but it was really hard to set up.
Because we’re launching our new server infrastructure on a new bigger Amazon instance in a fe days, I thought I’d give it a try.
The main reason I was looking for something like Chef was automation. In the past I would install every server manually and I didn’t have some predefined bash scripts for setting up a server, installing the base system and preconfigure Rails, PHP apps and things like backups. Chef allows me to do that now.
Our new server is going to run various apps. Our own website, some WordPress websites and mainly Ruby on Rails apps. Because we run some business-critical apps for our clients the server setup should be clean and certainly not hacked together, and we need external backups to S3 and be able to add another server to the pool when usage gets bigger – which is going to happen.
When you have Chef installed, you probably want to run a Chef Server and a Chef Client. The Chef Server keeps all the state of the server configuration for the configuration and installation scripts. The Chef Client actually reads the configuration and runs the script.
The chef clients runs multiple recipes that configure your server. For example, a recipe downloads apache or nginx via apt-get when you’re on Ubuntu, but could install an RPM if you are on an rpm-based distribution. The recipe is the actual script, but you can also store configuration attributes and download urls with the recipes. These little bundles of recipes and other configuration are called cookbooks.
We currently have the following cookbooks in our Chef repository:
Our Chef repository
Recipes can depend on other recipes from other cookbooks. For instance to install Phusion Passenger and nginx, I want to use the ruby_enterprise cookbook so it will first in stall the Phusion Ruby Enterprise Edition and then installes and configures nginx and passenger for it.
We use Scout App for monitoring the performance and usage of the instance and we use it so we receive warnings if something reaches critical numbers.
For Scout, I did not run the Scout agent as explained on their on website, but I created a recipe for it in the scout cookbook:
gem_package "scout" do
action :install
end
gem_package "request-log-analyzer" do
action :install
end
user "scout" do
comment "Scout Agent User"
home "/home/scout"
supports :manage_home => true
end
execute "scout_first_run" do
user "scout"
command "scout #{node[:scout][:key]}"
creates "/home/scout/.scout/client_history.yaml"
cwd "/home/scout"
returns 1
action :run
end
cron "scout_run" do
minute "*/5"
command "scout #{node[:scout][:key]}"
end
What this recipe does it that it installs the gem “scout” using the gem_package Chef command. It then goes on to create a new system user for scout, run the scout agent for the first time and actually adds a cronjob to run it every 5 minutes.
You can see the code is quite clean and it doesn’t look like a hacked-together bash script and it doesn’t look as closed down as some kind of configuration database or .ini file. They are nice Ruby recipe’s for configuring stuff on your server.
You can see that I’m using the node[] variable a few times. The node variable is a Ruby hash of the current configuration the server (or node) is in that the client is being run. Using the web interface on the Chef server you can actually configure per-server configuration values. In our case, the Scout key would be different for every server.
You can do a l it more with these recipes like defining templates for files, default attributes, generating passwords but I’ll save that for another post.
The best thing about the recipes is that I can also communicate with the AWS API. The application cookbook you see there actually creates an EBS block storage devices and attaches it to the current node if it is not already created.
Because all state is saved in the Chef Server configuration database you can easily add more block storage devices or other external stuff just by running the Chef Client. The Chef client probes the server for all the current state the client is in and goes on upgrading all the new changes the recipes requested.
The status page in the Chef Server webapp
by Michiel on April 21, 2010
Hi all,
I had some downtime today so I’m sorry if you could not access this blog to get help on all the topics I right about. Everything should be fixed now. There seemed to be an error with our hosting provider. I’m trying to see if it was something major or if it was just a minor glitch in the power or connectivity or something.
Anyways, back up now so enjoy!
Update: It seemed there was an administrative error with the supplier of my hosting provider. Will not happen again!
by Michiel on March 29, 2010
I started using Heroku three weeks ago since @_micho from teambox.com recommended it to me. He told me they had a free app tier with some basic functionality and you can upgrade if you need more power or other functionality.
I’ve been testing it for deploying several development and staging apps the last two weeks and Everyday Feed already runs on it in a production-kind-of way. I’ve come to a conclusion: always deploy your first deployment on Heroku.
So, why is this?
- Because Heroku is an app-based deployment service instead of an instance or server-based deployment service you can focus on the application and making it work, without having to worry about server installations, best deployment settings, software etc. You deploy your app on Heroku so you can fix your app, and not waste time on fixing your server.
- Heroku is totally Git-based so it will force you have a good Git-workflow right away, from the start of your first deploy. One of the advantages of using Git is of course that your code is in version management and you can easily manage various feature sets and rollback to previous deployments, but it’ll also help you right away when you get more team members.
- Heroku forces you to configure all your things that run around your app, like cronjobs, sending email, doing queuing and caching. Because Heroku forces you to work in a very automated and modular way you’ll never mess up your app’s code with external things. This make sure you configure everything nicely in external files or in the Heroku admin panel so you never hardcode things in your code.
- Heroku is free. Well at least the first database package they have (up to 5MB). I like this from a business point-of-view because you can also scope what you spend on Heroku with your income of the app. I have a simpel rule with Everyday Feed: I will not upgrade Heroku until the application has some users or advertisers that are paying. This way I make sure people want to pay for the core functionality and add extra features from there, when I can buy more power at Heroku.
Continue reading this post…
by Michiel on March 25, 2010
Everyday Feed started as a pet project about a week ago. I already scratched my own itch with building a service that actually let’s me read my feeds instead of skipping them. Also, this project is my way of researching and testing all the hints and tips I learned from Rework, Getting Real and Crush It.
I would really like you to test it, if the idea and functionality appeal to you. If not, you can of course also just give me feedback on design or copywriting topics if you’d like. I have some future ideas. For example I’d love to build a tablet-aware web app or an iPad app for reading the daily edition of your feed paper on mobile devices so that’s probably what I’m going to work on first. But if someone has a better idea, please let me know.
Head on over to everydayfeed.net, sign up and see if it’s useful for you. Thanks!
by Michiel on March 22, 2010
A little longer than two weeks ago, I talked about why the newspaper is going to rock, but that it’s not going to rock in it’s current form and that it’s not going to be owned by the big news companies.
In that post, my conclusion was that iPad/tablet-like devices are going to be the near future of consuming news. In my forecast of up to 5 years, I see a lot of people reading their news(papers) on a tablet while commuting, traveling, on the airplane, at the office, etc. I hope this will happen even sooner with the release of the iPad in a few weeks and of course, the other tablet devices.
But, I also want to contribute to a new way of consuming news – especially online blogs, news portals, magazines and other kind of feed-like services. Because building an iPad app is just one small step to far for me right now, today I’m announcing something else:
It is called Everyday Feed. It is a web service that allows you to read all the feeds you have like a newspaper. No, I don’t mean in a visual way but in an experience-kind of way: waking up, preparing breakfast, grabbing your newspaper along the ways and drinking some coffee. Everyday Feed will let you do that for your feeds.
Head over to the current website for more details at http://everydayfeed.net.
If you want a sneak preview, contact me directly via email, on Twitter or leave something in the comments.