Prevent variable overwrite in skipped tasks

This is the first time I hit wall with ansible after thousands lines of yaml so maybe I’m missing something.

I have a main playbook a.yml:

  • include b.yml

  • include c.yml
    when: 0 == 1

  • debug: var=x

where both b.yml and c.yml set value of ‘x’ variable. I understand that this is by design yet if I have a single role with two separate flows setting same variables I found no way to work around this and skip c.yml entirely.

Did anyone try do hack this directly in ansible source? I need to comment out portion where ansible assigns {‘skipped’: True} to my variable.

Thanks,
Bill

ansible sets registered variables on skipped tasks so you can query
them for setvar|skipped, I suggest you name the vars differently and
set a 'x' var depending on the value of those 2.