Closed barnaclebarnes closed 11 years ago
Not possible, see #7
But I do use this workaround:
Dir[File.dirname(__FILE__) + '/../nginx/sites-available/*.conf'].each do |path|
name = File.basename(path, ".conf")
package :"www_#{name}" do
user = name.gsub(/[^a-z]/, "-")
transfer path, "/etc/nginx/sites-available/#{name}"
runner "mkdir -p /var/www/"
runner "useradd -m -g www-data --home /var/www/#{user} -s /bin/bash www-#{user}; true"
runner "mkdir -p /var/www/#{user}"
runner "chmod 755 /var/www/#{user}"
runner "chown www-#{user}:www-data /var/www/#{user}"
runner "chown root:root /etc/nginx/sites-available/#{name}"
runner "ln -nfs /etc/nginx/sites-available/#{name} /etc/nginx/sites-enabled/#{name}"
runner "/etc/init.d/nginx restart"
verify do
has_directory "/var/www/#{user}"
matches_local path, "/etc/nginx/sites-enabled/#{name}"
end
end
end
and then in policies:
requires :www_example
requires :"www_domain.com"
...
Please try package arguments with sprinkle 0.5.0.rc1:
policy :websites, :roles => :web_server do
requires :nginx_site, :locals => {:site_name => 'somesite.com'}
requires :blah, 1, 2, 3
end
package :nginx_site do
runner "mkdir -p /var/www/#{opts[:locals][:site_name]}"
end
package :blah do
runner "count #{args.split(" ")}" # calls "count 1 2 3"
end
Right now the entire hash you pass is available as args but in the future some keys sprinkle might want to use internally could reserved, such as :version
, etc.
Or maybe try opts, since I'm using extract_options... so an array of arguments would drop into args
and any hashes you pass should drop into opts
.
I have a package
nginx_site
that I want to make fairly generic so that I can install different sites for different roles. What I wan to do is something like:Is there an easy way to pass variables to packages or some other way of accomplishing what I want?