|
5 | 5 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
6 | 6 |
|
7 | 7 | from __future__ import absolute_import, division, print_function
|
| 8 | + |
8 | 9 | __metaclass__ = type
|
9 | 10 |
|
10 | 11 | DOCUMENTATION = r'''
|
@@ -325,9 +326,10 @@ class MySQL_Info(object):
|
325 | 326 | 5. add info about the new subset with an example to RETURN block
|
326 | 327 | """
|
327 | 328 |
|
328 |
| - def __init__(self, module, cursor): |
| 329 | + def __init__(self, module, cursor, server_implementation): |
329 | 330 | self.module = module
|
330 | 331 | self.cursor = cursor
|
| 332 | + self.server_implementation = server_implementation |
331 | 333 | self.info = {
|
332 | 334 | 'version': {},
|
333 | 335 | 'databases': {},
|
@@ -387,6 +389,18 @@ def get_info(self, filter_, exclude_fields, return_empty_dbs):
|
387 | 389 | self.__collect(exclude_fields, return_empty_dbs, set(self.info))
|
388 | 390 | return self.info
|
389 | 391 |
|
| 392 | + def is_mariadb(self): |
| 393 | + if self.server_implementation == "mariadb": |
| 394 | + return True |
| 395 | + else: |
| 396 | + return False |
| 397 | + |
| 398 | + def is_mysql(self): |
| 399 | + if self.server_implementation == "mysql": |
| 400 | + return True |
| 401 | + else: |
| 402 | + return False |
| 403 | + |
390 | 404 | def __collect(self, exclude_fields, return_empty_dbs, wanted):
|
391 | 405 | """Collect all possible subsets."""
|
392 | 406 | if 'version' in wanted or 'settings' in wanted:
|
@@ -497,7 +511,10 @@ def __get_master_status(self):
|
497 | 511 |
|
498 | 512 | def __get_slave_status(self):
|
499 | 513 | """Get slave status if the instance is a slave."""
|
500 |
| - res = self.__exec_sql('SHOW SLAVE STATUS') |
| 514 | + if(self.is_mariadb()): |
| 515 | + res = self.__exec_sql('SHOW ALL SLAVES STATUS') |
| 516 | + else: |
| 517 | + res = self.__exec_sql('SHOW SLAVE STATUS') |
501 | 518 | if res:
|
502 | 519 | for line in res:
|
503 | 520 | host = line['Master_Host']
|
@@ -738,10 +755,16 @@ def main():
|
738 | 755 | 'Exception message: %s' % (connector_name, connector_version, config_file, to_native(e)))
|
739 | 756 | module.fail_json(msg)
|
740 | 757 |
|
| 758 | + cursor.execute("SELECT VERSION()") |
| 759 | + if 'mariadb' in cursor.fetchone()[0].lower(): |
| 760 | + server_implementation="mariadb" |
| 761 | + else: |
| 762 | + server_implementation="mysql" |
| 763 | + |
741 | 764 | ###############################
|
742 | 765 | # Create object and do main job
|
743 | 766 |
|
744 |
| - mysql = MySQL_Info(module, cursor) |
| 767 | + mysql = MySQL_Info(module, cursor, server_implementation) |
745 | 768 |
|
746 | 769 | module.exit_json(changed=False,
|
747 | 770 | connector_name=connector_name,
|
|
0 commit comments