Customizing your Scalarium Cloud using Chef: Configuring the Clients
Now that we have the server in place, all we need to do is update our clients on every deployment or whenever something
changes in our cloud. We'll start by adding a new recipe called
configure.rb, which looks like this:
First we're fetching all the attributes from the deploy recipe, which is installed on all instances managed by
Scalarium. It sets quite a few defaults for every application in your cloud. Next we're iterating over all the
applications defined for the cloud. Normally, when you deploy an application from within Scalarium, we only deploy one
application at a time. Iterating over all the applications covers the use case of automatically deploying new instances
during their setup phase, which is an option for every instance and enabled by default.
Next we're defining a resource to restart Passenger, which is nothing more than touching a file in the application's tmp
directory. By specifying
action :nothing we'll make sure that it's not run just yet, we'll only run it if the
configuration has changed. You can see in the template definition that we're notifying this resource to run. Chef is
smart enough to figure out that it shouldn't be notified to run when the resulting configuration file hasn't changed.
Before we write the configuration with the template resource we first pick out the active Redis server from the cloud
setup (see line 10), which we then hand over to the template as a variable named
:host. That way it's accessible
inside the template like this, using the notation
Now that we have the recipe ready, all that's left to do is tell Scalarium to run this recipe on the "configure" and
"deploy" events. That way the configuration can be updated whenever an application is deployed, or when e.g. the Redis server is restarted with a new configuration and new IP address.
After you've configured the custom recipes, add the
redis Rubygem as a dependency for the "Rails Application Server"
role and fire up the instance.
Next step: Deploying an Application
Or go back to Overriding Default Attributes
- Tutorial: Customizing your Scalarium Cloud using Chef
- Customizing your Scalarium Cloud using Chef: The Scalarium Lifecycle System
- Customizing your Scalarium Cloud using Chef: Cooking with Chef
- Customizing your Scalarium Cloud using Chef: Writing a Cookbook to set up Redis
- Customizing your Scalarium Cloud using Chef: Configuring Custom Cookbooks
- View all (4 more)