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

ansible-core:2.17 / Ansible 10 not supported #1525

Closed
codepuncher opened this issue Jun 19, 2024 · 5 comments
Closed

ansible-core:2.17 / Ansible 10 not supported #1525

codepuncher opened this issue Jun 19, 2024 · 5 comments
Labels

Comments

@codepuncher
Copy link

codepuncher commented Jun 19, 2024

Version

80a491e

What did you expect to happen?

To be able to run trellis deploy production without error

What actually happens?

The deploy fails

Steps to reproduce

Ensure that trellis init && trellis exec ansible --version shows ansible 2.17.x

System info

Error found in GitHub action runner.
Linux, using roots/setup-trellis-cli

Log output

TASK [deploy : Clone project files] ********************************************
task path: /home/runner/work/www.foobar.org-bedrock/www.foobar.org-bedrock/trellis/deploy-hooks/build-before.yml:11
Using module file /home/runner/work/www.foobar.org-bedrock/www.foobar.org-bedrock/trellis/.trellis/virtualenv/lib/python3.10/site-packages/ansible/modules/git.py
Pipelining is enabled.
<35.242.179.138> ESTABLISH LOCAL CONNECTION FOR USER: runner
<35.242.179.138> EXEC /bin/sh -c '/usr/bin/python3.8 && sleep 0'
fatal: [kinsta_production]: FAILED! => {
    "changed": false,
    "module_stderr": "/bin/sh: 1: /usr/bin/python3.8: not found\n",
    "module_stdout": "",
    "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error",
    "rc": 127
}

Please confirm this isn't a support request.

Yes

Other notes

https://docs.ansible.com/ansible/latest/roadmap/COLLECTIONS_10.html
https://docs.ansible.com/ansible/latest/roadmap/ROADMAP_2_17.html#id6

codepuncher added a commit to codepuncher/trellis that referenced this issue Jun 19, 2024
@swalkinshaw
Copy link
Member

Here's a great post about the issue: https://www.jeffgeerling.com/blog/2024/newer-versions-ansible-dont-work-rhel-8

@codepuncher I assume your server is running Ubuntu 18 or older?

@swalkinshaw
Copy link
Member

I'm inclined to leave Trellis on main as is since this restricts newer versions for everyone even if they are using newer Ubuntu versions that have proper Python 3.8+ support. Assuming this is an issue with Ubuntu 18.04, it's actually not supported anymore either.

@codepuncher
Copy link
Author

Hi @swalkinshaw,

This is happening on Ubuntu 22.04.4 (GitHub-hosted runner) as well as my WSL instance which is also Ubuntu 22.04.4

On the remote server (Kinsta), there is:

/usr/bin/python -> /usr/bin/python2.7
/usr/bin/python2 -> python2.7
/usr/bin/python2.7
/usr/bin/python3 -> python3.8
/usr/bin/python3.8

On my WSL (which would be similar on the GitHub runner):

/usr/bin/python3 -> python3.10*
/usr/bin/python3-config -> python3.10-config*
/usr/bin/python3.10*
/usr/bin/python3.10-config -> x86_64-linux-gnu-python3.10-config*

I can see through the trellis-cli deploy --verbose staging output that it is using Python 3.10 from the virtualenv but when it tries local commands it tries using /usr/bin/python3.8 which is not on the runner nor WSL. I cannot find why it is trying to do this, though.

Shouldn't it be using Python 3.10 from the virtualenv, though?

More debug info:

# roles/deploy/tasks/update.yml
- name: Get python path
  command: which python
  no_log: false
  register: pp_1

- ansible.builtin.debug:
    var: pp_1
    verbosity: 4

- name: Get python version
  command: python --version
  no_log: false
  register: pv_1

- ansible.builtin.debug:
    var: pv_1
    verbosity: 4

- name: Get python path
  command: which python
  no_log: false
  connection: local
  register: pp_2

- ansible.builtin.debug:
    var: pp_2
    verbosity: 4

- name: Get python version
  command: python --version
  no_log: false
  connection: local
  register: pv_2

- ansible.builtin.debug:
    var: pv_2
    verbosity: 4

