Bootstrap FreeKB - Ansible - Addition
Ansible - Addition

Updated:   |  Ansible articles

Here is a simple example of how you can perform addition in Ansible.

---
- hosts: localhost
  tasks:
  - name: addition example
    set_fact:
      result: "{{ 5 + 1 }}"

  - debug:
      var: result
...

 

Which should return the following.

ok: [localhost] => {
    "result": "6"
}

 

Likewise, you should be able to work with decimal point numbers and variables, perhaps something like this.

---
- hosts: localhost
  vars:
    mynumber: 5.75
  tasks:
  - name: addition example
    set_fact:
      result: "{{ mynumber + 1.125 }}"

  - debug:
      var: result
...



Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 65a790 in the box below so that we can be sure you are a human.