1

I am using below block to fetch mysql variables.

- name: Check for wsrep_cluster_status setting
  mysql_variables:
    login_user: '{{ mysql_root_user }}'
    login_password: '{{ mysql_root_pwd }}'
    variable: wsrep_ready
  register: v_wcs
  become_user: mysql

When I execute playbook, it gives be following message:

TASK [mysql-post-patch-validation : Check for wsrep_cluster_status setting] *****************************************************************************************************************
task path: /ansible/MYSQL_PROD_PLAYBOOKS/roles/mysql-post-patch-validation/tasks/main.yml:21
fatal: [dehammy199.int.kn]: **FAILED! => {"changed": false, "msg": "Variable not available \"wsrep_ready\""}**

PLAY RECAP **********************************************************************************************************************************************************************************
dehammy199.int.kn          : ok=5    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

However, when I use the same module to fetch other variable values not related to wsrep, for example wait_timeout, I get the results:

- name: Check for wait_timeout setting
  mysql_variables:
    login_user: '{{ mysql_root_user }}'
    login_password: '{{ mysql_root_pwd }}'
    variable: wait_timeout
  register: v_wcs_2
  become_user: mysql
 TASK [mysql-post-patch-validation : Check for wait_timeout setting] *************************************************************************************************************************
task path: /ansible/MYSQL_PROD_PLAYBOOKS/roles/mysql-post-patch-validation/tasks/main.yml:21
ok: [dehammy199.int.kn] => {"changed": false, "msg": "350"}

Is there a workaround for me to fetch wsrep related values using Ansible modules?

Yes, I can query the variable from mysql. (End result is same in all the cases.)

root@localhost [(none)]> show global status like 'wsrep_ready';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wsrep_ready   | ON    |
+---------------+-------+
1 row in set (0.00 sec)

root@localhost [(none)]>
  • well, the good news about them being open source is you can [see what it is doing](https://github.com/ansible-collections/community.mysql/blob/3.4.0/plugins/modules/mysql_variables.py#L138) and then you can replicate the experience for yourself using `mysql`; do you see the variable but ansible does not? – mdaniel Aug 23 '22 at 19:15
  • (a) don't put code snippets in comments, they're terrible for that, instead [edit your question](https://stackoverflow.com/posts/73458063/edit) and include those details. (b) that's not the `wsrep_ready` variable you asked for in your playbook, so is this just a simple typo? – mdaniel Aug 24 '22 at 15:44
  • I have updated my question with better readable format. – Srikanth Lingala Aug 26 '22 at 08:04
  • For clarity, you're using `SHOW GLOBAL STATUS` but, as I politely linked to the source, they're using `SHOW VARIABLES WHERE Variable_name = ` so if you're asking why a `show status` is not returned by `mysql_variables:` then there's your answer – mdaniel Aug 26 '22 at 15:51

0 Answers0