我试图通过拍摄/path/to/zookeeper/bin/zkServer.sh状态并检查rcvariables来findZookeeper进程的状态 。 但是ansible说输出没有输出中的rcvariables。
我附上了几个片段:
在这里,输出显示rc
changed: [staging] => { "changed": true, "cmd": [ "/path/to/zookeeper/bin/zkServer.sh", "status" ], "delta": "0:00:00.222272", "end": "2017-10-17 14:30:23.937679", "invocation": { "module_args": { "_raw_params": "/path/to/zookeeper/bin/zkServer.sh", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true } }, "rc": 0, "start": "2017-10-17 14:30:23.715407", "stderr": "JMX enabled by default\nUsing config: /path/to/zookeeper/bin/../conf/zoo.cfg", "stderr_lines": [ "JMX enabled by default", "Using config: /path/to/zookeeper/bin/../conf/zoo.cfg" ], "stdout": "Mode: follower", "stdout_lines": [ "Mode: follower" ] }
并ansible显示以下错误
fatal: [staging]: FAILED! => { "failed": true, "msg": "The conditional check 'output.rc != 0' failed. The error was: error while evaluating conditional (output.rc != 0): 'dict object' has no attribute 'rc'}
获取输出variables的任务:
- name : "Check Zookeeper Service" command : /path/to/zookeeper/bin/zkServer.sh status register : output
比较rcvariables的任务
- name: "Checking RC" fail: msg="Zookeeper Service is DOWN" when: output.rc != 0
你能告诉我这里可能是什么问题吗?
谢谢。
从意见回答:
– “check rc”任务是否在“检查zookeeper”之后?
– 不,有两个之间的任务,以及被跳过,但他们注册相同的variables。
– 那就是问题所在。
register:即使是跳过的任务也要注册结果。
有关详细信息,请参阅此线程 。