ansible conditions

Hi,

Below snippet sometimes working and sometimes failing. So, i am executing it with jenkins and idea is that if parameter is defined then script should run otherwise it should not run.

Can anyone please enlighten me what’s wrong ?

Hi All,

Any ideas ?

Sidh

Not without the actual error message you get.

when: is not working as expected, So, even if i don’t pass parameters then also it tries to run and then fails. So error is : from script i.e. parameters not passed.
But ideally, it should skip this if parameter is not supplied.

Regards,
Sidh

Is it possible the varibale is defined but unset. Why not test that the length of string is > 0 instead?

Can you please give me an example for that or refer documentation on how can i do this : "when’ in ansible ?

Hi Sudhir,

You’re barely making sense and it doesn’t help when you don’t provide any code.

Nobody can help you if they don’t understand you.

Hi All,

Seems like some miscommunication here. I provided code in my first comment :

Hi Sudhir,
Try logging the actual values:

- debug: var=vg_name verbosity=3

Thanks, got more info after debugging.
It’s resolved. Idea and when condition was ok. Only issue was that i was evaluating wrong parameterized input in this case.

Regards,
Sidh