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
blockinfile errors with Python3: TypeError: startswith first arg must be bytes or a tuple of bytes, not str
#76358
Comments
Files identified in the description: If these files are incorrect, please update the |
Can you provide a minimal version of Can you try updating to some of the more recent Ansible versions ( needs_info |
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
I'm currently working on exactly that. But to my own surprise I have found that certain blockinfile tasks work. For example the following worked on the very same target host which threw the error in the filebeat.yml playbook:
Trying to find out why right now. I'm using the Ubuntu PPA for Ansible. Seems that newer Ansible versions haven't been packaged, can you confirm? |
OMG. I found it. The filebeat playbook uses the yaegashi.blockinfile role. This is legacy stuff as we've been using Ansible for many years. I think blockinfile was added to builtin in 2.0.
I removed the
Sorry for the noise! |
Summary
When I try to run a blockinfile task with Python3 on the target, the following error is showing up:
If I set the
ansible_python_interpreter
of the target to Python 2.7, the task works.Maybe related: #76027
Issue Type
Bug Report
Component Name
blockinfile
Ansible Version
Configuration
OS / Environment
Ubuntu 18.04
Steps to Reproduce
Simple blockinfile task:
Run playbook with the task results in error:
Changing the target in the inventory to use Python 2.7 instead:
And the task is executed successfully:
Expected Results
Task should be executed without an error.
Actual Results
Code of Conduct
The text was updated successfully, but these errors were encountered: