I have a yaml file file1.yaml like this,
name: teshan
age: 420
country: lka # this line might not be present
In my Ansible playbook, I need to read this, add/ modify the country and write to a file2.yaml. And if file1.yaml does not exist I need to create file2.yaml with just the country. I understand I need to load file1 to a dict and modify it. But how do I do this?
Note: This is a part of a very large playbook that I need to modify. The file names are variables. I have had no knowledge in Ansible before today so please excuse me if this is a very noob question. Any help is appericiated.