you can use the command modules to read the file using what ever current method you are currently using to read the file, otherwise you can check which file module is closer to the functionality you need for example is it to be read by a version control system, then it is git, or is it to be read to be processed then template or read to be copied then it is fetch or copy. you need to let us know the original problem and describe it well, your description is very generic and a bit vague
run a command: A, A will generate file B, B content is simple, just a URI, i.e. http://xxxx.yyy.zzz/aaa
I want to read B and save the content as a variable D.
update file C in another location. C is a configuration file, there is a field: “uri”, I want to update this file C as a template and field “uri” is updated with variable D, i.e. “uri = {{ D }}”
I will read more “fetch” and “slurp”, but from my brief reading, I think I could not save the content of fetch file as variable then pass back to template in the same YAML file.
Sorry I am new learner, I asked a lot of dumb questions.
That is what I like about Ansible, if you do not know how to do it the Ansible way, try to use the command modules and do it the same way you are doing now, you can add register, ignore_error, and created flag for better handling and relationship with other surrounding tasks