Class: PoolParty::Resources::Exec

Inherits:
Resource show all
Defined in:
lib/poolparty/resources/exec.rb

Overview

Exec

Ensure a command is run on the instances

Usage

has_exec(:name => '...') do
  # More options. 
  # This block is optional
end

Options

  • name The name of your exec. This is optional, but nice for debugging purposes

  • cwd Current working directory to execute the command (optional)

  • command This describes the command to run

  • path The path to run the command with (optional)

Examples

has_exec(:name => 'start messenger', :command => 'server-start-node', :requires => get_gempackage('poolparty-latest', :onlyif => 'ps aux | grep beam | grep master')

Instance Attribute Summary

Attributes inherited from PoolPartyBaseClass

#init_opts, #ordered_resources

Instance Method Summary collapse

Methods inherited from Resource

#after_load, available_resources, #before_load, #class_name_sym, #class_type_name, #cloud, #duplicatable?, #get_modified_options, inherited, #initialize, #is_a_resource?, #is_in_plugin?, #resource?, #resource_name, #services

Methods included from SearchablePaths

included

Methods included from PoolParty::ResourcingDsl

#client_template_exists?, #client_templates_directory_exists?, #ensures, #get_client_or_gem_template, #is_absent, #is_present

Methods included from DependencyResolverResourceExtensions

#to_properties_hash

Methods inherited from PoolPartyBaseClass

add_has_and_does_not_have_methods_for, #add_resource, add_resource_lookup_method, #add_service, #add_to_parent_if_parent_exists_and_is_a_service, #get_local_resource, #get_name_from_options_and_extra_options, #get_resource, #handle_option_values, #in_local_resources?, #initialize, #inspect, #is_a_resource?, #is_plugin?, #plugin_store, #resource, #resources, #run_in_context, #run_with_callbacks, #search_in_known_locations, #store_in_local_resources, #to_hash, #to_json

Methods included from DependencyResolverCloudExtensions

#to_properties_hash

Constructor Details

This class inherits a constructor from PoolParty::Resources::Resource

Instance Method Details

#absentObject



44
45
46
# File 'lib/poolparty/resources/exec.rb', line 44

def absent
  nil
end

#after_createObject



48
49
50
# File 'lib/poolparty/resources/exec.rb', line 48

def after_create
  dsl_options[:name] = dsl_options[:command] unless dsl_options[:name]
end

#loaded(o = {}) ⇒ Object



33
34
35
36
37
38
# File 'lib/poolparty/resources/exec.rb', line 33

def loaded(o={})
  if user
    name "sudo -u #{user} -H #{name}"
    dsl_options.delete(:user)
  end
end

#presentObject



40
41
42
# File 'lib/poolparty/resources/exec.rb', line 40

def present
  nil
end