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

-- 
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/afb466d1-705c-4021-9fae-49dda9de0bdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to