Skip to content

Commit

Permalink
Docs: add info how to cope with a protocol-related connection error u…
Browse files Browse the repository at this point in the history
…sing login_unix_socket argument (#420)
  • Loading branch information
Andersson007 authored Aug 26, 2022
1 parent 0a68bb2 commit f1d63e3
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugins/doc_fragments/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ModuleDocFragment(object):
login_unix_socket:
description:
- The path to a Unix domain socket for local connections.
- Use this parameter to avoid the C(Please explicitly state intended protocol) error.
type: str
connect_timeout:
description:
Expand Down Expand Up @@ -78,6 +79,8 @@ class ModuleDocFragment(object):
- PyMySQL (Python 2.7 and Python 3.x) or
- MySQLdb (Python 2.x)
notes:
- "To avoid the C(Please explicitly state intended protocol) error, use the I(login_unix_socket) argument,
for example, C(login_unix_socket: /run/mysqld/mysqld.sock)."
- Requires the PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) package installed on the remote host.
The Python package may be installed with apt-get install python-pymysql (Ubuntu; see M(ansible.builtin.apt)) or
yum install python2-PyMySQL (RHEL/CentOS/Fedora; see M(ansible.builtin.yum)). You can also use dnf install python2-PyMySQL
Expand Down
3 changes: 3 additions & 0 deletions plugins/modules/mysql_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,13 @@
'''

EXAMPLES = r'''
# If you encounter the "Please explicitly state intended protocol" error,
# use the login_unix_socket argument
- name: Create a new database with name 'bobdata'
community.mysql.mysql_db:
name: bobdata
state: present
login_unix_socket: /run/mysqld/mysqld.sock
- name: Create new databases with names 'foo' and 'bar'
community.mysql.mysql_db:
Expand Down
3 changes: 3 additions & 0 deletions plugins/modules/mysql_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@
# Display all info from databases group except settings:
# ansible databases -m mysql_info -a 'filter=!settings'
# If you encounter the "Please explicitly state intended protocol" error,
# use the login_unix_socket argument
- name: Collect all possible information using passwordless root access
community.mysql.mysql_info:
login_user: root
login_unix_socket: /run/mysqld/mysqld.sock
- name: Get MySQL version with non-default credentials
community.mysql.mysql_info:
Expand Down
3 changes: 3 additions & 0 deletions plugins/modules/mysql_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@
'''

EXAMPLES = r'''
# If you encounter the "Please explicitly state intended protocol" error,
# use the login_unix_socket argument
- name: Simple select query to acme db
community.mysql.mysql_query:
login_db: acme
query: SELECT * FROM orders
login_unix_socket: /run/mysqld/mysqld.sock
- name: Select query to db acme with positional arguments
community.mysql.mysql_query:
Expand Down
3 changes: 3 additions & 0 deletions plugins/modules/mysql_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,12 @@
'''

EXAMPLES = r'''
# If you encounter the "Please explicitly state intended protocol" error,
# use the login_unix_socket argument
- name: Stop mysql replica thread
community.mysql.mysql_replication:
mode: stopreplica
login_unix_socket: /run/mysqld/mysqld.sock
- name: Get primary binlog file name and binlog position
community.mysql.mysql_replication:
Expand Down
3 changes: 3 additions & 0 deletions plugins/modules/mysql_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@
'''

EXAMPLES = r'''
# If you encounter the "Please explicitly state intended protocol" error,
# use the login_unix_socket argument, for example, login_unix_socket: /run/mysqld/mysqld.sock
# Example of a .my.cnf file content for setting a root password
# [client]
# user=root
Expand Down
3 changes: 3 additions & 0 deletions plugins/modules/mysql_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,14 @@
'''

EXAMPLES = r'''
# If you encounter the "Please explicitly state intended protocol" error,
# use the login_unix_socket argument
- name: Removes anonymous user account for localhost
community.mysql.mysql_user:
name: ''
host: localhost
state: absent
login_unix_socket: /run/mysqld/mysqld.sock
- name: Removes all anonymous user accounts
community.mysql.mysql_user:
Expand Down
3 changes: 3 additions & 0 deletions plugins/modules/mysql_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@
'''

EXAMPLES = r'''
# If you encounter the "Please explicitly state intended protocol" error,
# use the login_unix_socket argument
- name: Check for sync_binlog setting
community.mysql.mysql_variables:
variable: sync_binlog
login_unix_socket: /run/mysqld/mysqld.sock
- name: Set read_only variable to 1 persistently
community.mysql.mysql_variables:
Expand Down

0 comments on commit f1d63e3

Please sign in to comment.