Hi Vinod and dick,

Thank you, please look at the json file on the remote server. I'm trying to
replace the nas path using win_lineinfile, but the path that I'm providing
is updating at the end of the file.

Hi dick, please update how to do with from_json and to_json.

Json file:

[
    {
         "Service_id" : "node1"
         "Source_path" : "\\\\192.168.1.1\\data\\nonprod"
         "Source_type" : "NAS"
         "Deztination_type": "Nas"
      }
]

Playbook:

Win_lineinfile:
   Path: D:\\dest\\config.json
   regexp : '^source_path'
   insertafter: '^service_id'
   line: '\\\\192.168.1.2\\data\\nonprod'
   state: present

Thankyou,
Shyam



On Sat, Apr 11, 2020, 3:41 AM Dick Visser <dick.vis...@geant.org> wrote:

> It depends on your data.
> Please post your json and tell what you want to manipulate exactly.
> Lineinfile sounds fragile. You might have better results with from_json,
> combine, and to_json.
>
>
> On Fri, 10 Apr 2020 at 21:02, syam rhel <shyam....@gmail.com> wrote:
>
>> Hi All,
>>
>> Is it possible to update the data of json file using ansible modules.
>>
>> I tried on windows machine using win_lineinfile module but the required
>> file is not updating.
>>
>> The line is updating at the end of the file.
>>
>> Can any one suggest the solution for editing fields in json file.
>>
>> Thank you,
>>
>> --
>> 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-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/61a135e8-2c2a-4751-b21f-884c25debda3%40googlegroups.com
>> .
>>
> --
> Sent from a mobile device - please excuse the brevity, spelling and
> punctuation.
>
> --
> 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-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwNu7%2BAkRyeCdw2B-x2C1zV0sg8muLuD1KA0urgw0NWyNQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAL8fbwNu7%2BAkRyeCdw2B-x2C1zV0sg8muLuD1KA0urgw0NWyNQ%40mail.gmail.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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAN0_vCY%2BfrtN6p5dzGFJwnactVujHBNs6ZYRDj4fKdX17sYJHg%40mail.gmail.com.

Reply via email to