You can use with_items module. You can read more about it here: https://docs.ansible.com/ansible/latest/playbooks_loops.html
Thanks, Rajat On Mon, 27 Jan 2020 at 20:26, Anand Solomon <[email protected]> wrote: > Hi, > I want to create users in the database using Ansible. I need ansible to > run the task (creating user) for all the users mentioned in the vars: > schemaname. How do I do that in loop ? > > var: > schemaname: user1, user2, user3 > > tasks: > - name: This playbook will create the user. > oracle_user: > oracle_home: /home/ansible/instantclient_12_2 > user: "{{user}}" > password: "{{password}}" > service_name: "{{sname}}" > port: "{{prt}}" > hostname: "{{hostname}}" > schema: "{{schemaname}}" > schema_password: > default_tablespace: USERS > state: present > update_password: on_create > grants: "DBA" > environment: "{{oracle_env}}" > register: user_create > delegate_to: localhost > > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Development" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-devel/1807ea2b-cf26-4f4a-9c19-d2b8101072ef%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-devel/1807ea2b-cf26-4f4a-9c19-d2b8101072ef%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Rajat Taneja, Mob:+91-7358331552, LinkedIn: www.linkedin.com/in/rajat-taneja-1758abb3, Github: www.github.com/rajataneja101, Bangalore. -- You received this message because you are subscribed to the Google Groups "Ansible Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/CAGa0nXEUW-KP3tZW2M%2B-JP_7gYmOVQd75fqsZ%3DPL%2B8ZV24FVtw%40mail.gmail.com.
