Sha256: 458761e29d86b1c5c3781662297bf6ea327c8b8a1f940a691cba8aeadc78cd08

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.1.2 db/seeds.d/80-provision_templates.rb
foreman_remote_execution-0.1.1 db/seeds.d/80-provision_templates.rb
foreman_remote_execution-0.1.0 db/seeds.d/80-provision_templates.rb