Kubeinit / kubeinit

Ansible automation to have a KUBErnetes cluster INITialized as soon as possible...
https://www.kubeinit.org
Apache License 2.0
218 stars 57 forks source link

Execute commands in worker nodes #646

Closed logeshwaris closed 2 years ago

logeshwaris commented 2 years ago

I am deploying a OKD cluster with 1 master and 2 worker nodes. As of now, I can see that we can execute commands in the service node. When I tried to executing commands by delegating to the bootstrap node, i was getting the python interpreter error. Is there any way to execute commands in the bootstrap or worker nodes in ansible playbook?

logeshwaris commented 2 years ago

Hi, tried to execute the below task in kubeinit_okd/tasks/main.yml and getting the below error. When i tried to run the same in separate playbook, it is working fine. Any idea why it throws "/bin/sh: line 1: /usr/bin/python3: No such file or directory\n" ? I tried setting python_interpreter as well, but no luck.

-  name:  copy local script to destination
  ansible.builtin.copy:
    src: script.sh
    dest: /tmp/script.sh
  vars:
    ansible_user: core
    ansible_ssh_private_key_file: "~/.ssh/okdcluster_id_rsa"
    ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=accept-new'
  delegate_to: 20.0.0.4

Error: TASK [kubeinit.kubeinit.kubeinit_okd : copy local script to destination] **** task path: /home/slogeshw/.ansible/collections/ansible_collections/kubeinit/kubeinit/roles/kubeinit_okd/tasks/main.yml:41 Thursday 05 May 2022 23:30:41 +0530 (0:00:00.425) 0:34:05.783 ** <20.0.0.4> ESTABLISH SSH CONNECTION FOR USER: core <20.0.0.4> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/slogeshw/.ssh/okdcluster_id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="core"' -o ConnectTimeout=10 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=accept-new -o ControlPath=/home/slogeshw/.ansible/cp/01cba4ce83 20.0.0.4 '/bin/sh -c '"'"'echo ~core && sleep 0'"'"'' <20.0.0.4> (0, b'/var/home/core\n', b"Warning: Permanently added '20.0.0.4' (ECDSA) to the list of known hosts.\r\n") <20.0.0.4> ESTABLISH SSH CONNECTION FOR USER: core <20.0.0.4> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/slogeshw/.ssh/okdcluster_id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="core"' -o ConnectTimeout=10 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=accept-new -o ControlPath=/home/slogeshw/.ansible/cp/01cba4ce83 20.0.0.4 '/bin/sh -c '"'"'( umask 77 && mkdir -p "echo /var/home/core/.ansible/tmp"&& mkdir "echo /var/home/core/.ansible/tmp/ansible-tmp-1651773642.0561326-2387299-158629332054312" && echo ansible-tmp-1651773642.0561326-2387299-158629332054312="echo /var/home/core/.ansible/tmp/ansible-tmp-1651773642.0561326-2387299-158629332054312" ) && sleep 0'"'"'' <20.0.0.4> (0, b'ansible-tmp-1651773642.0561326-2387299-158629332054312=/var/home/core/.ansible/tmp/ansible-tmp-1651773642.0561326-2387299-158629332054312\n', b'') Using module file /usr/local/lib/python3.6/site-packages/ansible/modules/stat.py Pipelining is enabled. <20.0.0.4> ESTABLISH SSH CONNECTION FOR USER: core <20.0.0.4> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/slogeshw/.ssh/okdcluster_id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="core"' -o ConnectTimeout=10 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=accept-new -o ControlPath=/home/slogeshw/.ansible/cp/01cba4ce83 20.0.0.4 '/bin/sh -c '"'"'/usr/bin/python3 && sleep 0'"'"'' <20.0.0.4> (127, b'', b'/bin/sh: line 1: /usr/bin/python3: No such file or directory\n') <20.0.0.4> Failed to connect to the host via ssh: /bin/sh: line 1: /usr/bin/python3: No such file or directory <20.0.0.4> ESTABLISH SSH CONNECTION FOR USER: core <20.0.0.4> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/slogeshw/.ssh/okdcluster_id_rsa"' -o KbdInteract thentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="core"' -o ConnectTimeout=10 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=accept-new -o ControlPath=/home/slogeshw/.ansible/cp/01cba4ce83 20.0.0.4 '/bin/sh -c '"'"'rm -f -r /var/home/core/.ansible/tmp/ansible-tmp-1651773642.0561326-2387299-158629332054312/ > /dev/null 2>&1 && sleep 0'"'"'' <20.0.0.4> (0, b'', b'') fatal: [localhost -> 20.0.0.4]: FAILED! => { "msg": "Failed to get information on remote file (/tmp/script.sh): /bin/sh: line 1: /usr/bin/python3: No such file or directory\n" }