Print out contents of a file using ansible Print out contents of a file using ansible shell shell

Print out contents of a file using ansible


You are trying to call two different modules from a single task: script and shell. You need to break them up... one module per task! However, there's a better way to do it by capturing the output of the script with register, and using the debug module in a subsequent task to display it:

tasks:  - name: This option    script: "./getIt.py -s {{ myhostname }} -u {{ myuser }} -p {{ mypass }}"    register: script    when: user_option == 'L'  - name: stdout of getIt    debug: msg={{ script.stdout }}    when: script is defined and script|succeeded