Invoking the shell module is not necessary. One can use jinja2. An example:
$ cat a.yaml
- hosts: localhost
tasks:
- set_fact: A="5"
- set_fact: B="6"
- set_fact: C="{{ A|int - B|int }}"
- debug: var=C
$ ansible-playbook -v a.yaml
No config file found; using defaults
[WARNING]: Host file not found: /etc/ansible/hosts
[WARNING]: provided hosts list is empty, only localhost is available
PLAY [localhost]
****************************************************************************************************************************************************************************
TASK [Gathering Facts]
**********************************************************************************************************************************************************************
ok: [localhost]
TASK [set_fact]
*****************************************************************************************************************************************************************************
ok: [localhost] => {"ansible_facts": {"A": "5"}, "changed": false}
TASK [set_fact]
*****************************************************************************************************************************************************************************
ok: [localhost] => {"ansible_facts": {"B": "6"}, "changed": false}
TASK [set_fact]
*****************************************************************************************************************************************************************************
ok: [localhost] => {"ansible_facts": {"C": "-1"}, "changed": false}
TASK [debug] ********************************************************************************************************************************************************************************
ok: [localhost] => {
"C": "-1",
"changed": false
}
PLAY RECAP **********************************************************************************************************************************************************************************
localhost : ok=5 changed=0 unreachable=0 failed=0
>>
ansible-proje...@googlegroups.com.
>> To post to this group, send email to
ansible...@googlegroups.com.
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
ansible-proje...@googlegroups.com.
> To post to this group, send email to
ansible...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/ansible-project/CAH5ShBh4xinpsAxXdibrpL7c_OV5i9XE_jzEB4A%2BwumZ0W%2BZrw%40mail.gmail.com.
Nehal J Wani