Class: Proxy::Ansible::RolesReader

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_proxy_ansible/roles_reader.rb

Overview

Implements the logic needed to read the roles and associated information

Constant Summary collapse

DEFAULT_ROLES_PATH =
'/etc/ansible/roles:/usr/share/ansible/roles'.freeze

Class Method Summary collapse

Class Method Details

.list_rolesObject



10
11
12
13
14
# File 'lib/smart_proxy_ansible/roles_reader.rb', line 10

def list_roles
  roles = roles_path.split(':').map { |path| read_roles(path) }.flatten
  collection_roles = ReaderHelper.collections_paths.split(':').map { |path| read_collection_roles(path) }.flatten
  roles + collection_roles
end

.loggerObject



20
21
22
23
24
25
26
27
28
# File 'lib/smart_proxy_ansible/roles_reader.rb', line 20

def logger
  # Return a different logger depending on where ForemanAnsibleCore is
  # running from
  if defined?(::Foreman::Logging)
    ::Foreman::Logging.logger('foreman_ansible')
  else
    ::Proxy::LogBuffer::Decorator.instance
  end
end

.roles_pathObject



16
17
18
# File 'lib/smart_proxy_ansible/roles_reader.rb', line 16

def roles_path
  ReaderHelper.config_path(ReaderHelper.path_from_config('roles_path'), DEFAULT_ROLES_PATH)
end