Sha256: 7bcd9f9fac6ad5c5b1b9e8737ee565620c10cb7e9f27b35a19dda530c387d9ec

Contents?: true

Size: 683 Bytes

Versions: 39

Compression:

Stored size: 683 Bytes

Contents

# frozen_string_literal: true

module ForemanAnsible
  # imports ansible roles through UI
  class UiRolesImporter < RolesImporter
    def import!
      import_role_names
    end

    def finish_import(changes)
      return if changes.blank?
      create_new_roles changes['new'] if changes['new']
      delete_old_roles changes['obsolete'] if changes['obsolete']
    end

    def create_new_roles(changes)
      changes.each_pair do |_, new_role|
        ::AnsibleRole.create(JSON.parse(new_role))
      end
    end

    def delete_old_roles(changes)
      changes.each_pair do |_, old_role|
        ::AnsibleRole.find(JSON.parse(old_role)['id']).destroy
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
foreman_ansible-6.2.0 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-6.1.1 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-6.0.2 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-6.1.0 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-6.0.1 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-5.1.3 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-6.0.0 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-5.1.2 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-5.1.1 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-5.1.0 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-4.0.3.5 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-4.0.3.4 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-4.0.3.3 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-4.0.3.2 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-5.0.1 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-4.0.5 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-4.0.3.1 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-4.0.4 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-5.0.0 app/services/foreman_ansible/ui_roles_importer.rb
foreman_ansible-4.0.3 app/services/foreman_ansible/ui_roles_importer.rb