Sha256: bd3b369825f7bd78840d4bf41ef82383a8826957465cbc7a4edb025b81730267

Contents?: true

Size: 1.3 KB

Versions: 15

Compression:

Stored size: 1.3 KB

Contents

organizations = Organization.unscoped.all
locations = Location.unscoped.all
User.as_anonymous_admin do
  RemoteExecutionFeature.without_auditing do
    if Rails.env.test? || File.basename($PROGRAM_NAME) == '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
      Dir[File.join("#{ForemanAnsible::Engine.root}/app/views/foreman_ansible/"\
                    'job_templates/**/*.erb')].each do |template|
        sync = !Rails.env.test? && Setting[:remote_execution_sync_templates]
        template = JobTemplate.import_raw!(File.read(template),
                                           :default => true,
                                           :locked => true,
                                           :update => sync)
        template.organizations = organizations if SETTINGS[:organizations_enabled] && template.present?
        template.locations = locations if SETTINGS[:locations_enabled] && template.present?
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
foreman_ansible-2.2.14 db/seeds.d/75_job_templates.rb
foreman_ansible-2.2.13 db/seeds.d/75_job_templates.rb
foreman_ansible-2.2.12 db/seeds.d/75_job_templates.rb
foreman_ansible-2.2.11 db/seeds.d/75_job_templates.rb
foreman_ansible-2.2.10 db/seeds.d/75_job_templates.rb
foreman_ansible-2.2.9 db/seeds.d/75_job_templates.rb
foreman_ansible-2.2.8 db/seeds.d/75_job_templates.rb
foreman_ansible-2.2.7 db/seeds.d/75_job_templates.rb
foreman_ansible-2.2.6 db/seeds.d/75_job_templates.rb
foreman_ansible-2.2.5 db/seeds.d/75_job_templates.rb
foreman_ansible-2.2.4 db/seeds.d/75_job_templates.rb
foreman_ansible-2.2.3 db/seeds.d/75_job_templates.rb
foreman_ansible-2.2.2 db/seeds.d/75_job_templates.rb
foreman_ansible-2.2.1 db/seeds.d/75_job_templates.rb
foreman_ansible-2.2.0 db/seeds.d/75_job_templates.rb