- name: Clone project files
  git:
    repo: "{{ project_git_repo }}"
    dest: "{{ project_source_path }}"
    version: "{{ project_version }}"
    accept_hostkey: "{{ project.repo_accept_hostkey | default(repo_accept_hostkey | default(true)) }}"
    force: yes
  ignore_errors: true
  no_log: false
  register: git_clone
TASK [deploy : Get python path] ************************************************
task path: /path/to/trellis/roles/deploy/tasks/update.yml:26
Using module file /path/to/trellis/.trellis/virtualenv/lib/python3.10/site-packages/ansible/modules/command.py
Pipelining is enabled.
<35.234.152.223> ESTABLISH SSH CONNECTION FOR USER: itineris
<35.234.152.223> SSH: EXEC ssh -vvvv -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o [email protected],[email protected],ssh-ed25519,ssh-rsa -o StrictHostKeyChecking=no -o Port=54736 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="itineris"' -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o 'ControlPath="/path/to/.ansible/cp/7e01524a03"' 35.234.152.223 '/bin/sh -c '"'"'/usr/bin/python3.8 && sleep 0'"'"''
<35.234.152.223> (0, b'\n{"changed": true, "stdout": "/usr/bin/python", "stderr": "", "rc": 0, "cmd": ["which", "python"], "start": "2024-06-24 12:17:57.044753", "end": "2024-06-24 12:17:57.050665", "delta": "0:00:00.005912", "msg": "", "invocation": {"module_args": {"_raw_params": "which python", "_uses_shell": false, "expand_argument_vars": true, "stdin_add_newline": true, "strip_empty_ends": true, "argv": null, "chdir": null, "executable": null, "creates": null, "removes": null, "stdin": null}}}\n', b"OpenSSH_8.9p1 Ubuntu-3ubuntu0.6, OpenSSL 3.0.2 15 Mar 2022\r\ndebug1: Reading configuration data /path/to/.ssh/config\r\ndebug1: /path/to/.ssh/config line 1: Applying options for *\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug1: /etc/ssh/ssh_config line 21: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 35.234.152.223 is address\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/path/to/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/path/to/.ssh/known_hosts2'\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 = 256032\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 0\r\n")
changed: [kinsta_staging] => {
    "changed": true,
    "cmd": [
        "which",
        "python"
    ],
    "delta": "0:00:00.005912",
    "end": "2024-06-24 12:17:57.050665",
    "invocation": {
        "module_args": {
            "_raw_params": "which python",
            "_uses_shell": false,
            "argv": null,
            "chdir": null,
            "creates": null,
            "executable": null,
            "expand_argument_vars": true,
            "removes": null,
            "stdin": null,
            "stdin_add_newline": true,
            "strip_empty_ends": true
        }
    },
    "msg": "",
    "rc": 0,
    "start": "2024-06-24 12:17:57.044753",
    "stderr": "",
    "stderr_lines": [],
    "stdout": "/usr/bin/python",
    "stdout_lines": [
        "/usr/bin/python"
    ]
}

TASK [deploy : ansible.builtin.debug] ******************************************
task path: /path/to/trellis/roles/deploy/tasks/update.yml:31
ok: [kinsta_staging] => {
    "pp_1": {
        "changed": true,
        "cmd": [
            "which",
            "python"
        ],
        "delta": "0:00:00.005912",
        "end": "2024-06-24 12:17:57.050665",
        "failed": false,
        "msg": "",
        "rc": 0,
        "start": "2024-06-24 12:17:57.044753",
        "stderr": "",
        "stderr_lines": [],
        "stdout": "/usr/bin/python",
        "stdout_lines": [
            "/usr/bin/python"
        ]
    }
}

