need help to configure a loop

597 views
Skip to first unread message

y c

unread,
Jun 28, 2021, 6:14:40 AM6/28/21
to Ansible Project
Hello guys,
I need to run loop with a file but run all tasks item by item. Here is my conf:

- name: test
  hosts: yo

  tasks:
   - name: task 1
     win_uri:
       url: https://{{ frontsrc }}/{{ item }}/
     with_lines: cat /etc/ansible/group_vars/afyahia

   - name: Task 2
     win_uri:
       url: https://{{ frontsrc }}.{{ item }}/
     with_lines: cat /etc/ansible/group_vars/afyahia

in afyahia file, i have:
appli1
appli2
...
applin

If i run the playbook it's running like:
task 1
appli1
appli2
...
...

task 2
appli1
appli2
...

I would like to run it like this:
task 1
appli1

task 2
appli1

task 1
appli2

task 2
appli2

task 1
...

task 2
...

Is it possible? 
thx

david...@mycit.ie

unread,
Jun 28, 2021, 6:56:44 AM6/28/21
to Ansible Project
Message has been deleted
Message has been deleted

Roberto J. R. Paz

unread,
Jun 28, 2021, 11:01:06 AM6/28/21
to ansible...@googlegroups.com, david...@mycit.ie
You can't apply a loop to a block. A possible caveat for that is to include the code of the block as a separated playbook and run the loop on that.


El lun, 28 jun 2021 a las 9:53, Yahia CHILALI (<yahi...@gmail.com>) escribió:
Hi again,
I can't feed the correct syntax... i tried with with_lines: cat /etc/ansible/group_vars/afyahia or loop: cat /etc/ansible/group_vars/afyahia
Do you know the good attribute?
ERROR! 'loop' is not a valid attribute for a Block
ERROR! 'with_lines' is not a valid attribute for a Block

--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/dc923fa6-4c2f-4590-9d5d-606d0e10e950n%40googlegroups.com.

--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CACRVY78MS_H42tS%3DYP-HRTn%2BUH6JDTGZ0pEw2XdL%3Dv5gbLCfMg%40mail.gmail.com.


--

Roberto Paz
Reply all
Reply to author
Forward
0 new messages