Hi,
I decided to explore this a bit further, is it simply because
server-template and "server.c:parse_server" are executed at the
initialization phase when the sample fetches feature isn't ready? This
could be an implementation detail but I wonder if there's an opportunity to
make it more obvious in the manual, or I didn't do enough homework reading
the manual.
[image: image.png]
I was able to get what I want, slightly differently though. (using env
variables via ${variable}
<https://docs.haproxy.org/dev/configuration.html#2.3> syntax)
server-template svcname 1-4 svcname.${dcname}.discovery.com check resolvers
systemdns init-addr none
Thank you
On Wed, Nov 16, 2022 at 7:49 PM Abhijeet Rastogi <[email protected]>
wrote:
> Hi,
>
> >Are sample fetches only available in specific blocks
>
> Small correction over my previous statement. It isn't like "var()" can't
> be used in the backend block, as it works with the "http-request"
> directive.
>
> Secondly, the correct line for server-template is,
> server-template svcname 1-4 svcname.%[var(proc.dcname)].discovery.com check
> resolvers systemdns init-addr none
>
> I simply made a mistake while writing the email.
>
> On Wed, Nov 16, 2022 at 6:22 PM Abhijeet Rastogi <[email protected]>
> wrote:
>
>> Hi HAproxy community,
>>
>> There is a requirement to dynamically construct server/server-template
>> lines based on some variables.
>>
>> *global section (dcname == us1) :- *
>> set-var proc.dcname env(dcname)
>>
>> *Backend section:- *
>> # svcname.us1.discovery.com is a valid DNS record
>> server-template svcname 1-4 svcname.%[var(proc.dcname)].discovery.com
>>
>> It looks like this isn't possible because in my testing, it doesn't
>> evaluate the var fetch while setting "server.hostname" from
>> server-template. This seems to be true for the "server" directive as well.
>>
>> *Error with server block:- *
>> Config: server abc.def.%[var(proc.dcname)] 127.0.0.1:1234
>> Error: : character '%' is not permitted in server name
>> 'abc.def.%[var(proc.dcname)]'
>>
>> * Can someone point to the section in the configuration guide
>> <https://docs.haproxy.org/dev/configuration.html#7.3.2> which highlights
>> this limitation?
>> * Are sample fetches only available in specific blocks or directives? Is
>> there a general rule?
>>
>> --
>> Cheers,
>> Abhijeet (https://abhi.host)
>>
>
>
> --
> Cheers,
> Abhijeet (https://abhi.host)
>
--
Cheers,
Abhijeet (https://abhi.host)