TASK [deploy : Get python version] *********************************************
task path: /path/to/trellis/roles/deploy/tasks/update.yml:35
Using module file /path/to/trellis/.trellis/virtualenv/lib/python3.10/site-packages/ansible/modules/command.py
Pipelining is enabled.
<35.234.152.223> ESTABLISH SSH CONNECTION FOR USER: itineris
<35.234.152.223> SSH: EXEC ssh -vvvv -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o [email protected],[email protected],ssh-ed25519,ssh-rsa -o StrictHostKeyChecking=no -o Port=54736 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="itineris"' -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o 'ControlPath="/path/to/.ansible/cp/7e01524a03"' 35.234.152.223 '/bin/sh -c '"'"'/usr/bin/python3.8 && sleep 0'"'"''
<35.234.152.223> (0, b'\n{"changed": true, "stdout": "", "stderr": "Python 2.7.18", "rc": 0, "cmd": ["python", "--version"], "start": "2024-06-24 12:17:57.337503", "end": "2024-06-24 12:17:57.342818", "delta": "0:00:00.005315", "msg": "", "invocation": {"module_args": {"_raw_params": "python --version", "_uses_shell": false, "expand_argument_vars": true, "stdin_add_newline": true, "strip_empty_ends": true, "argv": null, "chdir": null, "executable": null, "creates": null, "removes": null, "stdin": null}}}\n', b"OpenSSH_8.9p1 Ubuntu-3ubuntu0.6, OpenSSL 3.0.2 15 Mar 2022\r\ndebug1: Reading configuration data /path/to/.ssh/config\r\ndebug1: /path/to/.ssh/config line 1: Applying options for *\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug1: /etc/ssh/ssh_config line 21: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 35.234.152.223 is address\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/itineris/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/itineris/.ssh/known_hosts2'\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 = 256032\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 0\r\n")
changed: [kinsta_staging] => {
    "changed": true,
    "cmd": [
        "python",
        "--version"
    ],
    "delta": "0:00:00.005315",
    "end": "2024-06-24 12:17:57.342818",
    "invocation": {
        "module_args": {
            "_raw_params": "python --version",
            "_uses_shell": false,
            "argv": null,
            "chdir": null,
            "creates": null,
            "executable": null,
            "expand_argument_vars": true,
            "removes": null,
            "stdin": null,
            "stdin_add_newline": true,
            "strip_empty_ends": true
        }
    },
    "msg": "",
    "rc": 0,
    "start": "2024-06-24 12:17:57.337503",
    "stderr": "Python 2.7.18",
    "stderr_lines": [
        "Python 2.7.18"
    ],
    "stdout": "",
    "stdout_lines": []
}

TASK [deploy : ansible.builtin.debug] ******************************************
task path: /path/to/trellis/roles/deploy/tasks/update.yml:40
ok: [kinsta_staging] => {
    "pv_1": {
        "changed": true,
        "cmd": [
            "python",
            "--version"
        ],
        "delta": "0:00:00.005315",
        "end": "2024-06-24 12:17:57.342818",
        "failed": false,
        "msg": "",
        "rc": 0,
        "start": "2024-06-24 12:17:57.337503",
        "stderr": "Python 2.7.18",
        "stderr_lines": [
            "Python 2.7.18"
        ],
        "stdout": "",
        "stdout_lines": []
    }
}

TASK [deploy : Get python path] ************************************************
task path: /path/to/trellis/roles/deploy/tasks/update.yml:44
Using module file /path/to/trellis/.trellis/virtualenv/lib/python3.10/site-packages/ansible/modules/command.py
Pipelining is enabled.
<35.234.152.223> ESTABLISH LOCAL CONNECTION FOR USER: itineris
<35.234.152.223> EXEC /bin/sh -c '/usr/bin/python3.8 && sleep 0'
fatal: [kinsta_staging]: FAILED! => {
    "changed": false,
    "module_stderr": "/bin/sh: 1: /usr/bin/python3.8: not found\n",
    "module_stdout": "",
    "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error",
    "rc": 127
}

@swalkinshaw
Copy link
Member

In your original error the failure was on task "Clone project files" which is not a local connection; meaning it's being executed on the remote server by Python on that server, not your local machine. This means it's using the system version of Python 3 on Ubuntu 22.04 and, unfortunately, completely separate and unrelated from your local virtualenv setup that the CLI manages.

I assume this must be related to Ansible's changes of how it detects the Python interpreter, but I guess not the same issue as it not supporting <3.8 now.

@codepuncher can you try setting your ansible_python_interpreter to these values and see if any fix the issue? https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html

@codepuncher
Copy link
Author

Hi @swalkinshaw, thanks for that; I have added ansible_python_interpreter=/usr/bin/python3 to my hosts and it's all good now and happy this is not a bug but a simple change to configuration for hosts.

I'll close my accompanying PR with this as an alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants