Sha256: c432669c9a8da42313d72f611e003c7d891738a96fed739e7f2240adb49cdf1f
Contents?: true
Size: 1.82 KB
Versions: 19
Compression:
Stored size: 1.82 KB
Contents
# frozen_string_literal: true organizations = Organization.unscoped.all locations = Location.unscoped.all template_files = Dir[File.join("#{ForemanAnsible::Engine.root}/app/views/foreman_ansible/job_templates/**/*.erb")] unsupported_templates = if Foreman::Plugin.find('foreman_theme_satellite').present? { 'Smart Proxy Upgrade Playbook': 'smart_proxy_upgrade_-_ansible_default.erb' } else { 'Capsule Upgrade Playbook': 'capsule_upgrade_-_ansible_default.erb' } end User.as_anonymous_admin do RemoteExecutionFeature.without_auditing do if Rails.env.test? || Foreman.in_rake? # If this file tries to import a template with a REX feature in a SeedsTest, # it will fail - the REX feature isn't registered on SeedsTest because # DatabaseCleaner truncates the db before every test. # During db:seed, we also want to know the feature is registered before # seeding the template ForemanAnsible::Engine.register_rex_feature end JobTemplate.without_auditing do template_files.reject { |template| unsupported_templates.value?(File.basename(template)) }.each do |template| sync = !Rails.env.test? && Setting[:remote_execution_sync_templates] template = JobTemplate.import_raw!(File.read(template), :default => true, :lock => true, :update => sync) template.organizations = organizations if template.present? template.locations = locations if template.present? end unsupported_templates_in_db = JobTemplate.where(name: unsupported_templates.keys) if unsupported_templates_in_db.any? unsupported_templates_in_db.update_all(locked: false) unsupported_templates_in_db.destroy_all end end end end
Version data entries
19 entries across 19 versions & 1 rubygems