Giter Site home page Giter Site logo

sprinkle-tool / sprinkle Goto Github PK

View Code? Open in Web Editor NEW
1.1K 16.0 138.0 891 KB

Sprinkle is a software provisioning tool you can use to build remote servers with. eg. to install a Rails, or Sinatra stack on a brand new slice directly after its been created

Home Page: https://github.com/sprinkle-tool/sprinkle

License: MIT License

Ruby 99.98% HTML 0.02%

sprinkle's Introduction

Sprinkle

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.

Build Status Code Climate

Installation

Install:

$ gem install sprinkle

Packages

Properties of packages such as their name, type, dependencies, etc, and what packages apply to what machines is described via a domain specific language that Sprinkle executes (in fact one of the aims of Sprinkle is to define as concisely as possible a language for installing software).

An example:

package :ruby do
  description 'Ruby Virtual Machine'
  version '1.8.6'
  source "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-#{version}-p111.tar.gz"
  requires :ruby_dependencies

  verify do
    has_file '/usr/bin/ruby'
  end
end

This defines a package called ruby, that uses the source based installer to build Ruby 1.8.6 from source, installing the package ruby_dependencies beforehand. The package verifies it was installed correctly by verifying the file /usr/bin/ruby exists after installation. If this verification fails, the sprinkle script will gracefully stop.

Reasonable defaults are set by sprinkle, such as the install prefix, download area, etc, but can be customized globally or per package (see below for an example).

Since packages come in many forms (eg. gems, pre-compiled debs, compressed source tar.gz, etc), Sprinkle supports many different installer types, giving you the most amount of flexibility of how you'd like software installed. New installer types can be added into the system easily.

For example, you could install Rails via gems, nginx via source, and mysql via APT, while retaining the flexibility of changing installer types as software is updated upstream.

Sprinkle also supports dependencies between packages, allowing you specify pre-requisites that need to be installed in order.

Policies

Packages can be grouped into polices to define several packages that should be installed together. An example:

policy :rails, :roles => :app do
  requires :rails, :version => "3.2"
  requires :appserver
  requires :database
  requires :webserver
end

This defines a policy called Rails, that applies to machines of role :app. The policy includes the packages rails (version 3.2), appserver, database and webserver.

The appserver, database and webserver packages can also be virtual, prompting the user for selection if multiple choices for the virtual package exist.

Sprinkle is architected to be extendable in many ways, one of those areas is in its deployment of commands to remote hosts. Currently Sprinkle supports the use of Capistrano, Vlad, or a direct net/ssh connection to issue commands on remote hosts via ssh, but could also be extended to use any other command transport mechanism desired. Sprinkle can also be configured to simply issue installation commands to provision the local system.

Sprinkle is a work in progress and I'm excited to hear if anyone finds it useful - please feel free to comment, ask any questions, or send in any ideas, patches, bugs. All most welcome.

Marcus Crafter - [email protected]


APPENDIX

A full example deployment

A full example Sprinkle deployment script for deploying Rails (via gems), MySQL (via APT), Apache (via source) and Git (via source with dependencies from APT):

# Sprinkle Rails deployment script
#
# This is an example Sprinkle script, configured to install Rails from gems, Apache, Ruby and Git from source,
# and mysql and Git dependencies from apt on an Ubuntu system. Installation is configured to run via
# Capistrano (and an accompanying deploy.rb recipe script). Source based packages are downloaded and built into
# /usr/local on the remote system.
#
# A sprinkle script is separated into 3 different sections. Packages, policies and deployment.
#
# Packages
#
#  Defines the world of packages as we know it. Each package has a name and
#  set of metadata including its installer type (eg. apt, source, gem, etc). Packages can have
#  relationships to each other via dependencies
#
# Policies
#
#  Names a group of packages (optionally with versions) that apply to a particular set of roles.
#
# Deployment
#
#  Defines script wide settings such as a delivery mechanism for executing commands on the target
#  system (eg. capistrano), and installer defaults (eg. build locations, etc).

# Packages

package :ruby do
  description 'Ruby Virtual Machine'
  version '1.8.6'
  source "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-#{version}-p111.tar.gz"
  requires :ruby_dependencies
end

package :ruby_dependencies do
  description 'Ruby Virtual Machine Build Dependencies'
  apt %w( bison zlib1g-dev libssl-dev libreadline5-dev libncurses5-dev file )
end

package :mysql, :provides => :database do
  description 'MySQL Database'
  apt %w( mysql-server mysql-client )
end

package :apache, :provides => :webserver do
  description 'Apache 2 HTTP Server'
  version '2.2.9'
  source "http://apache.wildit.net.au/httpd/httpd-#{version}.tar.bz2" do
    enable %w( mods-shared=all proxy proxy-balancer proxy-http rewrite cache headers ssl deflate so )
    prefix "/opt/local/apache2-#{version}"
    post :install, 'install -m 755 support/apachectl /etc/init.d/apache2', 'update-rc.d -f apache2 defaults'
  end
  requires :apache_dependencies
