Sha256: 09393d94d35ed4e01199f6b6ebdd18fc5135f1307d9613fada87c7ba11215dbd
Contents?: true
Size: 887 Bytes
Versions: 38
Compression:
Stored size: 887 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 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 old, changes[:new] = imported.partition { |role| role.id.present? } changes[:obsolete] = ::AnsibleRole.where.not(:id => old.map(&:id)) changes end private def remote_roles proxy_api.roles end end end
Version data entries
38 entries across 38 versions & 1 rubygems