register variable in conjunction with when_changed

I think I understand what's happening; the $packet_changed "variable" isn't
getting "auto-created" because the action isn't being executed due to the
only_if
So I tried the following workaround:
In group_/vars/all, I defined package_changed with the proper default
"skeleton" :
package_changed: {"changed": false, "item": "", "msg": "", "rc": 0,
"results": [""]}

This seems to work : )
Am I missing something? Alternatively, can anyone point me to a better
solution/workaround?

I think you've got it exactly.

I think this is a (somewhat minor) bug we need to file. When
skipping a conditional statement, store "None" in the value of the
variable being registered, and is_set($foo) of a variable that is None
should return False.

Please file a github on this one and we can take care of it.

Ticket filed (note: issue has easy and pretty clean workarounds):

Issue #2269

My solution to this was to initialize the variable to track. The result was something like this:

I used to do that (initialise the variable), then started to use "when_set":
https://coderwall.com/p/q7dj5w?i=8&p=2&q=sort%3Ascore+desc&t[]=ansible