Ansible: given a list of ints in a variable, define a second list in which each element is incremented
<p>Let's assume that we have an Ansible variable that is a <code>list_of_ints</code>.</p>

<p>I want to define an <code>incremented_list</code>, whose elements are obtained incrementing by a fixed amount the elements of the first list.</p>

<p>For example, if this is the first variable:</p>

<pre><code>---
# file: somerole/vars/main.yml

list_of_ints:
  - 1
  - 7
  - 8
</code></pre>

<p>assuming an increment of 100, the desired second list would have this content:</p>

<pre><code>incremented_list:
  - 101
  - 107
  - 108
</code></pre>

<p>I was thinking of something on the lines of:</p>

<pre><code>incremented_list: "{{ list_of_ints | map('add', 100) | list }}"
</code></pre>

<p>Sadly, Ansible has <a href="http://docs.ansible.com/ansible/playbooks_filters.html#math" rel="nofollow">custom filters for logarithms or powers</a>, but not for basic arithmetic, so I can easily calculate the log10 of those numbers, but not increment them.</p>

<p>Any ideas, apart from a pull request on <a href="https://github.com/ansible/ansible/blob/v2.1.1.0-1/lib/ansible/plugins/filter/mathstuff.py" rel="nofollow">https://github.com/ansible/ansible/blob/v2.1.1.0-1/lib/ansible/plugins/filter/mathstuff.py</a> ?</p>