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