centos 使用Ansible执行Karaf客户端命令

0h4hbjxa  于 2022-11-07  发布在  其他
关注(0)|答案(1)|浏览(175)

我正在尝试执行的功能:列表命令卡拉夫对centos 7与ansible剧本。
在终端上运行此命令可以正常工作:

sudo /opt/runtimeV8/Talend-Runtime-V8.0.1/bin/start;sleep 30;/opt/runtimeV8/Talend-Runtime-V8.0.1/bin/client -r 20 feature:list > /tmp/log.txt

我想用Ansible运行相同的命令,但最后一个命令出错。

- name: Command 1
    shell: sudo /opt/runtimeV8/Talend-Runtime-V8.0.1/bin/start

  - name: Command 2
    command: sleep 30

  - name: Command 3
    shell:  /opt/runtimeV8/Talend-Runtime-V8.0.1/bin/client feature:list > /tmp/log.txt
    ignore_errors: true

即使是忽略错误似乎也改变不了什么大事。

"msg": "non-zero return code"

并且日志文件只包含输出的第一行:

2lpgd968

2lpgd9681#

应使用批处理模式,命令将变为:

- name: Command 3
    shell: $KARAF_HOME/bin/client  -b <<< "feature:list" > /tmp/log.txt
    ignore_errors: true

answer found here : https://stackoverflow.com/questions/70355095/unable-to-run-client-command-for-apache-karaf-4-3-3-through-remote-server

相关问题