libraries/data_bag_processors.rb
# Checks an array in a data bag item to see if the node['name'] exists in the array, allowing processing logic to change how a cookbook reacts to a listed exception.
#   Accepts a data bag, a data bag item, and up to two array objects to look for within a data bag.
#   Data Bag Item Example:
#     {
#       "id": "uac_exceptions",
#       "permanent_exceptions": ['node1', 'node2', 'node3']
#       "temporary_exceptions": ['node4', 'node5']
#     }
#   Method usage example with above data bag
#     data_bag_exception_check?('all_exceptions', 'uac_exceptions', 'permanent_exceptions', 'temporary_exceptions')
#
Checks an array in a data bag item to see if the node['name'] exists in the array, allowing processing logic to change how a cookbook reacts to a listed exception.
Accepts a data bag, a data bag item, and up to two array objects to look for within a data bag.
Checks an array in a data bag item to see if the node [ ' name ' ] exists in the array allowing processing logic to change how a cookbook reacts to a listed exception . Accepts a data bag a data bag item and up to two array objects to look for within a data bag .
def data_bag_exception_check?(data_bag, data_bag_item, array1 = 'exceptions', array2 = 'overrides')
      exception_array = []
      exception_array += data_bag_item(data_bag, data_bag_item)[array1] unless data_bag_item(data_bag, data_bag_item)[array1].nil?
      exception_array += data_bag_item(data_bag, data_bag_item)[array2] unless data_bag_item(data_bag, data_bag_item)[array2].nil?
      exception_array.any? { |array| Regexp.new(Regexp.escape(node['name']), 'i') =~ array }
    end
def data_bag_exception_check? ( data_bag , data_bag_item , array1 = 'exceptions' , array2 = 'overrides' ) exception_array = [ ] exception_array += data_bag_item ( data_bag , data_bag_item ) [ array1 ] unless data_bag_item ( data_bag , data_bag_item ) [ array1 ] . nil? exception_array += data_bag_item ( data_bag , data_bag_item ) [ array2 ] unless data_bag_item ( data_bag , data_bag_item ) [ array2 ] . nil? exception_array . any? { | array | Regexp . new ( Regexp . escape ( node [ 'name' ] ) , 'i' ) =~ array } end
Checks an array in a data bag item to see if the node['name'] exists in the array, allowing processing logic to change how a cookbook reacts to a listed exception.
Checks an array in a data bag item to see if the node [ ' name ' ] exists in the array allowing processing logic to change how a cookbook reacts to a listed exception .
data_bag
<not_specific>
data_bag_item
<not_specific>
array1
<not_specific>
array2
<not_specific>