You shoul provide the output of testing . Is it variable or register . Give us some more info
//v On Mon 8. Feb 2021 at 15:53, Akshay Kumar <[email protected]> wrote: > Hi All, > > I am currently working on a playbook where in i need to write the output > of SQL statement into a file . > I have 4 SQL statement and 4 hosts thus want the output in such a way that: > 1st host > SQL1 output > SQL2 Output > SQL3 output > SQL4 Output > 2nd host ... and so on > > Currently i am using this code: > > - name: trying something new > lineinfile: > line: "{{ item }}" > path: "{{ VlclFile }}" > insertafter: EOF > loop: "{{ testing }}" > delegate_to: localhost > > which gives output in the format as i want for eg: > > xxx:xxVC1:user: control_file_record_keep_time integer 365 > yyy:yyy:user: control_file_record_keep_time integer 365 > > but the output comes in a random order and thus statement 1 output for > host 1 is followed by statement 1 for host 2 and not statement 2 of host 1. > > Anyone can help me with this . > > Other block of code which i tried is as followed: > #- name: Add output of task for getting content to the local > # local_action: > # module: blockinfile > # path: "{{ VlclFile }}" > # marker: "" > # state: present > # block: "{{ hostvars[item]['testing']}}" > # insertafter: EOF > # run_once: True > # with_items: > # - "{{ play_hosts }}" > > but in this its giving me output in the form of a list and not items per > se eg: > host1 > [a: value 1,b:value2] > host2 > [a: value 1,b:value2] > > -- > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/ecc3dfa5-b963-4cc4-9976-acc28196f4fbn%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/ecc3dfa5-b963-4cc4-9976-acc28196f4fbn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJ%2BRxtT3W9vegnJ-bdw67wdBJ%3DwwgsTkgfxAUwNQwKQ%2BdWbRCA%40mail.gmail.com.
