Sha256: 57d98b08ac2e16d8fbfce5f94c9457f1a5ac0dbfc1f0c667c48a6ebde691ebfe
Contents?: true
Size: 989 Bytes
Versions: 65
Compression:
Stored size: 989 Bytes
Contents
# frozen_string_literal: true module ForemanAnsible # Imports roles from smart proxy class RolesImporter include ::ForemanAnsible::ProxyAPI def initialize(proxy = nil) @ansible_proxy = proxy @variables_importer = ForemanAnsible::VariablesImporter.new(@ansible_proxy) end def import_role_names import_roles remote_roles if @ansible_proxy.present? end def fetch_role_names remote_roles if ansible_proxy end def import_roles(roles) imported = roles.map do |role_name| ::AnsibleRole.find_or_initialize_by(:name => role_name) end detect_changes imported end def detect_changes(imported) changes = {}.with_indifferent_access changes[:old], changes[:new] = imported.partition { |role| role.id.present? } changes[:obsolete] = ::AnsibleRole.where.not(:id => changes[:old].map(&:id)) changes end private def remote_roles proxy_api.roles end end end
Version data entries
65 entries across 65 versions & 1 rubygems