No templates found for operating system

Problem: I cant see the templates I registered for a particular operating system
I added a template that runs salt-minion setup to an operating system (Ubuntu 18.04) but Foreman can’t find any configured templates for that OS in the Create Host wizard on the Operating system tab.

I tried both the network based and image based provisioning method, but neither do help. I am not sure if the template I created is invalid for some reason, therefore I added it to the end of this post.

Foreman and Proxy versions:
Foreman 1.24.0-RC2

Foreman and Proxy plugin versions:
Foreman templates 6.0.3

Distribution and version:
Ubuntu 18.04

Other relevant data:
Here’s some details about the template:
image
image

Excerpt from the template:

<%#
kind: snippet
name: saltstack_setup
model: ProvisioningTemplate
description: this snippet will configure the Saltstack Minion
snippet: true
%>
<%
etc_path = (@host.operatingsystem.family == 'Freebsd') ? '/usr/local/etc/salt' : '/etc/salt'
bin_path = (@host.operatingsystem.family == 'Freebsd') ? '/usr/local/bin' : '/usr/bin'
%>

<% if @host.operatingsystem.family == 'Debian' -%>
apt-get update
apt-get install -y salt-minion
<% elsif @host.operatingsystem.family == 'Freebsd' -%>
pkg install -y py27-salt
<% elsif @host.operatingsystem.family == 'Redhat' -%>
yum -t -y install salt-minion
<% end -%>

This is the log output when I click the “resolve template” button:

2019-11-20T15:16:27 [I|app|15832689] Started POST "/hosts/template_used?provisioning=image" for 10.239.15.19 at 2019-11-20 15:16:27 +0000
2019-11-20T15:16:27 [I|app|15832689] Processing by HostsController#template_used as */*
2019-11-20T15:16:27 [I|app|15832689]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"XXX==", "host"=>{"name"=>"eva-fauset", "organization_id"=>"1", "location_id"=>"2", "hostgroup_id"=>"", "compute_resource_id"=>"1", "compute_profile_id"=>"1", "environment_id"=>"", "puppet_proxy_id"=>"", "puppet_ca_proxy_id"=>"", "managed"=>"true", "progress_report_id"=>"[FILTERED]", "type"=>"Host::Managed", "interfaces_attributes"=>{"0"=>{"_destroy"=>"0", "type"=>"Nic::Managed", "mac"=>"", "identifier"=>"", "name"=>"eva-fauset", "domain_id"=>"", "ip"=>"", "ip6"=>"", "managed"=>"1", "primary"=>"1", "provision"=>"1", "virtual"=>"0", "tag"=>"", "attached_to"=>"", "compute_attributes"=>{"type"=>"VirtualVmxnet3", "network"=>"network-3843"}}, "new_interfaces"=>{"_destroy"=>"1", "type"=>"Nic::Managed", "mac"=>"", "identifier"=>"", "name"=>"", "domain_id"=>"", "ip"=>"", "ip6"=>"", "managed"=>"1", "primary"=>"0", "provision"=>"0", "virtual"=>"0", "tag"=>"", "attached_to"=>"", "compute_attributes"=>{"type"=>"VirtualE1000", "network"=>"dvportgroup-161088"}}}, "compute_attributes"=>{"cpus"=>"1", "corespersocket"=>"1", "memory_mb"=>"2048", "firmware"=>"bios", "cluster"=>"c301-srv-rb", "resource_pool"=>"Resources", "path"=>"/Datacenters/company/vms", "guest_id"=>"otherGuest", "hardware_version"=>"Default", "memoryHotAddEnabled"=>"1", "cpuHotAddEnabled"=>"1", "add_cdrom"=>"0", "start"=>"1", "annotation"=>"", "scsi_controllers"=>"{\"scsiControllers\":[{\"type\":\"VirtualLsiLogicController\",\"key\":1000},{\"type\":\"ParaVirtualSCSIController\",\"key\":1001}],\"volumes\":[{\"thin\":true,\"name\":\"Hard disk\",\"mode\":\"persistent\",\"controllerKey\":1000,\"size\":20971520,\"sizeGb\":20,\"storagePod\":\"pool1\",\"datastore\":null}]}", "image_id"=>"5009681b-1325-a110-0857-44739d06ecc8"}, "architecture_id"=>"1", "operatingsystem_id"=>"1", "provision_method"=>"image", "build"=>"1", "medium_id"=>"", "ptable_id"=>"", "pxe_loader"=>"", "disk"=>"", "root_pass"=>"[FILTERED]", "is_owned_by"=>"4-Users", "enabled"=>"1", "model_id"=>"", "comment"=>"", "overwrite"=>"false"}, "fakepassword"=>"[FILTERED]", "provisioning"=>"image"}
2019-11-20T15:16:27 [I|app|15832689]   Rendering common/404.html.erb within layouts/application
2019-11-20T15:16:27 [I|app|15832689]   Rendered common/404.html.erb within layouts/application (0.7ms)
2019-11-20T15:16:27 [I|app|15832689]   Rendered layouts/_application_content.html.erb (0.3ms)
2019-11-20T15:16:27 [I|app|15832689]   Rendering layouts/base.html.erb
2019-11-20T15:16:27 [I|app|15832689]   Rendered layouts/base.html.erb (22.1ms)
2019-11-20T15:16:27 [I|app|15832689] Completed 404 Not Found in 71ms (Views: 23.7ms | ActiveRecord: 7.9ms)
2019-11-20T15:16:28 [I|app|4df7f3dc] Started GET "/notification_recipients" for 10.239.15.19 at 2019-11-20 15:16:28 +0000
2019-11-20T15:16:28 [I|app|4df7f3dc] Processing by NotificationRecipientsController#index as JSON
2019-11-20T15:16:28 [I|app|4df7f3dc] Completed 200 OK in 10ms (Views: 0.2ms | ActiveRecord: 1.5ms)

Did you choose templates to use in the OS (Hosts -> Operating System -> Ubuntu 18.04 -> Templates)?

1 Like

Thanks Bernhard, I missed that step!

1 Like

Should have found this issue in the search, same problem here: Foreman finish template is not getting resolve when user-data of the image is enabled

We know this is confusing and we need to find a way of improving this. So many people hit this. In some cases we auto-select templates I believe this is done by Katello when a RHEL is synced. We need the same experience for other OSes too.

I am getting the same error and templates are assigned in the OS.