class Proxy::Ansible::Api

API endpoints. Most of the code should be calling other classes, please keep the actual implementation of the endpoints outside of this class.

Private Instance Methods

extract_variables(role_name) click to toggle source
# File lib/smart_proxy_ansible/api.rb, line 33
def extract_variables(role_name)
  variables = {}
  role_name_parts = role_name.split('.')
  if role_name_parts.count == 3
    RolesReader.collections_paths.split(':').each do |path|
      variables[role_name] = VariablesExtractor
                             .extract_variables("#{path}/ansible_collections/#{role_name_parts[0]}/#{role_name_parts[1]}/roles/#{role_name_parts[2]}") if variables[role_name].nil? || variables[role_name].empty?
    end
  else
    RolesReader.roles_path.split(':').each do |path|
      role_path = "#{path}/#{role_name}"
      if File.directory?(role_path)
        variables[role_name] ||= VariablesExtractor.extract_variables(role_path)
      end
    end
  end
  variables
end