end

package :apache_dependencies do
  description 'Apache 2 HTTP Server Build Dependencies'
  apt %w( openssl libtool mawk zlib1g-dev libssl-dev )
end

package :rubygems do
  description 'Ruby Gems Package Management System'
  version '1.2.0'
  source "http://rubyforge.org/frs/download.php/38646/rubygems-#{version}.tgz" do
    custom_install 'ruby setup.rb'
  end
  requires :ruby
end

package :rails do
  description 'Ruby on Rails'
  gem 'rails'
  version '3.2'
end

package :mongrel do
  description 'Mongrel Application Server'
  gem 'mongrel'
  version '1.1.5'
end

package :mongrel_cluster, :provides => :appserver do
  description 'Cluster Management for Mongrel'
  gem 'mongrel_cluster' # :source => 'http://gems.github.com/' for alternate gem server
  version '1.0.5'
  requires :mongrel
end

package :git, :provides => :scm do
  description 'Git Distributed Version Control'
  version '1.5.6.3'
  source "http://kernel.org/pub/software/scm/git/git-#{version}.tar.gz"
  requires :git_dependencies
end

package :git_dependencies do
  description 'Git Build Dependencies'
  apt 'git', :dependencies_only => true
end

# Policies

# Associates the rails policy to the application servers. Contains rails, and surrounding
# packages. Note, appserver, database and webserver are all virtual packages defined above. If
# there's only one implementation of a virtual package, it's selected automatically, otherwise
# the user is requested to select which one to use.

policy :rails, :roles => :app do
  requires :rails, :version => "3.2"
  requires :appserver
  requires :database
  requires :webserver
  requires :scm
end

# Deployment

# Configures sprinkle to use capistrano for delivery of commands to the remote machines (via
# the named 'deploy' recipe). Also configures 'source' installer defaults to put package gear
# in /usr/local

deployment do

  # mechanism for deployment
  delivery :capistrano do
    recipes 'deploy'
  end

  # source based package installer defaults
  source do
    prefix   '/usr/local'           # where all source packages will be configured to install
    archives '/usr/local/sources'   # where all source packages will be downloaded to
    builds   '/usr/local/build'     # where all source packages will be built
  end

end

Please see the examples directory for more complete examples of Sprinkle deployment scripts, and also the Passenger Stack github page and video by Ben Schwarz.

sprinkle's People

Contributors

adzap avatar bsears avatar crafterm avatar dekz avatar doke avatar ebeigarts avatar javierav avatar jonrowe avatar joshgoebel avatar jpease avatar jsierles2 avatar keithhanson avatar kimptoc avatar koenpunt avatar lasseebert avatar luonet avatar manuelmeurer avatar mitchellh avatar mlooney avatar mtrudel avatar okiess avatar plusplus avatar sunaku avatar tlj avatar tmikoss avatar tpitale avatar troelskn avatar turboladen avatar weakish avatar zapnap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sprinkle's Issues

Is it possible to reference Capistrano config variables?

Some of my packages need to know where I'm deploying my Rails app to so that they can create directories, write config files, etc. I can't figure out how to refer to Capistrano's "deploy_to" variable from inside my packages.

I can reference "deploy_to" from within the deployment definition as @style.config.fetch(:deploy_to). It also looks like the instance of Deployment (that contains @Style) is passed into Package#process (http://rubydoc.info/gems/sprinkle/0.4.2/Sprinkle/Package/Package:process).

Is there a good way (or even a bad way, frankly) to refer to "deploy_to" and other Cap variables?

Specify additional capistrano tasks when executing a sprinkle

Hi,
I'm using capistrano for delivery and I'm looking for a way to specify additional tasks on the command line that will be executed before the delivery. What I'm looking to do is to specify the system via a role action and possibly set a few other parameters. This is primarily so I don't have to edit the config/deploy every time I add a new system or run a different sprinkle.

It looks like this can probably be done during option parsing in sprinkle itself but I thought I would ping you to see if there is a more straightforward way this can be done. Any suggestions are welcome.

Thanks for creating this. It's been helpful for us to take some of the manual work out of provisioning. It is convenient to be able to specify a configuration once and be done with it.

Thanks,
Damon

Still active?

@crafterm Are you planning to continue actively developing Sprinkle?
It seems to me that development has pretty much stopped a while ago. In #82 somebody suggested a fork. Maybe, if you don't have the willingness or time to continue working on this project, it would be best to hand it over to somebody else who wants to take care of it?
Don't get me wrong, I think you have done tremendous work, but it would be a shame to not push things forward with Sprinkle. Thanks!

uninitialized constant ActiveSupport::Dependencies (NameError) with Rails 3 betas

Sprinkle is blowing up if you have one of the Rails 3 betas installed. It fails to load ActiveSupport::Dependencies unless you require 'active_support/dependencies' explicitly after requiring active_support itself.

