PyratLabs / ansible-role-k3s

Ansible role for installing k3s as either a standalone server or HA cluster.
BSD 3-Clause "New" or "Revised" License
640 stars 135 forks source link

Incorrect detection of (non-default) Python 3 on RPi since 3.0.0 #172

Closed gloomytrousers closed 2 years ago

gloomytrousers commented 2 years ago

Summary

Playbook fails on Raspberry Pi OS (buster) with "Python v2.7.16 is not supported by this role. Please install >= v3.6."

However, Python 3 is installed, it's just not the default for the python command.

Issue Type

Controller Environment and Configuration

This is using the newly-released version 3.0.0 of the role, which mentions "Minimum python version on targets is 3.6" as a breaking change.

pi@pi1:~ $ python --version
Python 2.7.16
pi@pi1:~ $ python3 --version
Python 3.7.3
pi@pi1:~ $ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Steps to Reproduce

Run a playbook which includes the role (I am running it with --check but I don't expect that makes any difference).

Expected Result

Playbook succeeds

Actual Result

TASK [xanmanning.k3s : Check that Python v2.7.16 is supported by this role] *******************************************************************
fatal: [pi1.gloomytrousers.co.uk -> localhost]: FAILED! => {
    "assertion": "ansible_python_version is version_compare(k3s_python_min_version, '>=')",
    "changed": false,
    "evaluated_to": false,
    "msg": "Python v2.7.16 is not supported by this role. Please install >= v3.6."
}
xlejo commented 2 years ago

You try to add ansible_python_interpreter: python3 in the group_vars or in the inventory file?

gloomytrousers commented 2 years ago

Thank you @xlejo, that solved it.

Not sure whether to close this issue, or if it's something that needs to be documented - anyone have any thoughts?

xanmanning commented 2 years ago

@xlejo is right, this is the way to specify the python version to use on target systems. Alternatively the default python version can be set with alternatives, however for some distros this can interfere with certain applications that might use a shebang of #!/usr/bin/python and expecting to get python 2.

The reason for targeting python 3 is due to some inconsistencies in Ansible behaviour when python 2 is used. I had one issue that I've previously worked around for this role because of this. Given v2 is EOL, it made sense to try and push for python 3 usage.

It probably needs some documentation, I'll have a look into it when I get some time.

crutonjohn commented 2 years ago

I wonder if just documenting that ansible_python_interpreter: python3 should be added to the group vars so that the burden is on the user 🤔

thoughts? @onedr0p @xanmanning ?

crutonjohn commented 2 years ago

looks like @xanmanning already tackled this in https://github.com/PyratLabs/ansible-role-k3s/commit/2e5dd3cc07881846265b855616a6181b135adff4#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5

marking this as closed