#2 new
Ryan C. Creasey

Global Variable Support In Packages

Reported by Ryan C. Creasey | March 20th, 2009 @ 03:55 AM

Perhaps I'm treating Packages in the same fashion as a Capistrano recipe, but it seems that any variable set in my deploy.rb config file with 'set :foobar, "foobaz"' do not seem to be in scope when in a package definition.


set :foobar, 'foobaz'

package :some_package do
  source "somefile.tgz" do
    prefix "/usr/local/#{foobar}"

The package would try to install to '/usr/local/', not '/usr/local/foobaz'.

Comments and changes to this ticket

  • Ryan C. Creasey

    Ryan C. Creasey March 20th, 2009 @ 02:15 PM

    Or even passing them via the policy requires would be nice:

    policy :some_farm, :roles => :app do
      requires :apache, :version => '2.2.11', :arch => 'x86_64'
  • Ryan Creasey

    Ryan Creasey March 21st, 2009 @ 11:52 AM

    Actually, forget about all what I said. This is a more clear definition of what I'm trying to do and where things are breaking down. By using the Capistrano deploy method, it's running with this recipe:

    @@@ Ruby role :build, "cent4_64.buildhost.com", {:os => 'centos_4', :arch => 'x86_64'}

    And this being my sprinkle script:
    @@@ Ruby
    # Include the install packages
    Dir['packages/build/*.rb'].each { |e| require e }
    policy :lamp, :roles => :build do
      requires :apache
      requires :mysql
      requires :php
    policy :scm, :roles => :build do
      requires :git
    policy :caching, :roles => :build do
      requires :memcache
    deployment do
      delivery :capistrano do
        recipes 'farms/build'
      source do
        prefix   "/tools/services"
        archives "/export/sources"
        builds   "/export/build"

    And an example "build" package, 'packages/build/apache.rb': @@@ Ruby package :apache do description 'Apache web server.' version = '2.2.11' install_path = "#{prefix}/#{os}/#{arch}/apache/#{version}"

    source "http://apache.mirrors.redwire.net/httpd/httpd-#{version}.tar.gz" do

    prefix install_path
    with %w( mpm=prefork )
    enable %w( mods-shared=all ssl deflate proxy=shared mem-cache cache authn-dbm authn-dbd authz-dbm dbd )


    verify do

    has_directory install_path
    has_executable "#{install_path}/bin/httpd"

    end end

    Here's ruby debug output:
    @@@ Ruby
    [4, 13] in ./packages/build/apache.rb
       4    install_path = "#{prefix}/#{os}/#{arch}/apache/#{version}"
       5    #install_path = "/tools/services/centos_4/x86_64/apache/#{version}"
       7  debugger 
    => 9    source "http://apache.mirrors.redwire.net/httpd/httpd-#{version}.tar.gz" do
       10      prefix install_path
       12      with %w( mpm=prefork )
       13      enable %w( mods-shared=all ssl deflate proxy=shared mem-cache cache authn-dbm authn-dbd authz-dbm dbd )
    source "http://apache.mirrors.redwire.net/httpd/httpd-#{version}.tar.gz" do
    (rdb:1) install_path
    (rdb:1) v l
      __dbg_verbose_save => false
      install_path => "///apache/2.2.11"
      version => "2.2.11"
    (rdb:1) role

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Sprinkle is a software provisioning tool you can use to build remote servers with, after the base operating system has been installed. For example, to install a Rails or Merb stack on a brand new slice directly after its been created.

People watching this ticket