I've tried a lot many ways to get this done in Ansible, I still get stuck :/
So, I have to read credentials (user & password) from one file:
file1: (dest: /home/usr/Desktop/file1.txt)
#this is a cred file
number= 8910334
user= xyz #(this maybe username=xyz also)
password= abc
After reading the file content, I need to split where ever I find a ('=') sign with 'user' & 'password' based on the following:
user key= user
user value= xyz
password key= password
password value= abc
file2: (dest: /home/usr/Desktop/file2.txt)
#Hi, I need credentials
school= spsg
user = #(this value may be blank or may be filled with some other entry or it may be xyz.user.name= )
password= #(this value may be blank or may be filled with some other entry or it may be xyz.password.value= )
Now, in file2, I want the user=________ value & password=________ value replaced by the extracted user value & password value from file1. (the line number of user & password may vary, so don't fix the line numbers as [1] & [2] respectively)
Also, along with file2, there are some more files which need the values from file1, so it would be better if this task is done with loops.
Please suggest me with possible YAML code for getting this done. Thanks :)