gigascience / gigadb-website

Source code for running GigaDB
http://gigadb.org
GNU General Public License v3.0
9 stars 14 forks source link

Ansible interpreter discovery broken for rhel 8 based distros on 2.17.x #1986

Open kencho51 opened 1 month ago

kencho51 commented 1 month ago

Describe the bug A clear and concise description of what the bug is.

After upgrading ansible to 2.17.x, it will throw the following error:

% ansible --version
ansible [core 2.17.1]
  config file = None
  configured module search path = ['/Users/kencho/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/10.1.0/libexec/lib/python3.12/site-packages/ansible
  ansible collection location = /Users/kencho/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.12.4 (main, Jun  6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.1.0.2.5)] (/opt/homebrew/Cellar/ansible/10.1.0/libexec/bin/python)
  jinja version = 3.1.4
  libyaml = True
kencho@Kens-MacBook-Pro:~ % which ansible
/opt/homebrew/bin/ansible
% ansible-playbook -i ../../inventories bootstrap_playbook.yml --tags="bastion_ips" -e="private_ip=10.99.0.174 public_ip=$bastion-ip" --extra-vars="gigadb_env=staging" -vvv
fatal: [3.36.204.163]: FAILED! => {
    "ansible_facts": {},
    "changed": false,
    "failed_modules": {
        "ansible.legacy.setup": {
            "ansible_facts": {
                "discovered_interpreter_python": "/usr/bin/python3"
            },
            "failed": true,
            "module_stderr": "OpenSSH_9.0p1, LibreSSL 3.3.6\r\ndebug1: Reading configuration data /Users/kencho/.ssh/config\r\ndebug1: /Users/kencho/.ssh/config line 87: Applying options for *\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files\r\ndebug1: /etc/ssh/ssh_config line 54: Applying options for *\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 3.36.204.163 is address\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/kencho/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/kencho/.ssh/known_hosts2'\r\ndebug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 43600\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 127\r\nShared connection to 3.36.204.163 closed.\r\n",
            "module_stdout": "/bin/sh: /usr/bin/python3: No such file or directory\r\n",
            "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error",
            "rc": 127,
            "warnings": [
                "No python interpreters found for host 3.36.204.163 (tried ['python3.12', 'python3.11', 'python3.10', 'python3.9', 'python3.8', 'python3.7', '/usr/bin/python3', 'python3'])"
            ]
        }
    },
    "msg": "The following modules failed to execute: ansible.legacy.setup\n"
}

PLAY RECAP **********************************************************************************************************************************************************************************
3.36.204.163               : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Additional context

It is a known ansible bug reported at https://github.com/ansible/ansible/issues/83357. More report case: https://forum.ansible.com/t/ansible-playbook-ansible-core-2-17-1-fails-on-target-with-python-3-9/6700/22

Since we are using CentOS stream 8 for our production OS, it is a rebuild of Red Hat Enterprise Linux (RHEL). My temp solution was install older version using python pip as it allows specify which version to install :

% brew uninstall ansible
% /usr/bin/python3 --version
Python 3.9.6
% /usr/bin/python3 -m pip install --user ansible-core==2.15.12
% echo "Users/kencho/Library/Python/3.9/bin:" >> $PATH
 % ansible --version
ansible [core 2.15.12]
  config file = None
  configured module search path = ['/Users/kencho/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/kencho/Library/Python/3.9/lib/python/site-packages/ansible
  ansible collection location = /Users/kencho/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/kencho/Library/Python/3.9/bin/ansible
  python version = 3.9.6 (default, May  7 2023, 23:32:44) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/Library/Developer/CommandLineTools/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True
rija commented 1 month ago

Thanks for creating a ticket for this. From the issue you've linked to, it seems the problems will disappear when we switch to Centos Stream 9