Prevent premature variable substitution in tasks

Wasn't sure whether to raise an issue or a pull-request without a fix. Here's my PR that at least contains a test case. 

Here templating goes too far
Need to test if a value is set (or unset) - but the value is substituted
before the test

Test with
```
ansible-playbook -i test/ansible_hosts -e 'external=xyz' test/playbook-when.yml
```