I would fork and send you a patch, but I'm not sure how to handle this so it works in both Rails 3 and Rails 2.

use "unzip -o" for binary installer

Currently binary installer uses unzip without additional options to extract files
http://github.com/crafterm/sprinkle/blob/master/lib/sprinkle/installers/binary.rb#L39
which can cause install script to stop on prompt asking if existing files should be overwritten.

It would be better to use "unzip -o" which is already used in source installer
http://github.com/crafterm/sprinkle/blob/master/lib/sprinkle/installers/source.rb#L169
as it will ensure that existing files are overwritten without prompting.

Not working with capistrano-multistage-ext

I'm trying to use sprinkle with capistrano multistage extension, but it fails because no servers match the role. The problem happens only in a multistage configuration, even very basic ones. It's like if the multistage extension is ignored and roles are required to be defined in the main deploy.rb file.

Is it possible to send local variables to a package?

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:

# install.rb
policy :websites, :roles => :web_server do
  requires :nginx_site, :locals => {:site_name => 'somesite.com'}
  requires :nginx_site, :locals => {:site_name => 'someothersite.com'}
end

policy :api_server, :roles => :api_server do
  requires :nginx_site, :locals => {:site_name => 'api.somesite.com'}
end
# nginx-site.rb
package :nginx_site do
  runner "mkdir -p /var/www/#{site_name}"
  # Other site setup stuff...
end

Is there an easy way to pass variables to packages or some other way of accomplishing what I want?

source installer only working with "wget"

source.rb allows to specify a path to a source file to be downloaded (using wget), built and installed. There is a change in the source code that allows to specify a pre-existing file (i.e. on the destination server). In this case "cp" is used instead of "wget".

The problem is that file existance is checked locally (on the machine runing sprinkle using File.exists?) instead that on the remote server, and then a "cp" command is issued remotely. The cp command will normally fail because paths don't match.

I am not skilled enough to fix it myself. As a suggestion, allowing to transfer the file from the server running sprinkle (i.e. like using the transfer installer) would prove really useful.

Capistrano::CommandError

Seeing my problem elsewhere on the Internet:
http://www.mail-archive.com/[email protected]/msg06306.html
http://pastie.org/pastes/1047922
http://gist.github.com/216677

My output:
--> Installing ruby_enterprise for roles: app
/Users/kimball/.rvm/gems/ree-1.8.7-2010.02/gems/capistrano-2.5.19/lib/capistrano/command.rb:173:in `process!': failed: "sh -c 'sudo -p '''sudo password: ''' bash -c '''cd /usr/local/build && tar xzf /usr/local/src/ruby-enterprise-1.8.7-2010.02.tar.gz''''" on example.com (Capistrano::CommandError)

vlad support broken?

/Users/mml/.gem/ruby/1.8/gems/sprinkle-0.3.1/bin/../lib/sprinkle/actors/vlad.rb:39:in `script': private  method `load' called for #<Sprinkle::Actors::Vlad:0x101079778 @loaded_recipes=[]> (NoMethodError)
    from config/sprinkle.rb:33:in `sprinkle'

called via simple:

deployment do
  delivery :vlad do
    script File.join(File.dirname(__FILE__), 'deploy.rb')
  end 
end

Actors::Vlad::script seems incorrect (where is "script" defined?)

Specs fail

With current versions of dependent gems, two test fail.

Failures:

  1) Sprinkle::Installers::Installer during installation should request the install sequence from the concrete class
     Failure/Error: @installer.should_receive(:install_sequence).and_return(@sequence)
       (#<Sprinkle::Installers::Installer:0x9b15fcc>).install_sequence(any args)
           expected: 1 time
           received: 2 times
     # ./spec/sprinkle/installers/installer_spec.rb:65:in `block (3 levels) in <top (required)>'

  2) Sprinkle should create a logger of level INFO
     Failure/Error: logger.level.should == ActiveSupport::BufferedLogger::Severity::INFO
       expected: 1
            got: 0 (using ==)
     # ./spec/sprinkle/sprinkle_spec.rb:22:in `block (2 levels) in <top (required)>'

In fact calling rake doesn't work any more due to changes in Jeweler, you need to comment out task :spec => :check_dependencies first.

Here is a .rvmrc / Gemfile.lock of what I'm using : https://gist.github.com/2294259

Fixed code is in https://github.com/arnebrasseur/sprinkle/tree/fix_specs

push_text installer problem

I'm trying to prepare automatic setup for debian squeeze box and having the following problem:
when I try to:
push_text 'some text', '/etc/init.d/nginx'
this is what I get (simply telling me I have no rights to access the file):

