0

Team, Works locally on my laptop manually but fails only when calling via ansible. Is ansible looking at it in different shell? I have ansible controller as MAC book.

I am trying to store the path of a binary in register variable but shell command is not executing.

      - name: "Find kubectl binary"
        register: kubectl_path
        shell: which kubectl
        args:
          executable: /bin/bash

output:

TASK [Find kubectl binary] ***************************************************************************************************************
fatal: [target1]: FAILED! => {"changed": true, "cmd": "which kubectl", "delta": "0:00:00.007541", "end": "2019-10-01 17:17:45.515963", "msg": "non-zero return code", "rc": 1, "start": "2019-10-01 17:17:45.508422", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
AhmFM
  • 1,552
  • 3
  • 23
  • 53
  • Can you try running the command through the terminal and check whether it's giving output? Play is fine and it is working for me if I run for `which java` as it is there but failing for `which kubectl` as it is not present. – Pacifist Oct 02 '19 at 00:43
  • I specified in my question. may be ansible is looking in different location? how do i fix it? – AhmFM Oct 02 '19 at 00:55
  • If you feel it's a shell issue then try commenting `args` and `executable` and then run. – Pacifist Oct 02 '19 at 01:04
  • No help. Same result. – AhmFM Oct 02 '19 at 01:06
  • Am getting same result fir any binary I look for. So seems like a configuration issue? – AhmFM Oct 02 '19 at 01:32
  • what is the `target1` in your play? is it the localhost which is your MAC or some other host? – Pacifist Oct 02 '19 at 01:42
  • It’s localhost Mac from where am also running the play. – AhmFM Oct 02 '19 at 02:35
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/200270/discussion-between-pacifist-and-ahmfm). – Pacifist Oct 02 '19 at 02:41

0 Answers0