cqlsh命令无法通过ansible工作

c3frrgcw  于 2021-06-10  发布在  Cassandra
关注(0)|答案(2)|浏览(361)

我有下面的ansible playbook在远程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 模块,但它没有工作,但当尝试 cqlsh -f .cql 在cassandra服务器上手动运行。
通过ansible剧本可以做些什么?

x8goxv8g

x8goxv8g1#

检查是否 cqlsh.py 以及 cqlsh 文件存在于 /usr/bin 文件夹,如果没有那么复制它,因为它似乎你已经配置Cassandra提取tar文件。
我在我的环境中也面临同样的问题。
同时复制 cqlshlib 在这种情况下你可以在 /etc/cassandra/conf/ 然后粘贴到 /usr/local/lib/python2.7/dist-packages/ 你上面的剧本看起来不错,应该可以解决这个问题。

ebdffaop

ebdffaop2#

必须指定到的完整路径 cqlsh 如果它不在$path环境变量中。

相关问题