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

On Tue, Feb 14, 2017 at 9:58 PM, DHAVAL JAISWAL <[email protected]> wrote:
>  - name: Set the output of the this state
>      set_fact: A="{{image_avl.stdout}}"          -- this is coming from the
> previous registered output
>      tags: avl1
>
>    - name: Define our static value for the desired image number
>      set_fact: B={{retain}}                       -- this is coming from the
> inventory
>      tags: num2
>
>    - name: difference
>      shell: C=`expr "{{image_avl.stdout}}" - {{retain}}`
>      register: num_del
>      tags: del1
>    - debug: var="num_del"
>
> On Tue, Feb 14, 2017 at 8:58 PM, Dick Visser <[email protected]> wrote:
>>
>> On 14 February 2017 at 16:12, DHAVAL JAISWAL <[email protected]> wrote:
>> > solved it.
>>
>> Well done!
>>
>> Any chance of sharing *how* you solved it?
>>
>>
>> Thanks,
>>
>> --
>> Dick Visser
>> Sr. System & Network Engineer
>> GÉANT
>>
>> Want to join us? We're hiring: https://www.geant.org/jobs
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Ansible Project" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/ansible-project/keIYWBBA1c8/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> To post to this group, send email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CAL8fbwNOB9bkDrzDzOcBCKTY6EbbrfMxWwzHLCD2zpm_w6KfxQ%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Thanks & Regards
> Dhaval Jaiswal
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAH5ShBh4xinpsAxXdibrpL7c_OV5i9XE_jzEB4A%2BwumZ0W%2BZrw%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 
Nehal J Wani

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG6NSr%3DTwvNwr-kGBPxzK_vdeQPXb2SAR20zr%2BXB3%3DNNF7RN1g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to