Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82baf75

Browse files
mexonMatthew Exon
andauthored
Clarified error message about missing python modules (ansible-collections#279)
* Clarified error message about missing python modules, and tweak documentation to suggest overriding interpreter. * Mention mysqlclient as another option * Correct mysqlclient suggestions from python2 to python3 Co-authored-by: Matthew Exon <[email protected]>
1 parent 5afae45 commit 82baf75

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

plugins/doc_fragments/mysql.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,13 @@ class ModuleDocFragment(object):
7979
The Python package may be installed with apt-get install python-pymysql (Ubuntu; see M(ansible.builtin.apt)) or
8080
yum install python2-PyMySQL (RHEL/CentOS/Fedora; see M(ansible.builtin.yum)). You can also use dnf install python2-PyMySQL
8181
for newer versions of Fedora; see M(ansible.builtin.dnf).
82-
- Be sure you have PyMySQL or MySQLdb library installed on the target machine
83-
for the Python interpreter Ansible uses, for example, if it is Python 3,
84-
you must install the library for Python 3. You can also change the interpreter.
85-
For more information, see U(https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html).
82+
- Be sure you have mysqlclient, PyMySQL, or MySQLdb library installed on the target machine
83+
for the Python interpreter Ansible discovers. For example if ansible discovers and uses Python 3, you need to install
84+
the Python 3 version of PyMySQL or mysqlclient. If ansible discovers and uses Python 2, you need to install the Python 2
85+
version of either PyMySQL or MySQL-python.
86+
- If you have trouble, it may help to force Ansible to use the Python interpreter you need by specifying
87+
C(ansible_python_interpreter). For more information, see
88+
U(https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html).
8689
- Both C(login_password) and C(login_user) are required when you are
8790
passing credentials. If none are present, the module will attempt to read
8891
the credentials from C(~/.my.cnf), and finally fall back to using the MySQL

plugins/module_utils/mysql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
except ImportError:
3030
mysql_driver = None
3131

32-
mysql_driver_fail_msg = 'The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is required.'
32+
mysql_driver_fail_msg = 'A MySQL module is required: for Python 2.7 either PyMySQL, or MySQL-python, or for Python 3.X mysqlclient or PyMySQL. Consider setting ansible_python_interpreter to use the intended Python version.'
3333

3434

3535
def parse_from_mysql_config_file(cnf):

0 commit comments

Comments
 (0)