Preseed w/ host group gives "undefined method token"

Greetings all,

I'm trying to setup a Foreman install as a test with preseed-based
provisioning of Ubuntu desktops. I've got the various PXE stuff working
such that my test machines correctly retrieve the PXE menu and get a boot
entry based on their subnet/hostgroup. The problem is that the evaluation
of the Preseed Default template fails.

I'm testing the template rendering via curl with something like:

curl --insecure
'https://foreman-server/unattended/template/Preseed%20Default/hp8100'

where "hp8100" is the host group I've defined.

I'm pretty sure the problem stems from the fact that I'm using host groups
rather than an individual host to run the preseed. I found that this:

d-i netcfg/get_domain string <%= @host.domain %>

failed with an unknown getter for 'domain' on the host object (which is
actually a host group), so I commented that out. I get as far as trying to
execute the call to <%= foreman_url("finish") %> at the very bottom of the
script, but I die with:

There was an error rendering the template: undefined method `token' for
#<Hostgroup:0x7ff75650e0b0>

Removing the reference to foreman_url allows the rest of the template to
render correctly, but of course the preseed finish script is missing at
that point.

Is there some setting I need to enable to generate tokens for a host in a
hostgroup-oriented call? Is there some way to disable token generation for
this call? As far as I can tell, provisioning scripts for the other
distros embed what's in the Ubuntu late_script call directly in their
initial provisioning template, so there's no need to access the "finish"
URL in the initial template.

I'm running stock templates (aside from the work around listed above)
against 1.3 RC4.

Any help would be appreciated!

Best regards,
Zac Bedell

> Greetings all,
>
> I'm trying to setup a Foreman install as a test with preseed-based
> provisioning of Ubuntu desktops. I've got the various PXE stuff working
> such that my test machines correctly retrieve the PXE menu and get a boot
> entry based on their subnet/hostgroup. The problem is that the evaluation
> of the Preseed Default template fails.
>
> I'm testing the template rendering via curl with something like:
>
> curl --insecure '
> https://foreman-server/unattended/template/Preseed%20Default/hp8100'
>
> where "hp8100" is the host group I've defined.
>
> I'm pretty sure the problem stems from the fact that I'm using host groups
> rather than an individual host to run the preseed. I found that this:
>
> d-i netcfg/get_domain string <%= @host.domain %>
>
> failed with an unknown getter for 'domain' on the host object (which is
> actually a host group), so I commented that out. I get as far as trying to
> execute the call to <%= foreman_url("finish") %> at the very bottom of
> the script, but I die with:
>
> There was an error rendering the template: undefined method `token' for
> #<Hostgroup:0x7ff75650e0b0>
>

Tokens are only for hosts, and since you are doing a hostgroup based
rendering, it fails… as a quick workaround, you can turn off tokens under
settings.

Ohad

··· On Wed, Oct 9, 2013 at 7:00 PM, Zachary Bedell wrote:

Removing the reference to foreman_url allows the rest of the template to
render correctly, but of course the preseed finish script is missing at
that point.

Is there some setting I need to enable to generate tokens for a host in a
hostgroup-oriented call? Is there some way to disable token generation for
this call? As far as I can tell, provisioning scripts for the other
distros embed what’s in the Ubuntu late_script call directly in their
initial provisioning template, so there’s no need to access the "finish"
URL in the initial template.

I’m running stock templates (aside from the work around listed above)
against 1.3 RC4.

Any help would be appreciated!

Best regards,
Zac Bedell


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.

The only reference I can find to tokens under settings is "token_duration" which says "0 to disable." I've tried setting that value to both zero and non-zero, but it has no effect on the "undefined method" error.

-Zac

··· On Oct 9, 2013, at 12:41 PM, Ohad Levy wrote: > On Wed, Oct 9, 2013 at 7:00 PM, Zachary Bedell wrote: > I'm pretty sure the problem stems from the fact that I'm using host groups rather than an individual host to run the preseed. I found that this: > > d-i netcfg/get_domain string <%= @host.domain %> > > failed with an unknown getter for 'domain' on the host object (which is actually a host group), so I commented that out. I get as far as trying to execute the call to <%= foreman_url("finish") %> at the very bottom of the script, but I die with: > > There was an error rendering the template: undefined method `token' for # > > Tokens are only for hosts, and since you are doing a hostgroup based rendering, it fails.. as a quick workaround, you can turn off tokens under settings.