使用 Ansible 显示 MQ 侦听器状态不起作用
Display MQ listener status usning Ansible not working
---
- hosts: all
become_user: mqm
become_method: sudo
tasks:
- name: Execute a MQ Command
shell:
cmd: "echo 'DISPLAY LSSTATUS(TCP) STATUS' | runmqsc QMGR"
chdir: /opt/mqm/bin/runmqsc
register: mqstat
- debug:
var: mqstat.stdout_lines
**错误:**
TASK [Execute a MQ Command] ****************************************************************************************************************************************
fatal: [QMGR]: FAILED! => {"changed": false, "module_stderr": "Shared connection to xyz.pqr.com closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_UASQnG/ansible_module_command.py\", line 213, in <module>\r\n main()\r\n File \"/tmp/ansible_UASQnG/ansible_module_command.py\", line 152, in main\r\n os.chdir(chdir)\r\nOSError: [Errno 20] Not a directory: '/opt/mqm/bin/runmqsc'\r\n", "msg": "MODULE FAILURE", "rc": 0}
chdir: /opt/mqm/bin/runmqsc
如果这应该是在其中执行命令的目录,runmqsc 不是目录名称,所以它不应该是简单的 chdir:/opt/mqm/bin。此外,请记住,如果您通过管道传输到 runmqsc,则 runmqsc 必须在路径上。如果不是,那么你需要完全限定它,意思是 try:
shell:
cmd: "echo 'DISPLAY LSSTATUS(TCP) STATUS' | ./runmqsc QMGR"
chdir: /opt/mqm/bin
或
shell:
cmd: "echo 'DISPLAY LSSTATUS(TCP) STATUS' | /opt/mqm/bin/runmqsc QMGR"
chdir: /opt/mqm/bin
---
- hosts: all
become_user: mqm
become_method: sudo
tasks:
- name: Execute a MQ Command
shell:
cmd: "echo 'DISPLAY LSSTATUS(TCP) STATUS' | runmqsc QMGR"
chdir: /opt/mqm/bin/runmqsc
register: mqstat
- debug:
var: mqstat.stdout_lines
**错误:**
TASK [Execute a MQ Command] ****************************************************************************************************************************************
fatal: [QMGR]: FAILED! => {"changed": false, "module_stderr": "Shared connection to xyz.pqr.com closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_UASQnG/ansible_module_command.py\", line 213, in <module>\r\n main()\r\n File \"/tmp/ansible_UASQnG/ansible_module_command.py\", line 152, in main\r\n os.chdir(chdir)\r\nOSError: [Errno 20] Not a directory: '/opt/mqm/bin/runmqsc'\r\n", "msg": "MODULE FAILURE", "rc": 0}
chdir: /opt/mqm/bin/runmqsc
如果这应该是在其中执行命令的目录,runmqsc 不是目录名称,所以它不应该是简单的 chdir:/opt/mqm/bin。此外,请记住,如果您通过管道传输到 runmqsc,则 runmqsc 必须在路径上。如果不是,那么你需要完全限定它,意思是 try:
shell: cmd: "echo 'DISPLAY LSSTATUS(TCP) STATUS' | ./runmqsc QMGR" chdir: /opt/mqm/bin
或
shell: cmd: "echo 'DISPLAY LSSTATUS(TCP) STATUS' | /opt/mqm/bin/runmqsc QMGR" chdir: /opt/mqm/bin