Sha256: d447078c7d80b4cf8406e0e4b4d14dc13314a1f4fcf701387c71460d68fa8ec1

Contents?: true

Size: 1.37 KB

Versions: 12

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

organizations = Organization.unscoped.all
locations = Location.unscoped.all
if ForemanSalt.with_remote_execution?
  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
        # kudos to dLobatog
        ForemanSalt.register_rex_feature
      end
      JobTemplate.without_auditing do
        templates = Dir[File.join("#{ForemanSalt::Engine.root}/app/views/foreman_salt/"\
                    'job_templates/**/*.erb')]
        first = templates.select { |d| File.basename(d).start_with?('salt_run_function') }
        (first + (templates - first)).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
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
foreman_salt-17.0.1 db/seeds.d/76-job_templates.rb
foreman_salt-17.0.0 db/seeds.d/76-job_templates.rb
foreman_salt-16.0.3 db/seeds.d/76-job_templates.rb
foreman_salt-16.0.2 db/seeds.d/76-job_templates.rb
foreman_salt-16.0.1 db/seeds.d/76-job_templates.rb
foreman_salt-16.0.0 db/seeds.d/76-job_templates.rb
foreman_salt-15.2.3 db/seeds.d/76-job_templates.rb
foreman_salt-15.2.2 db/seeds.d/76-job_templates.rb
foreman_salt-15.2.1 db/seeds.d/76-job_templates.rb
foreman_salt-15.2.0 db/seeds.d/76-job_templates.rb
foreman_salt-15.1.0 db/seeds.d/76-job_templates.rb
foreman_salt-15.0.0 db/seeds.d/76-job_templates.rb