Class: Proxy::Ansible::RolesReader
- Inherits:
-
Object
- Object
- Proxy::Ansible::RolesReader
- 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_CONFIG_FILE =
'/etc/ansible/ansible.cfg'.freeze
- DEFAULT_ROLES_PATH =
'/etc/ansible/roles:/usr/share/ansible/roles'.freeze
Class Method Summary collapse
Class Method Details
.list_roles ⇒ Object
11 12 13 |
# File 'lib/smart_proxy_ansible/roles_reader.rb', line 11 def list_roles roles_path.split(':').map { |path| read_roles(path) }.flatten end |
.logger ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/smart_proxy_ansible/roles_reader.rb', line 24 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_path(roles_line = roles_path_from_config) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/smart_proxy_ansible/roles_reader.rb', line 15 def roles_path(roles_line = roles_path_from_config) # Default to /etc/ansible/roles if none found return DEFAULT_ROLES_PATH if roles_line.empty? roles_path_key = roles_line.first.split('=').first.strip # In case of commented roles_path key "#roles_path", return default return DEFAULT_ROLES_PATH unless roles_path_key == 'roles_path' roles_line.first.split('=').last.strip end |