I am trying to convert a yml file into json. I need to pick the list of yml files from file1.txt and convert all those files to json.
Below is the code that I am using
- hosts: localhost
tasks:
- name: convert yml to json
shell: cat /home/testadmin/{{ item }}.yml
register: result
- copy:
dest: ./{{ item }}.json
content: "{{ result.stdout | from_yaml | to_nice_json }}"
with_lines: cat file1.txt
The code should pick up the filename from file1.txt and then convert the file 1 by 1. I would like to know how to put all these commands to convert yml to json in a loop.
The actual result should replace all the .yml files in file1.txt and convered into the json format with the same name