在ansible剧本中,我使用一个包含perl脚本文件的文件来执行一些任务。如何让ansible为perl脚本捕获STDIN?
> #!/usr/bin/perl -w
> ...
> print OUTPUT_FILE "\n";
> my $datasetid_target = <STDIN>; <<--not able to link to ansible playbook
> $datasetid_target; print OUTPUT_FILE
> qq("datasetId":"$datasetid_target",);该脚本作为独立脚本运行良好,但使用ansible时不打印任何内容。
我尝试使用args、vars、expect、stdin,但没有成功。
预期结果是这样的:(请参考快照)
> - name: edit source file
> shell: perl "{{ project_dir }}/edit_dataschema.pl"
> args:
> stdin: <<-- here is my problem
> "{{datasetid_target}}"发布于 2019-07-14 14:18:31
首先,为了以防万一,请检查在同一行传递参数是否有任何影响(as seen here):
- name: edit source file
shell: perl "{{ project_dir }}/edit_dataschema.pl"
args:
stdin: "{{datasetid_target}}"其次,检查string conversion as made here是否会有所帮助:
args:
stdin: "{{datasetid_target | string}}"https://stackoverflow.com/questions/57024573
复制相似问题