синтаксическая ошибка в команде оболочки более ansible - PullRequest
0 голосов
/ 30 апреля 2020

Team,

моя задача ниже, и я просто пытаюсь вытянуть модуль с сопоставлением с образцом до 5 символов, но получаю ошибку в выводе ansible.

- name: "fetch csi pod on node"
  #command: "kubectl get pods -n csi-vdiskplugin  --no-headers --field-selector spec.nodeName={{ inventory_hostname }} | grep -E csi-vdiskplugin-'[[:alnum:]]{5}' -o -w"
  command: kubectl get pods -n csi-vdiskplugin  --no-headers --field-selector spec.nodeName={{ inventory_hostname }} | grep -E csi-vdiskplugin-'[[:alnum:]]{5}' -o -w
  #command: "kubectl get pods -n csi-vdiskplugin  --no-headers --field-selector spec.nodeName={{ inventory_hostname }} --kubeconfig $KUBECONFIG" 
  #command: "kubectl get pods -n csi-vdiskplugin  --no-headers --field-selector spec.nodeName={{ inventory_hostname }}" 
  register: csi_pod
  delegate_to: localhost
  become: false

вывод:

fatal: [node1 -> localhost]: FAILED! => {"changed": true, "cmd": ["kubectl", "get", "pods", "-n", "csi-vdiskplugin", "--no-headers", "--field-selector", "spec.nodeName=node1", "|", "grep", "-E", "csi-vdiskplugin-[[:alnum:]]{5}", "-o", "-w"], "delta": "0:00:00.574302", "end": "2020-04-30 07:00:28.104617", "msg": "non-zero return code", "rc": 1, "start": "2020-04-30 07:00:27.530315", "stderr": "Error: unknown shorthand flag: 'E' in -E\n\n\nExamples:\n  # List all pods in ps output format.\n  kubectl get pods\n  \n  # List all pods in ps output format with more information (such as node name).\n  kubectl get pods -o wide\n  \n  # List a single replication controller with spec

ожидаемый результат:

csi-vdiskplugin-asdf9d

команда отлично работает на linux терминал

1 Ответ

0 голосов
/ 30 апреля 2020

использованный модуль оболочки

- name: "fetch csi pod on node"
  shell: "kubectl get pods -n csi-vdiskplugin  --no-headers --field-selector spec.nodeName={{ inventory_hostname }} | grep -E csi-vdiskplugin-'[[:alnum:]]{5}' -o -w"
  register: csi_pod
  delegate_to: localhost
  become: false
...