nginx install sequence: /bin/echo -e 'some text' |tee -a /etc/init.d/nginx for roles: web_stack
--> Installing nginx for roles: web_stack
** [out :: deb-vb] tee: /etc/init.d/nginx: Permission denied
** [out :: deb-vb] 
** [out :: deb-vb] some text
/Users/piotrkowalski/.rvm/gems/ruby-1.9.2-p290@servers/gems/capistrano-2.8.0/lib/capistrano/command.rb:176:in `process!': failed: "sh -c 'sudo -p '\\''sudo password: '\\'' /bin/echo -e '\\''some text'\\'' |tee -a /etc/init.d/nginx'" on deb-vb (Capistrano::CommandError)

On the other hand when I use sudo like this:
push_text 'some text', '/etc/init.d/nginx', :sudo => true do
the installation hangs waiting for sudo password:

nginx install sequence: /bin/echo -e 'some text' |sudo tee -a /etc/init.d/nginx for roles: web_stack
--> Installing nginx for roles: web_stack
** [out :: deb-vb] [sudo] password for pkow:

Source documentation for Installer says there is no need to use sudo since 'All commands by default are sudo'd'.

in my deploy.rb I have:
default_run_options[:pty] = true

I am using sprinkle 0.4.1 and capistrano 2.8.0.

Any ideas?

BTW How to execute arbitrary shell command as a sudo user?

options are ignored by policy requires method

README.markdown has one example where :version option is provided to policy requires method:
requires :rails, :version => '2.1.0'

But when I look at source http://github.com/crafterm/sprinkle/blob/master/lib/sprinkle/policy.rb#L66-68 I see that these options are ignored (initially I thought that :version will override default version specified in package definition). So either README example should be fixed and options should be removed or options should be somehow implemented in this method.

source pre/post should support inline installers (such as push_text)

I'm looking for a way to run a method from within a pre/post statement like so:

source 'http://apache.cu.be//httpd/httpd-2.4.3.tar.gz' do
prefix '/usr/local/apache2'
post(:extract) { push_text 'this is a line of text', '/tmp/test.txt' }
end

But get the following error:
/usr/local/lib/ruby/gems/1.9.1/gems/capistrano-2.14.1/lib/capistrano/command.rb:176:in `process!': failed: "sh -c 'bash -c '''cd /tmp/build/httpd-2.4.3 && ["this is a line of text", "/tmp/test.txt"] >> apache2-post.log 2>&1''''" on 192.168.0.31 (Capistrano::CommandError)

Packages and requires should support multiple versions

Firstly, thanks for picking up the project and continue on maintaining it.

My issue, which may be due to a lack of understanding is to do with versions within Package's. I'll bust out a code sample with what I expected the behaviour to be.

policy :z, :roles => :lb do
  requires :nginx, :version => '1.4.0'
end
policy :d, :roles => :worker do
  requires :nginx, :version => '1.2.0'
end

As far as I can tell (and reproduce), the definition of two nginx packages will override each other and version itself becomes pretty useless when related to package name. What are your thoughts on this as a concept? The problem stems from Package referencing packages as single items in the PACKAGE[name] hash. If it's possible to make this an array that is searched if :version is provided or simply selecting first or last otherwise.

The only current way to do this I assume is to rename the packages to :nginx_1_4_0 and :nginx_1_2_0 respectively.

sudo: no tty present and no askpass program specified

Great tool, but I discovered this issue today. I developed most of my scripts against a 8.04 Ubuntu (hardy) installation and once I thought they were about ready to go I tried running them against an 10.04 Ubunutu (lucid) box. I immediatley ran into this error:
sudo: no tty present and no askpass program specified

A bit of googling found the following capistrano option that fixed the problem: "default_run_options[:pty] = true". The scripts would now run as sudo correctly but it disabled the "output collection" on the server. That means I can't see any results from the commands so I have no hints as to why the sprinkle command failed. I'm assuming that sprinkle needs to hook onto the extra psudeo-tunnel and print that text but it wasn't clear to me where those hooks might be.

If anyone can give me a pointer on where to look for the capistrano links I'll try to find a solution.

Use cmake instead of configure

I would like to install MySQL from source with Sprinkle. MySQL uses cmake instead of configure.
Is it possible to change just the configure instruction but still use make and make install to build and install?
AFAICS using custom_install overwrites all of these.

Local installation in chroot environment (e. g. for vmbuilder)

