Sha256: 773484ceb428efabdc70595fb472b2a07acff9e6d7e271e541004bffbf8490a5

Contents?: true

Size: 805 Bytes

Versions: 3

Compression:

Stored size: 805 Bytes

Contents

ProvisioningTemplate.without_auditing do
  templates = [{:name => 'remote_execution_ssh_keys', :source => 'snippets/_remote_execution_ssh_keys.erb', :snippet => true}]

  defaults = {:vendor => 'Remote Execution', :default => true, :locked => true}

  templates.each do |template|
    next if ProvisioningTemplate.find_by_name(template[:name])

    template.merge!(defaults)

    t= ProvisioningTemplate.create({
      :snippet => false,
      :template => File.read(File.join("#{ForemanRemoteExecution::Engine.root}/app/views/unattended", template.delete(:source)))
    }.merge(template))

    t.organizations << (Organization.all - t.organizations)
    t.locations << (Location.all - t.locations)

    raise "Unable to create template #{t.name}: #{format_errors t}" if t.nil? || t.errors.any?
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_remote_execution-0.2.3 db/seeds.d/80-provision_templates.rb
foreman_remote_execution-0.2.2 db/seeds.d/80-provision_templates.rb
foreman_remote_execution-0.2.1 db/seeds.d/80-provision_templates.rb