I mean, what does the output of

- name: Dump result
  ansible.builtin.debug:
    msg: "{{ result }}"

look like? It presumably has a 'json' field? Which itself contains a 
'value'?
Without a reasonable approximation of your input, I can't possibly suggest 
how to create expected output from it.

On Monday, July 31, 2023 at 2:43:20 PM UTC-4 Veera wrote:

> it looks like 
> 'servera',  'serverb', 'serverc', 'serverd'
>
>
> and I want result to be like ..
> $cat /tmp/my_inv
> servera
> serverb
> serverc
> serverd
>
>
> On Tuesday, August 1, 2023 at 12:00:58 AM UTC+5:30 Todd Lewis wrote:
>
>> What does your "result" look like?
>>
>> On Monday, July 31, 2023 at 1:11:16 PM UTC-4 Veera wrote:
>>
>>> While collecting the inventory from a dynamic source , I am able to  
>>> filter the hostname and print them as below as expected.
>>>
>>> servera
>>> serverb
>>> serverc
>>> serverd
>>>
>>> when set to facts with set_fact  also fine  and print in the order one 
>>> below the other.
>>> However when I try to write into a file with copy module , 
>>>  
>>>     - name:  Write to the file 
>>>       ansible.builtin.copy:
>>>         content: "{{ result['json']['value'] |map(attribute='hostname') 
>>> }}"
>>>         dest: "{{my_inv}}" 
>>>
>>> the format collapses as below.
>>> 'servera',  'serverb', 'serverc', 'serverd'
>>>
>>> How can I write the  output  in the list format(line by line)  as  this 
>>> file will be used to read  as an inventory for other tasks . 
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>

-- 
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/385f917a-7a23-44c5-8c57-150c9e09a83an%40googlegroups.com.

Reply via email to