我有以下ansible攻略,可以在远程cassandra集群上运行特定命令
---
- hosts: newcass
become: yes
become_user: root
become_method: sudo
gather_facts: True
serial: 1
tasks:
- name: Execute CQLSH
# shell: 'cqlsh -f /home/ubuntu/abc.cql'
shell: 'cqlsh -f abc.cql'
# command: "export CQLSH_NO_BUNDLED=true && cqlsh -f /home/ubuntu/abc.cql"
# command: "cqlsh -f abc.cql"
args:
chdir: /home/ubuntu/
register: cqlsh_result
- debug:
msg: "{{ cqlsh_result }}"运行此攻略后,我们得到下面的错误提示
{"changed": true, "cmd": "cqlsh -e abc.cql", "delta": "0:00:00.001835",
"end": "2019-03-22 02:13:41.799578", "failed": true, "rc": 127, "start":
"2019-03-22 02:13:41.797743", "stderr": "/bin/sh: 1: cqlsh: not found",
"stdout": "", "stdout_lines": [], "warnings": []}我也尝试过使用command模块,但是它不起作用,但是当在cassandra服务器上手动尝试cqlsh -f abc.cql时,它起作用了。
通过ansible playbooks可以做些什么来运行它?
发布于 2019-03-29 17:37:22
检查cqlsh.py和cqlsh文件是否存在于/usr/bin文件夹中,如果没有,则复制它,因为您似乎已经通过解压tar文件配置了cassandra。
我在我的环境中也遇到了同样的问题。
还要复制cqlshlib,在本例中可以在/etc/cassandra/conf/中找到它,并将其粘贴到/usr/local/lib/python2.7/dist-packages/中
你上面的攻略看起来很好,应该可以解决这个问题。
发布于 2019-03-22 10:46:28
如果$PATH环境变量中没有cqlsh,则必须指定它的完整路径。
https://stackoverflow.com/questions/55292009
复制相似问题