Sha256: e9c4f5726aa2f0916aaa676f0f912cb5ce589118562e4c8e6dddb1e859b3a61e

Contents?: true

Size: 1.64 KB

Versions: 8

Compression:

Stored size: 1.64 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 :<%= 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

8 entries across 8 versions & 2 rubygems

Version Path
auser-poolparty-1.3.0 lib/poolparty/resources/exec.rb
auser-poolparty-1.3.1 lib/poolparty/resources/exec.rb
auser-poolparty-1.3.2 lib/poolparty/resources/exec.rb
auser-poolparty-1.3.3 lib/poolparty/resources/exec.rb
auser-poolparty-1.3.4 lib/poolparty/resources/exec.rb
poolparty-1.3.4 lib/poolparty/resources/exec.rb
poolparty-1.3.3 lib/poolparty/resources/exec.rb
poolparty-1.3.1 lib/poolparty/resources/exec.rb