Puppet Function: oci_config::latest_image_for
- Defined in:
- lib/puppet/functions/oci_config/latest_image_for.rb
- Function type:
- Ruby 4.x API
Overview
See the file “LICENSE” for the full license governing this code.
Function to fetch the fact ora_is_root_db and based on that information decide if the specified sid is a root database or not.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/puppet/functions/oci_config/latest_image_for.rb', line 10 Puppet::Functions.create_function('oci_config::latest_image_for') do dispatch :latest_image_for do param 'String[1]', :operating_system param 'String[1]', :operating_system_version optional_param 'Regexp', :name return_type 'String' end def latest_image_for(, , name = /.*/) variable = 'oci_core_image' fail "Fact #{variable} does not exists. Probably not enabled. Check enabled facts for this tenant." unless variable_exists?(variable) fact_value = closure_scope.lookupvar("::#{variable}") available_images = fact_value.select do |k, v| v['operating_system'] == && v['operating_system_version'] == && k =~ name end fail "No images found for '#{} version #{}' with name #{name}" if available_images == {} available_images.min_by { |k, _v| k['time_created'] }.first.split('/').last end # Check if the variable exists without generating a warning def variable_exists?(var) closure_scope.to_hash.keys.include?(var) end end |