Last active
August 29, 2015 14:04
-
-
Save vinyar/ea86af90a0c4d84d7909 to your computer and use it in GitHub Desktop.
handing undefined attributes in chef/ruby loops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chef:recipe > a = 'stuff' | |
chef:recipe > | |
chef:recipe > service 'testing_start' do | |
chef:recipe > action defined?(a) ? :start : :stop | |
chef:recipe ?> end | |
=> <service[testing_start] @name: "testing_start" @noop: nil @before: nil @params: {} @provider: nil @allowed_actions: [:nothing, :enable, :disable, :start, :stop, :restart, :reload] @action: [:start] @updated: false @updated_by_last_action: false @supports: {:restart=>false, :reload=>false, :status=>false} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line: "(irb#2):144:in `irb_binding'" @guard_interpreter: :default @elapsed_time: 0 @resource_name: :service @service_name: "testing_start" @enabled: nil @running: nil @parameters: nil @pattern: "testing_start" @start_command: nil @stop_command: nil @status_command: nil @restart_command: nil @reload_command: nil @init_command: nil @priority: nil @cookbook_name: nil @recipe_name: nil> | |
chef:recipe > | |
chef:recipe > | |
chef:recipe > d | |
' | |
NameError: No resource, method, or local variable named `d' for `Chef::Recipe ""' | |
from /Library/Ruby/Gems/2.0.0/gems/chef-11.12.4/lib/chef/dsl/recipe.rb:49:in `rescue in method_missing' | |
from /Library/Ruby/Gems/2.0.0/gems/chef-11.12.4/lib/chef/dsl/recipe.rb:44:in `method_missing' | |
from (irb#2):149 | |
chef:recipe > | |
chef:recipe > service 'testing_stop' do | |
chef:recipe > action defined?(d) ? :start : :stop | |
chef:recipe ?> end | |
=> <service[testing_stop] @name: "testing_stop" @noop: nil @before: nil @params: {} @provider: nil @allowed_actions: [:nothing, :enable, :disable, :start, :stop, :restart, :reload] @action: [:stop] @updated: false @updated_by_last_action: false @supports: {:restart=>false, :reload=>false, :status=>false} @ignore_failure: false @retries: 0 @retry_delay: 2 @source_line: "(irb#2):151:in `irb_binding'" @guard_interpreter: :default @elapsed_time: 0 @resource_name: :service @service_name: "testing_stop" @enabled: nil @running: nil @parameters: nil @pattern: "testing_stop" @start_command: nil @stop_command: nil @status_command: nil @restart_command: nil @reload_command: nil @init_command: nil @priority: nil @cookbook_name: nil @recipe_name: nil> | |
chef:recipe > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment