Score:0

How do I install a Python module on localhost so that Ansible finds it?

cn flag

I want to use the community.mysql.mysql_user module. It requires PyMySQL or MySQLdb. I installed PyYySQL with pip3 install pymysql on localhost, but an error message about the missing PyMySQL still appeared. I thought perhaps I should install to a system directory with sudo, but the error still appeared.

The following did not help either, after uninstalling with pip3 again:

  • sudo apt install --yes python3-pymysql
  • sudo apt install --yes python3-mysqldb

The installation command from the PyMySQL page on PYPI (python3 -m pip install pymysql) gave this output:

Requirement already satisfied: PyMySQL in /usr/lib/python3/dist-packages (0.9.3)

Localhost is WSL2 Ubuntu 20.04.

Score:2
in flag

PyMySQL is a requirement on the host that executes the module. The module needs to be installed on the server running the msql server not the computer where ansible-playbook playbook.yml is executed.

Geoffrey avatar
cn flag
Thanks. I misunderstood what that meant.
ke flag
Why is this the case though? I thought ansible didn't require anything special installed on the remote hosts which it manages.
Henrik Pingel avatar
in flag
Ansible is agentless. But it some modules do have dependencies. Under the hood Ansible creates a small python script for each task and some have dependencies. That script is copied to the remote host and executed there. The dependencies are always listed in the documentation.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.