Re: Fwd: Set environment variables

2022-05-17 Thread Valerio Pachera
Il giorno ven 13 mag 2022 alle ore 16:10 Willy Tarreau  ha
scritto:

> Hi Valerio,
>
> On Mon, May 09, 2022 at 10:14:09AM +0200, Valerio Pachera wrote:
> > Unfortunately I'm not a developer so it will take too much time form me
> to
> > contribute to the code.
>
> I've just implemented it in 2.6-dev as this commit:
>
> https://github.com/haproxy/haproxy/commit/973cf90714
>
> Once 2.6 is released we may backport it to 2.5 as it's expected to be
> trivial and with no side effect.
>

Thank you very much!


Re: Fwd: Set environment variables

2022-05-13 Thread Willy Tarreau
Hi Valerio,

On Mon, May 09, 2022 at 10:14:09AM +0200, Valerio Pachera wrote:
> Unfortunately I'm not a developer so it will take too much time form me to
> contribute to the code.

I've just implemented it in 2.6-dev as this commit:

https://github.com/haproxy/haproxy/commit/973cf90714

Once 2.6 is released we may backport it to 2.5 as it's expected to be
trivial and with no side effect.

Willy



Re: Fwd: Set environment variables

2022-05-11 Thread Willy Tarreau
On Mon, May 09, 2022 at 10:14:09AM +0200, Valerio Pachera wrote:
> Thank you very much willy for your reply.
> Unfortunately I'm not a developer so it will take too much time form me to
> contribute to the code.

No problem, do not worry. I've added an issue for this one:

   https://github.com/haproxy/haproxy/issues/1692

Thanks!
Willy



Re: Fwd: Set environment variables

2022-05-09 Thread Valerio Pachera
Il giorno dom 8 mag 2022 alle ore 11:07 Willy Tarreau  ha scritto:

>
> With that said, I admit that it could be useful to have another variable
> such as HAPROXY_SERVER_SSL to indicate if SSL is being used, and possibly
> another one such as HAPROXY_SERVER_PROTO to indicate when a protocol is
> being forced (e.g. h2).
>
> If you think your only solution would be to have such variables, feel
> free to have a look at the code to see how to add them. That should be
> simple enough for a first contribution. That's something we can merge
> late in the cycle, and possibly even backport to 2.5.
>
>
> Thank you very much willy for your reply.
Unfortunately I'm not a developer so it will take too much time form me to
contribute to the code.
I think I'll use a naming convention.

Valerio.


Re: Fwd: Set environment variables

2022-05-08 Thread Willy Tarreau
Hi Valerio,

On Fri, May 06, 2022 at 04:25:23PM +0200, Valerio Pachera wrote:
> Hi, I have several backend configuration that make use of a custom script:
> 
> external-check command 'custom-script.sh'
> 
> The script read uses the environment variables such as $HAPROXY_PROXY_NAME.
> I would like to be able to set and environment variable in the backend
> declaration, before running the external check.
> This environment variable will change the behavior of custom-script.sh.
> 
> Is it possible to declare environment variables in haproxy 1.9 or later?
> 
> What I need is to make custom-script.sh aware if SSL is used or not.
> If there's another way to achieve that, please tell me.

You can only set variables in the global section using "setenv" and
"presetenv", and they are in effect at the moment they're parsed (thus
they're even usable later in the config file). But there's nothing to
set per-backend variables that would be used by the external-check
commands. If you know that your whole haproxy process is either with
or without SSL, that might still work for you. Otherwise maybe you
should use two different scripts for SSL a clear servers.

You could possibly also rely on the server's name and/or port as a hint
to your script.

With that said, I admit that it could be useful to have another variable
such as HAPROXY_SERVER_SSL to indicate if SSL is being used, and possibly
another one such as HAPROXY_SERVER_PROTO to indicate when a protocol is
being forced (e.g. h2).

If you think your only solution would be to have such variables, feel
free to have a look at the code to see how to add them. That should be
simple enough for a first contribution. That's something we can merge
late in the cycle, and possibly even backport to 2.5.

Willy



Fwd: Set environment variables

2022-05-06 Thread Valerio Pachera
Hi, I have several backend configuration that make use of a custom script:

external-check command 'custom-script.sh'

The script read uses the environment variables such as $HAPROXY_PROXY_NAME.
I would like to be able to set and environment variable in the backend
declaration, before running the external check.
This environment variable will change the behavior of custom-script.sh.

Is it possible to declare environment variables in haproxy 1.9 or later?

What I need is to make custom-script.sh aware if SSL is used or not.
If there's another way to achieve that, please tell me.

Thank you.