I have written an shell script that outputs an list of applications and the ports on which these applications listen (I can ajust this output to anything I want)
{ application: 'foo', port: '10' }
{ application: 'bar', port: '20' }
First the shell script is executed in ansible and the output is in an variable: outputscript.
Now I want to use this in an ansible loop something like this:
- name: Execute script
shell: "/home/test/test.sh"
register: output_script
- name: change file
line_in_file:
path: /home/{{ item.application }}/file.txt
regex: '^LISTEN '
insertafter: '^#LISTEN '
line: Listen {{ item.port }}
with_items:
- {{ output_script.stdout_lines }}
How can I do this?