/usr/lib/python3/dist-packages/paramiko/transport.py:219: CryptographyDeprecationWarning: Blowfish has been deprecated

Does anyone know what causes this message when I use the ansible-playbook -i ~/project_app1/hosts playbook.yaml:

/usr/lib/python3/dist-packages/paramiko/transport.py:219: CryptographyDeprecationWarning: Blowfish has been deprecated

How can I fix it? I tried to update ansible version 2.12.10 but still same issue. How can I fix it?

Upgrade paramiko to the latest version, and it will go away. However, it is only sometimes possible to upgrade Python 3 paramiko because the system may install it. For example, RHEL or LTS distro like Debian/Ubuntu will always be behind the latest version. In such cases, you need to install pip/pip3 to install it. So opening an issue with the official package maintainers would be best solution to fix it or install it using pip/pip3.

Can I update and install Ansible and paramiko using the pip in my home directory and leave the system installed python3-paramiko as it is? Do you think it will cause conflict? Can I keep python3-paramiko package?

Here is how to install Ansible in your HOME dir using virtual environments. This version is limited per user in their HOME dir and separate from the system installed Ansible and modules. There won’t be any conflict and no need to remove system install Ansible and co.

Step 1: Install the tool to create isolated Python environments

First, install Python virtualenv using dnf command or apt command (as per your distro). For example:
apt install python3-virtualenv

sudo apt install python3-virtualenv python3-pip # Debian/Ubuntu
sudo dnf install python3-virtualenv python3-pip # Rocky/ALma/RHEL/Fedora/CentOS Linux

The above will also install pip to install Ansible.

Step 2: Creating a virtual environment to host a local copy of Ansible in your $HOME

cd # go to home dir
virtualenv ansible-aws-project

This will create a new dir called ansible-aws-project in the current directory. To use ansible-aws-project dir, you must activate it. For example:

source ~/ansible-aws-project/bin/activate

You will see the shell prompt as follows:

(ansible-aws-project) vivek@desktop:~$

Step 3: Installing Ansible

Next, install Ansible to make it possible to use the modules with the latest version. Here is how to do it:

pip install Ansible
## OR ##
pip3 install Ansible

Check your Ansible version, and type:

ansible --version
ansible [core 2.13.8]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/vivek/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vivek/ansible-aws-project/lib/python3.8/site-packages/ansible
  ansible collection location = /home/vivek/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/vivek/ansible-aws-project/bin/ansible
  python version = 3.8.10 (default, Nov 14 2022, 12:59:47) [GCC 9.4.0]
  jinja version = 3.1.2
  libyaml = True

Step 4: Test it

That is all. It should work now without any warnings. For example:

ansible-playbook -i ~/project_app1/hosts playbook.yaml

You must activate virtual environment before getting started with Ansible. For instance:

source ~/ansible-aws-project/bin/activate
## now do your stuff

To exit from virtual environment, run:

exit

Step 5: Upgrading Ansible

When you need to upgrade Ansible, you can run the following commands:

source ~/ansible-aws-project/bin/activate
pip install --upgrade ansible
## OR ##
pip3 install --upgrade ansible
1 Like