Ансибл не идентифицирует процессор yq - PullRequest
0 голосов
/ 01 октября 2019

Команда, в моей книге игр я вызываю yq в модуле оболочки, но жалуюсь на путь. кто-нибудь может помочь, пожалуйста? Я уже проверил вручную yq и jq доступны.

cat $HOME/.kube/config/cluster-user.kubeconfig | yq .contexts[0].name```
"site.test.com"
"site.test.com"
      - name: "GET API server current-context name with YQ..  "
        shell: "cat $HOME/.kube/config/cluster-user.kubeconfig | yq .[\"current-context\"]"
        register: string1
        ignore_errors: true

      - debug:
          var: string1.stdout_lines
        when: string1.stdout != ''


      - name: "GET API server contexts name with YQ..  "
        shell: "cat $HOME/.kube/config/cluster-user.kubeconfig | yq .contexts[0].name"
        register: string2
        ignore_errors: true

      - debug:
          var: string2.stdout_lines
        when: string2.stdout != ''


      - fail:
          msg: "Validate if both string1 and string2 are same, if yes proceed..."
        when: string2.stdout != string1.stdout

anyhint, как заставить ANSI использовать двоичные файлы?

вывод:

TASK [GET API server contexts name with YQ..] ******************************************************************************************
fatal: [target1]: FAILED! => {"changed": true, "cmd": "cat $HOME/.kube/config/cluster-user.kubeconfig | yq .contexts[0].name", "delta": "0:00:00.006670", "end": "2019-09-30 18:15:13.829021", "msg": "non-zero return code", "rc": 127, "start": "2019-09-30 18:15:13.822351", "stderr": "/bin/sh: yq: command not found", "stderr_lines": ["/bin/sh: yq: command not found"], "stdout": "", "stdout_lines": []}
...ignoring

1 Ответ

0 голосов
/ 03 октября 2019

Добавлен путь в окружениях в playbook

environment: PATH: «{{ansible_env.PATH}}: / usr / local / bin»

Теперь мои двоичные файлы использовались какожидается. Тем не менее, у меня все еще есть проблема с использованием yq, потому что он запрашивает jq.

...