# Increment - Ansible variable assigment

**URL:** <https://forum.ansible.com/t/increment-ansible-variable-assigment/18765>\
**Category:** Ansible Project\
**Created:** [July 15, 2015, 8:16am UTC](https://forum.ansible.com/t/increment-ansible-variable-assigment/18765 "2015-07-15T08:16:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Esteban\_Freire](https://avatars.discourse-cdn.com/v4/letter/e/d26b3c/32.png) [@Esteban\_Freire](https://forum.ansible.com/u/Esteban_Freire)\
**Post date:** [July 15, 2015, 8:16am UTC](https://forum.ansible.com/t/increment-ansible-variable-assigment/18765/1 "2015-07-15T08:16:53Z")

</div>

Hi all,

I have the following vars file:

`student_accounts: user: username: user password: pass accounts_to_create: 2 start_number_account: 1`

And then the following task:

`

- name: Generate the sequence numbers  
set\_fact: item.value.start\_number\_account={{ item.value.start\_number\_account | int + 1 }}  
register: item.value.start\_number\_account  
with\_dict: student\_accounts  
when: (item.value.start\_number\_account != item.value.accounts\_to\_create)  
tags:

- create\_student\_account

- name: Create an user account in ON for the users defined on users.yml file  
sudo: True  
sudo\_user: oneadmin  
shell: oneuser create “{{ item.value.username }}{{ item.value.start\_number\_account }}” “{{ item.value.password }}{{item.value.start\_number\_account }}”  
with\_items: item.value.start\_number\_account.results  
tags:

- create\_student\_account  
`

My idea is to use this task to create several accounts on OpenNebula at the same time, in this case, so many accounts as I have specified on “`accounts_to_create`” variable. So I use the `start_number_account variable to increment and then I would like to execute the command to create the account as many times as I have specified on ``"`accounts\_to\_create`" using the incremental variable and taking the advantage of ```it to also add the number to the account so it is a different account. The command would be executed like:``

`oneuser create "user1" "pass1"`  
```````oneuser create “user2” “pass2” ` `oneuser create “user3” “pass3”```  
[…]

`I tried with set fact but I think I am not understanding it well. Also, If you know another method to get this, please let me know and any help is appreciated :)`

`Thanks in advance,`  
`Esteban`
