- The parameter -e, --extra-vars is missing in your run-string
shell> ansible-playbook -i ip "{'template': true}" sample.yml
Because the first parameter without option is considered a playbook you should have seen the error message:
ERROR! the playbook: {"template": true} could not be found
- The Jinja test boolean should always be available the same way the test defined is. I can't reproduce the problem. The playbook below
- hosts: localhost
tasks:
- assert:
that:
- template is defined
- template is boolean
fail_msg: template must be defined and type boolean
works as expected. The test will pass if the variable template is defined and boolean
shell> ansible-playbook -e '{"template": true}' pb.yml
PLAY [localhost] ******************************************************************************
TASK [assert] *********************************************************************************
ok: [localhost] => changed=false
msg: All assertions passed
PLAY RECAP ************************************************************************************
localhost: ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Otherwise, the play fails
shell> ansible-playbook pb.yml
PLAY [localhost] ******************************************************************************
TASK [assert] *********************************************************************************
fatal: [localhost]: FAILED! => changed=false
assertion: template is defined
evaluated_to: false
msg: template must be defined and type boolean
PLAY RECAP ************************************************************************************
localhost: ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0