geerlingguy / ansible-role-mysql

Ansible Role - MySQL
https://galaxy.ansible.com/geerlingguy/mysql/
MIT License
1.05k stars 861 forks source link

Check master replication status. #500

Closed zangra-dev closed 1 year ago

zangra-dev commented 2 years ago

In tasks/replication.yml This errors occurs while I'm testing this role on vagrant guests.

Problem 1 has a delegate_to: "{{ mysql_replication_master }} option which in my case needed a remote_user to fix a remote SSH connection failure

Problem 2 a) When I give the remote_user: my ansible_user variable it gives me an "Unhandled exception occurred while templating" b) Using a custom group variable gives me an "msg": "'remote_user' is undefined"

solution is to set a variable in defaults/main.yml which can be overridden for the different used distribution ....

- name: Check master replication status.
  mysql_replication: mode=getprimary
  delegate_to: "{{ mysql_replication_master }}"
  remote_user: "{{ guest_user }}"
  register: master
  when:
    - (slave.Is_Replica is defined and not slave.Is_Replica) or (slave.Is_Replica is not defined and slave is failed)
    - mysql_replication_role == 'slave'
    - (mysql_replication_master | length) > 0
  tags: ['skip_ansible_galaxy']

- name: "debug 'master' var"
  debug:
    msg: "{{ master }}, guest_user: {{ guest_user }}"

This is also a follow up of #495

giorgioma commented 1 year ago

See #503

stale[bot] commented 1 year ago

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

stale[bot] commented 1 year ago

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.