Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'kubernetes.core.kustomize'. Error was a <class 'FileNotFoundError'>, o riginal message: [Errno 2] No such file or directory: '/usr/local/bin/kubectl'. [Errno 2] No such file or directory: '/usr/local/bin/kubectl'"} #664

Open
alishaik1 opened this issue Nov 22, 2023 · 1 comment
Labels
needs_info Needs additional information from original reporter

Comments

@alishaik1
Copy link

alishaik1 commented Nov 22, 2023

SUMMARY

I am trying to use the kustomize anisble module but unable to execute it. Kubernetes resources are not creating.
Kubernetes node is having kubectl binary

/usr/local/bin/kubectl version
Client Version: v1.28.2
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.28.2

ISSUE TYPE

Code:

  • name: Create kubernetes resources for lookup output
    k8s:
    definition: "{{ lookup('kubernetes.core.kustomize', dir='../hybrid-cloud/kustomization.yaml', binary_path='/usr/local/bin/kubectl') }}"

Error1:
FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'kubernetes.core.kustomize'. Error was a <class 'FileNotFoundError'>, o
riginal message: [Errno 2] No such file or directory: '/usr/local/bin/kubectl'. [Errno 2] No such file or directory: '/usr/local/bin/kubectl'"}


Code:

  • name: Create kubernetes resources for lookup output
    k8s:
    definition: "{{ lookup('kubernetes.core.kustomize', dir='../hybrid-cloud/kustomization.yaml') }}"
    Error2:
    FAILED! => {"msg": "Failed to find required executable 'kubectl' and 'kustomize' in paths"}
COMPONENT NAME

kubernetes.core.kustomize

ANSIBLE VERSION
ansible --version
ansible [core 2.14.0]
  config file = None
  configured module search path = ['/home/test-user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /home/test-user/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.16 (main, May 31 2023, 12:21:58) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)] (/usr/bin/python3.9)
  jinja version = 3.1.2
  libyaml = True

COLLECTION VERSION

ansible-galaxy collection list kubernetes.core

/home/test-user/.ansible/collections/ansible_collections

Collection Version


kubernetes.core 2.4.0


##### CONFIGURATION
<!--- Paste verbatim output from "ansible-config dump --only-changed" between quotes -->
```ansible-config dump --only-changed
CONFIG_FILE() = None

OS / ENVIRONMENT

uname -a
Linux ansible-master 4.18.0-425.13.1.el8_7.x86_64 #1 SMP Thu Feb 2 13:01:45 EST 2023 x86_64 x86_64 x86_64 GNU/Linux
[test-user@ansible-master tasks]$ cat /etc/os-release
NAME="Red Hat Enterprise Linux"
VERSION="8.8 (Ootpa)"

STEPS TO REPRODUCE

below or the syntax i tried:

  • name: Run lookup using kubectl
    set_fact:
    resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/usr/local/bin/kubectl') }}"

  • name: Run lookup
    set_fact:
    resources: "{{ lookup('kubernetes.core.kustomize', dir='../hybrid-cloud/kustomization.yaml', binary_path='/usr/local/bin/kubectl') }}"

  • name: Create kubernetes resources for lookup output
    k8s:
    definition: "{{ lookup('kubernetes.core.kustomize', dir='../hybrid-cloud/kustomization.yaml', binary_path='/usr/local/bin/kubectl') }}"


- name: Run lookup using kubectl
  set_fact:
    resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/usr/local/bin/kubectl') }}"

- name: Run lookup
  set_fact:
    resources: "{{ lookup('kubernetes.core.kustomize', dir='../hybrid-cloud/kustomization.yaml', binary_path='/usr/local/bin/kubectl') }}"

- name: Create kubernetes resources for lookup output
  k8s:
    definition: "{{ lookup('kubernetes.core.kustomize', dir='../hybrid-cloud/kustomization.yaml', binary_path='/usr/local/bin/kubectl') }}"

EXPECTED RESULTS
ACTUAL RESULTS

@gravesm
Copy link
Member

gravesm commented Nov 28, 2023

@alishaik1 Keep in mind that lookup plugins run on the control node, not the remote node. kubectl/kustomize will have to be present on the machine that you are running Ansible from.

@gravesm gravesm added the needs_info Needs additional information from original reporter label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs_info Needs additional information from original reporter
Projects
None yet
Development

No branches or pull requests

2 participants