Hi,
First of all, a very happy new year to all of you.
I am trying to find a way to make it possible to add “-e force=yes” to an ansible-playbook command line to force certain things, like unpacking an archive, even if it has not changed. I want to add “when: force” to such tasks.
My set-up is role-based, so the first thing a tried is adding force: false in defaults/main.yml for every role that uses the variable. Unfortunately, if I use “-e force=yes” the variable is not magically interpreted as a boolean. So I could use “when: force|bool”, but I tried to avoid that by setting "forced: “{{ force | default(False) | bool }}” and using the “forced” variable instead of “force”. But it seems that variables set in vars/main.yml are always converted to strings. See the files at https://gist.github.com/jcassee/8217906 and a full Ansible environment at https://letscrate.com/f/jcassee/github/ansible-issue.tar.gz
Two question:
- Is the conversion to strings a bug or expected behaviour?
- What is the simplest way to tie “-e force=yes” to “when: force”?
Regards,
Joost