ERROR! Unexpected Exception, this is probably a bug: cannot pickle '_io.TextIOWrapper' object

Trying to run my ansible-playbook to deploy to Kinsta.

I’ve tried both this solution to no avail and haven’t been able to find anything else that looks like it’ll work.

Here’s my ansible --version output:

/Users/josephroberts/.pyenv/versions/3.10.3/lib/python3.10/site-packages/paramiko/transport.py:236: CryptographyDeprecationWarning: Blowfish has been deprecated
  "class": algorithms.Blowfish,
ansible 2.8.20
  config file = /Users/josephroberts/localdev/syracusehearingsolutions.com/trellis/ansible.cfg
  configured module search path = ['/Users/josephroberts/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/josephroberts/.pyenv/versions/3.10.3/lib/python3.10/site-packages/ansible
  executable location = /Users/josephroberts/.pyenv/versions/3.10.3/bin/ansible
  python version = 3.10.3 (main, Apr 29 2022, 11:02:36) [Clang 12.0.5 (clang-1205.0.22.9)]

Here’s the output when running the playbook:

/Users/josephroberts/.pyenv/versions/3.10.3/lib/python3.10/site-packages/paramiko/transport.py:236: CryptographyDeprecationWarning: Blowfish has been deprecated
  "class": algorithms.Blowfish,
[WARNING]: Skipping plugin (/Users/josephroberts/.pyenv/versions/3.10.3/lib/python3.10/site-packages/ansible/plugins/filter/core.py) as it seems to be invalid: cannot import name 'environmentfilter' from
'jinja2.filters' (/Users/josephroberts/.pyenv/versions/3.10.3/lib/python3.10/site-packages/jinja2/filters.py)

[WARNING]: Skipping plugin (/Users/josephroberts/.pyenv/versions/3.10.3/lib/python3.10/site-packages/ansible/plugins/filter/mathstuff.py) as it seems to be invalid: cannot import name 'environmentfilter' from
'jinja2.filters' (/Users/josephroberts/.pyenv/versions/3.10.3/lib/python3.10/site-packages/jinja2/filters.py)


PLAY [Ensure necessary variables are defined] ******************************************************************************************************************************************************************************
[WARNING]: Failure using method (v2_playbook_on_play_start) in callback plugin
(<ansible.plugins.callback./Users/josephroberts/localdev/syracusehearingsolutions.com/trellis/lib/trellis/plugins/callback/vars.CallbackModule object at 0x10c5da7d0>): 'AnsibleUnicode' object has no attribute
'get_groups'

skipping: no hosts matched

PLAY [Test Connection] *****************************************************************************************************************************************************************************************************
[WARNING]: You Ansible version is 2.8.20 but this version of Trellis has only been tested for compatability with Ansible 2.7.12 -> 2.8.4. It is advisable to check for Trellis updates or downgrade your Ansible version.


TASK [connection : Require manual definition of remote-user] ***************************************************************************************************************************************************************
ERROR! Unexpected Exception, this is probably a bug: cannot pickle '_io.TextIOWrapper' object

Any thoughts on the matter?

Still dealing with this issue. Have been trying many combinations of python/ansible versions to no avail.

for disabling error related to Cryptography, downgrade it to 36.0.2

pip3 uninstall -y cryptography
pip3 install cryptography==36.0.2

for the 2nd issue, i am still struggling too.

Regarding the first warning, CryptographyDeprecationWarning: Blowfish has been deprecated.

The issue there is with an “upstream” library called Paramiko.

I took a look at their GitHub page and a fix is in the works. Brian Skinn stated that ”a fix will get pulled into a near-term future release”.

Alex Moir posted a quite convenient workaround, that eliminates the need to downgrade the cryptography package.

Hope this helps.

By using pyenv, I’ve finally been able to fix the issue with the following ansible version and python versions:

ansible 2.10.17
  config file = /Users/josephroberts/.ansible.cfg
  configured module search path = ['/Users/josephroberts/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/josephroberts/.pyenv/versions/3.10.3/lib/python3.10/site-packages/ansible
  executable location = /Users/josephroberts/.pyenv/versions/3.10.3/bin/ansible
  python version = 3.10.3 (main, Apr 29 2022, 11:02:36) [Clang 12.0.5 (clang-1205.0.22.9)]

Whenever you have environmental issues like this, try running the Trellis CLI command trellis init in the root of your project to install the correct versions of Trellis’s supporting software!