I am currently working on a script that automatically creates a VM appliance for a project via Ubuntu vmbuilder (see http://manpages.ubuntu.com/manpages/precise/man1/vmbuilder.1.html)

The vmbuilder script creates a build directoy in which the target VM file system is prepared. This already works fine.

Now my installation procedure is going to be horridly complex, much too complex for the mechanisms provided by vmbuilder. For example I need install a plethora of packages, then I need to modify a lot of configuration files (partly using templates) and run a lot of commands to initialize the database and LDAP directory within the VM (the goal is to create an appliance including a fully configured PKI environment using http://www.openxpki.org as a showcase for the project)

vmbuilder provides a postinstall script hook which can be used to run commands chrooted in the target directory.

Now my idea is to use Sprinkle to perform the deployment work once the base installation has been prepared in the build directory. I would like to have Sprinkle copy files to the target directory (which can be done with the "local" actor) and more importantly run chrooted commands to perform tasks within the target environment.

Questions: is Sprinkle the right tool for the task? And do you think it is both sensible and possible to have a "chroot" actor that executes commands within the target environment?

My ruby knowledge is very limited, but I'd be willing to develop a chroot actor and contribute a pull request is somebody with insight tells me that Sprinkle is in principle capable of doing this.

has_gem error with Capistrano 2.5.19

Hi and thanks for Sprinkle! I'm psyched to use it for my server deployment. I think I was using passenger-stack pretty much out of the box. I seemed to be having a problem wherever a 'sudo' was passed to capistrano, which seemed to already be applying sudo itself. This happened in a few places in packages in passenger-stack (see http://github.com/benschwarz/passenger-stack/issues/#issue/3), and once in lib/sprinkle/verifiers/ruby.rb. See my commit: http://github.com/Gladcraft/sprinkle/commit/0e6d5fc94177e3e7438a994e013101992ef905d1

Of course with my being relatively noobish, there may be a better answer to my difficulties. Probably having to do with my minimal familiarity with Capistrano and other things.

Hope this is helpful. Thanks, David Kaplan

Transfer should explain that it does not copy symlinks

I use transfer to copy some config files to the server but it seems like symlinks gets converted into regular files.. Probably because transfer uses scp internally. Is there a way to preserve symlinks, maybe by replacing scp with rsync?

Is it possible for post :install not use sudo?

Is it possible to run a post :install command without sudo?

I have the same problem with runner, but I can get around this using chown.

package :zsh do
  description 'Zsh with OhMyZsh'

  apt 'zsh' do
    # FIXME: This needs to be run as user, not sudo
    post :install, 'chsh -s /usr/bin/zsh'
  end

  verify do
    has_executable 'zsh'
  end

  requires :oh_my_zsh
end

package :oh_my_zsh do
  runner '/usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh'
  runner 'chown -R deploy:deploy ~/.oh-my-zsh'
  runner 'cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc'
  runner 'echo "export PATH=$PATH" >> ~/.zshrc'

  verify do
    # has_file '~/.zshrc'
  end

  requires :git
end

Configuring machines in different states

When I run sprinkle against a cluster of servers that are in different states (ie one has already been successfully configured by sprinkle (machine A) and one hasn't (machine B)), machine A gets everything installed again at the same time as B.

Is this the expected behaviour? I'd expect that if A has a package installed and it verifies, but B doesn't, then only B will have the package installed (rather than both of them).

Sprinkle is not ruby 1.9 compatible

Issues I've found so far:

  1. Optparse causes a segmentation fault on ruby 1.9.1p376 on CentOS when loaded in bin/sprinkle.
  2. The method of assigning options in bin/sprinkle is not compatible with ruby 1.9
  3. Source and build paths are not generated correctly:
    cd ["/usr/local/build"] && tar xzf ["/usr/local/src"]/ruby-1.9.1-p376.tar.gz
    expected:
    cd /usr/local/build && tar xzf /usr/local/src/ruby-1.9.1-p376.tar.gz

Installing Ruby hangs

โ†’ sprinkle -c -s provision.rb 
--> Cloud hierarchy for policy application

Policy application requires package rails
    Package rails requires rubygems
        Package rubygems requires ruby
            Package ruby requires ruby_dependencies
                Package ruby_dependencies requires core
    Package rails requires rubygems
        Package rubygems requires ruby
            Package ruby requires ruby_dependencies
                Package ruby_dependencies requires core

--> Normalized installation order for all packages: core, ruby_dependencies, ruby, rubygems, rails
--> Installing core for roles: application
*** [err :: xxx.xx.xx.xxx] Extracting templates from packages: 76%
*** [err :: xxx.xx.xx.xxx] Extracting templates from packages: 100%
--> Installing ruby_dependencies for roles: application
--> Checking if ruby is already installed for roles: application
    --> Verifying ruby...
--> Installing ruby for roles: application

It hangs forever at --> Installing ruby for roles: application - when I manually SSH in to the server and perform the operations manually it all works fine.

This is the package that's being run:

package :ruby, :provides => :language do
  requires :ruby_dependencies
  version "1.9.3"
  patchlevel "0"
  source "ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-#{version}-p#{patchlevel}.tar.gz"

  verify do
    has_executable_with_version "ruby", version
    has_executable "gem"
  end
end

Anyone have any idea why this never finishes?

Thanks!

Anyone using VLAD with Sprinkle and want to help out?

Could really use someone to help test my Vlad actor rewrite... and weigh in on if per host execution is even a realistic possibility with Vlad... it seems quite doable with Cap and SSH. I could figure out Vlad and do it myself but that's just annoying. :)

If transfer installer has several post :install hooks then just first one runs with sudo

Due to specific post :install hooks implementation for transfer method
http://github.com/crafterm/sprinkle/blob/master/lib/sprinkle/installers/transfer.rb#L170
which just joins all commands with ";" only the first post install hook is executed with sudo.

This example of concatenated command which is generated - first id will return root uid, second id will return normal user uid:
sh -c 'sudo -p '''sudo password: ''' id; id'

Separate repository for example packages?

I'm raising this as an idea to see what you think, but would also be willing to work on it if you think that it's worthwhile.

The benefit would be that it would give people an obvious place to look for packages, and to contribute back. I've recently started using Sprinkle, putting together a small reusable stack, and have found a lot of really good stuff in different examples and stacks, but many of them seem to be incomplete or no longer maintained.

In any event, thank you for Sprinkle - it has been a real pleasure to use.

source installer always uses sudo -p

I honestly don't know if this is a configuration issue or a a bug. I'm using the latest gem (0.4.2). The sprinkle recipe always stops at this package. It successfully installs apt packages and creates users among other things, but I can't get it to successfully install from source. I've tried as root, as a user with sudo privs, and as both types of users with and without ssh keys, and with and without capistrano's set use_sudo.

Do you have any advice?

--> Installing ruby for roles: app
/home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/capistrano-2.11.2/lib/capistrano/command.rb:176:in `process!': failed: "sh -c 'sudo -p '\\''sudo password: '\\'' wget -cq -O '\\''/usr/local/sources/ruby-1.9.3-p195.tar.gz'\\'' ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p195.tar.gz'" on 96.126.104.148 (Capistrano::CommandError)
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/capistrano-2.11.2/lib/capistrano/command.rb:134:in `process'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/capistrano-2.11.2/lib/capistrano/configuration/actions/invocation.rb:178:in `block in run_tree'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/capistrano-2.11.2/lib/capistrano/configuration/connections.rb:198:in `block in execute_on_servers'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/capistrano-2.11.2/lib/capistrano/configuration/connections.rb:186:in `each'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/capistrano-2.11.2/lib/capistrano/configuration/connections.rb:186:in `each_slice'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/capistrano-2.11.2/lib/capistrano/configuration/connections.rb:186:in `execute_on_servers'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/capistrano-2.11.2/lib/capistrano/configuration/actions/invocation.rb:176:in `run_tree'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/capistrano-2.11.2/lib/capistrano/configuration/actions/invocation.rb:148:in `run'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/capistrano-2.11.2/lib/capistrano/configuration/actions/invocation.rb:214:in `sudo'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/capistrano-2.11.2/lib/capistrano/configuration/actions/invocation.rb:89:in `invoke_command'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/actors/capistrano.rb:64:in `block (2 levels) in process'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/actors/capistrano.rb:63:in `each'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/actors/capistrano.rb:63:in `block in process'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:139:in `instance_eval'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:139:in `invoke_task_directly'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/capistrano-2.11.2/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/capistrano-2.11.2/lib/capistrano/configuration/execution.rb:89:in `execute_task'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/capistrano-2.11.2/lib/capistrano/configuration/namespaces.rb:110:in `block in define_task'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/actors/capistrano.rb:103:in `run'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/actors/capistrano.rb:69:in `process'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/installers/installer.rb:75:in `process'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/package.rb:248:in `block in process'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/package.rb:246:in `each'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/package.rb:246:in `process'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/policy.rb:92:in `block in process'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/policy.rb:121:in `each'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/policy.rb:121:in `normalize'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/policy.rb:91:in `process'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/deployment.rb:68:in `block in process'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/deployment.rb:67:in `each'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/deployment.rb:67:in `process'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/script.rb:20:in `sprinkle'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/lib/sprinkle/script.rb:16:in `sprinkle'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/gems/sprinkle-0.4.2/bin/sprinkle:95:in `<top (required)>'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/bin/sprinkle:19:in `load'
    from /home/brandon/.rvm/gems/ruby-1.9.3-p125@loudcity_stats/bin/sprinkle:19:in `<main>'


```ruby
package :ruby do
  requires :ruby_dependencies
  description 'Ruby Virtual Machine'
  version '1.9.3'
  patchlevel '195'

  source "ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-#{version}-p#{patchlevel}.tar.gz",:sudo => false do
    pre :install, 'apt-get purge ruby ruby1.9 ruby1.9.1 rubygems1.8 rubygems1.9 rubygems1.9.1'
  end

  verify { has_executable_with_version "/usr/local/bin/ruby", version }
end

package :ruby_dependencies do
  description 'Ruby Virtual Machine Build Dependencies'
  apt %w( bison zlib1g-dev libssl-dev libreadline-gplv2-dev libncurses5-dev libyaml-0-2 file )
end

```ruby
# Example configuration file for Capistrano Sprinkle deploy strategy
#
#
# -- Application configuration
#
# Note: The default Vagrant box IP is "33.33.33.10"
#
role :app,  '192.168.1.100', :primary => true

# --- SSH connection configuration
#
# Note: The default Vagrant user is "vagrant"
#
set  :user, 'deploy'
#
# --  SSH options
#
# -   Port
# ssh_options[:port] = 22
#
# -   Authenticate with key pair, not password
# ssh_options[:keys] = ['/path/to/your/private/key']
#
# Configuration for the Vagrant box:
#
#ssh_options[:keys] = File.join(File.dirname(`gem which vagrant`.strip), '../keys/vagrant')
#
# -   Use sudo
set  :use_sudo, false
#
# -   Declare intareactive terminal
default_run_options[:pty] = true
#
ssh_options[:forward_agent] = true
ssh_options[:keys] = %w(/home/#{ENV['USER']}/.ssh/id_dsa) 

Errors from scp not propagated back?

WARNING: I'm a noob with capistrano and sprinkle.

I just spent the better part of the day tracking down why I couldn't deploy. I'm trying to use sprinkle to push out development binaries (executables compiled and linked from C++ code) to a test server (ultimately I would like to extend sprinkle to control running the tests, but that's later). scp kept failing.

It turns out that the "problem" was that the very first binary it was trying to push out was running on the target, so scp was failing with a "text file busy" error. Either capistrano wasn't communicating that back to sprinkle, or sprinkle was squelching the error. In any case, it took more investigation and unrolling of the source to dig out an understanding of what was happening.

What should be reporting the error? Am I looking in the wrong place?

Finally, is this the best place to ask questions about sprinkle, or is there a better community forum?

Capistrano sudo and sprinkle sudo can trip each other up

See issue #42 for reference.

To summarize the problem

You're using capistrano with sudo that requries a password. No matter what you try push_text cannot push to a privileged file. Say you try:

push_text :sudo => true

Then push_text merely appends "sudo" which doesn't have the brains to deal with the sudo password prompt the same way that Capistrano does.

Or say you assume since you're using sudo with Capistrano (set :use_sudo, true) for everything that this would just be a non-issue... the problem is the command issued from capistrano looks like this:

sh -c 'sudo -p 'sudo password: ' ... blah | sudo tee'

It's simply spawning a new shell and then prefixing that with it's own sudo... but once you start piping you're back to the original permission set and the second sudo gets hung up at the password prompt as explained above.

Potential solution

A branch to review: https://github.com/sprinkle-tool/sprinkle/tree/smart_sudo

So we can let installers determine the actor's sudo mode and even ask the actor to build a sudo command for them... that's what the branch I linked to does. And it should actually work but then you get commands like this:

sh -c 'sudo -p 'sudo password: ' sudo -p 'sudo password: ' grep -qPzo '^now$' /etc/stupid_file || /bin/echo -e 'now' |sudo -p 'sudo password: ' tee -a /etc/stupid_file

In many cases sudo is now being called twice... so we could define a first_sudo_cmd that was blank when we knew the actor was going to be sudoing everything, but then that starts to seem really messy to me...

Problem with #add_user

I've following code in script:

if users.any?
  users.each do |user|
    pkg = "create_#{user}".to_sym

    package pkg do
      add_user user, flags: '--shell /bin/bash --disabled-password'

       verify { has_user user }
     end

     requires pkg
  end
end

In Ubuntu, running "adduser lalala --shell /bin/bash --disabled-password" will ask you about new user's password. But i don't see any prompts etc, so installation stucks. Is there any solution for this?

execute_on_role - undefined method

Dear all,

I am following this simple tutorial at http://engineering.gomiso.com/2011/08/26/forget-chef-or-puppet-automate-with-sprinkle/ and test script at the bottom of the page and when i run the script i get the following error message:

--> Cloud hierarchy for policy myapp

Policy myapp requires package git

--> Normalized installation order for all packages: git
--> Checking if git is already installed for roles: app
--> Verifying git...
/usr/local/sprinkle/lib/sprinkle/actors/ssh.rb:69:in execute_on_role': undefined method[]' for nil:NilClass (NoMethodError)

I've changed capistrano to ssh like so:
deployment do
delivery :ssh

source do
prefix '/usr/local'
archives '/usr/local/sources'
builds '/usr/local/build'
end
end

am unable to load server please help...

DEPRECATION WARNING: ref is deprecated and will be removed from Rails 3.2. (called from mailer= at /home/rahul/lib/ruby/gems/1.9.1/bundler/gems/devise-cfadaf80a2b7/lib/devise.rb:173)
DEPRECATION WARNING: new is deprecated and will be removed from Rails 3.2. (called from mailer= at /home/rahul/lib/ruby/gems/1.9.1/bundler/gems/devise-cfadaf80a2b7/lib/devise.rb:173)
/home/rahul/lib/ruby/gems/1.9.1/bundler/gems/sprinkle-7c744ed158dd/lib/sprinkle.rb:7:in <top (required)>': undefined methodload_paths' for ActiveSupport::Dependencies:Module (NoMethodError)
from /home/rahul/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'

Thanks,

Multiple policies

I can't figure out how exactly the policies work. In no blog post about Sprinkle or the Sprinkle docs itself have I found a single example that uses multiple policies...

Basically I have multiple environments in my app for which I want to install different packages. I am working with a STAGE env var that I pass in when calling Sprinkle (e.g. sprinkle STAGE=legacy -s config/sprinkle/install.rb, based on https://github.com/crafterm/sprinkle/issues/50#issuecomment-6914779) and I want to install a certain set of packages based on this stage parameter.
What is the proper way to do this? Create a separate policy for it? If so, how do I just execute one policy, not all of them?
Any ideas and tips appreciated!

SSH Actor transfer_to_host does not look at password

I am getting errors when trying to transfer files using the ssh deployment method.

It seems this part of the transfer_to_host function doesn't look at the ssh password:

Net::SSH.start(host, @options[:user]) do |ssh|
  transfer_on_connection(source, destination, recursive, ssh)
end

Works when i change to:

Net::SSH.start(host, @options[:user], :password => @options[:password) do |ssh|
  transfer_on_connection(source, destination, recursive, ssh)
end

Add "has_apt" verifier

Thanks :)

module Sprinkle
  module Verifiers
    # = Apt package Verifier
    #
    # Contains a verifier to check the existance of an Apt package.
    # 
    # == Example Usage
    #
    #   verify { has_apt 'ntp' }
    #
    module Apt
      Sprinkle::Verify.register(Sprinkle::Verifiers::Apt)

      # Checks to make sure the apt <tt>package</tt> exists on the remote server.
      def has_apt(package)
        @commands << "dpkg -l | grep #{package}"
      end

    end
  end
end

How to get apt-get to install with sudo?

Hey I've got this package

package :git do
  description 'Git version control client'
  apt 'git-core', :sudo => true

  verify do
    has_executable 'git'
  end
end

when I run I get this error:


-> Normalized installation order for all packages: git, build_essential, ruby_dependencies, ruby, python_software_properties, passenger, postgres_deps, postgres_gis, ufw_config
--> Checking if git is already installed for roles: app
gitgit verification sequence: [ -n "`echo \`which git\``" ] for roles: app

    --> Verifying git...
git install sequence: env DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get --force-yes -qyu install git-core for roles: app

--> Installing git for roles: app
 ** [out :: 120.138.30.76] E
 ** [out :: 120.138.30.76] :
 ** [out :: 120.138.30.76] Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
 ** [out :: 120.138.30.76] 
 ** [out :: 120.138.30.76] E
 ** [out :: 120.138.30.76] :
 ** [out :: 120.138.30.76] Unable to lock the administration directory (/var/lib/dpkg/), are you root?
 ** [out :: 120.138.30.76] 
/Users/christopherbull/.rvm/gems/ruby-1.9.3-p194@popin_sprinkle/gems/capistrano-2.12.0/lib/capistrano/command.rb:176:in `process!': failed: "sh -c 'env DEBCONF_TERSE='\\''yes'\\'' DEBIAN_PRIORITY='\\''critical'\\'' DEBIAN_FRONTEND=noninteractive apt-get --force-yes -qyu install git-core'" on 120.138.30.76 (Capistrano::CommandError)

This is on ubuntu 12.04. I'm almost certain it's because the command isn't being run as sudo. Is there any way to make apt-get run with sudo? I can't see any when looking at the source. Also is sprinkle still in development?

Thanks,
Chris

source pre/post hooks fail for prepare/download/extract

From the documentation:

package :magic_beans do
  source 'http://magicbeansland.com/latest-1.1.1.tar.gz' do
    prefix    '/usr/local'

    pre :prepare { 'echo "Here we go folks."' }
    post :extract { 'echo "I believe..."' }
    pre :build { 'echo "Cross your fingers!"' }
  end
end

However, dress forces the command to be run from the build dir -- this is the directory created by extracting the archive. So all pre/post hooks prior to the extraction will fail. In the example above, the pre :prepare should fail.

has_executable_with_version fails for Python

python -V prints its version number to STDOUT, which gets thrown away by the verifier.

 verify { has_executable_with_version( "/usr/local/python-#{version}/bin/python", version, "-V"  ) }

A better approach would be:
@commands << "[ -x #{path} -a -n "#{path} #{get_version} 2>&1 | egrep -s -q -e \\\"#{version}\\\"" ]"

Getting error with has_gem

Using sprinkle 0.4.2 with rbenv on Ubuntu 10.10

Package definition

package :thin do
description "Thin server"
thin_version = "1.3.1"
gem "thin", "#{thin_version}"
verify do
has_gem "thin", "#{thin_version}"
end
end

result in an error
--> Checking if thin is already installed for roles: app
thinthin verification sequence: gem list 'thin' --installed --version '1.3.1' > /dev/null for roles: app
--> Verifying thin...
executing ["gem list 'thin' --installed --version '1.3.1' > /dev/null"] on vpstest.
failed (1).
process returning false
.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sprinkle-0.4.2/lib/sprinkle/configurable.rb:24:in []': can't convert Symbol into Integer (TypeError) .rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sprinkle-0.4.2/lib/sprinkle/configurable.rb:24:inmethod_missing'
,,,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.