Sha256: 4a4ab8468a6a91d7aeba29336e38052d768d07e5224dad91f322ebebab636a4a

Contents?: true

Size: 1.66 KB

Versions: 20

Compression:

Stored size: 1.66 KB

Contents

=begin rdoc rdoc
== Exec
 
Ensure a command is run on the instances
 
== Usage
 
  has_exec(:name => '...') do
    # More options. 
    # This block is optional
  end
 
== Options
 
* <tt>name</tt> The name of your exec. This is optional, but nice for debugging purposes
* <tt>cwd</tt> Current working directory to execute the command (optional)
* <tt>command</tt> This describes the command to run
* <tt>path</tt> The path to run the command with (optional)
 
== Examples
  has_exec 'ps aux | grep erl | mail -s "running commands" root@root.com' do
    onlyif => 'ps aux | grep beam'
  end
=end
module PoolParty
  module Resources
    
    class Exec < Resource
      
      default_options(
        :path         => ["/usr/bin:/bin:/usr/local/bin:$PATH"],
        :command      => nil,
        :creates      => nil,
        :cwd          => nil,
        :environment  => nil,
        :group        => nil,
        :returns      => nil,
        :user         => nil,
        :action       => :run
      )
      
      def print_to_chef
str = 'execute "<%= name %>" do
  command <%= print_variable(command || name) %>
  path <%= print_variable(path) %>
  action <%= print_variable(action ? action : (exists ? :run : :nothing)) %>
'
      str << "  creates <%= print_variable(creates) %>\n" if creates
      str << "  cwd <%= print_variable(cwd) %>\n" if cwd
      str << "  environment <%= print_variable(environment) %>\n" if environment
      str << "  group <%= print_variable(group) %>\n" if group
      str << "  returns <%= print_variable(returns) %>\n" if returns
      str << "  user <%= print_variable(user) %>\n" if user
      
      str << "end"
      end
      
    end
    
  end
end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
auser-poolparty-1.3.10 lib/poolparty/resources/exec.rb
auser-poolparty-1.3.11 lib/poolparty/resources/exec.rb
auser-poolparty-1.3.12 lib/poolparty/resources/exec.rb
auser-poolparty-1.3.13 lib/poolparty/resources/exec.rb
auser-poolparty-1.3.14 lib/poolparty/resources/exec.rb
auser-poolparty-1.3.15 lib/poolparty/resources/exec.rb
auser-poolparty-1.3.16 lib/poolparty/resources/exec.rb
auser-poolparty-1.3.17 lib/poolparty/resources/exec.rb
auser-poolparty-1.3.5 lib/poolparty/resources/exec.rb
auser-poolparty-1.3.6 lib/poolparty/resources/exec.rb
auser-poolparty-1.3.7 lib/poolparty/resources/exec.rb
auser-poolparty-1.3.8 lib/poolparty/resources/exec.rb
fairchild-poolparty-1.3.17 lib/poolparty/resources/exec.rb
fairchild-poolparty-1.3.5 lib/poolparty/resources/exec.rb
poolparty-1.3.15 lib/poolparty/resources/exec.rb
poolparty-1.3.14 lib/poolparty/resources/exec.rb
poolparty-1.3.13 lib/poolparty/resources/exec.rb
poolparty-1.3.8 lib/poolparty/resources/exec.rb
poolparty-1.3.7 lib/poolparty/resources/exec.rb
poolparty-1.3.6 lib/poolparty/resources/exec.rb