Executing a module according to a variable value

Hey

I would like to execute a module only when a certain variable is set to specific value:
pseudo-code
if ok_to_exec == true
exec module stuff

Please advise on how to do that, I found something that might be similar, but not exactly:
in the module, add the following line:
to_exec_count = "${var.ok_to_exec ? 0 : 1}
default for ok_to_exec is “false”
when set to true, all resources related to the module will be executed.
Is that correct ?

thank you in advance,
Michal