Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow replica master to be differ from local inventory + fix Is_Replica or Is_Slave #503

Merged
merged 2 commits into from
Nov 17, 2022

Conversation

giorgioma
Copy link
Contributor

E.g.
I am running ansible on my local machine and they are accessible over public IP but i want the master and the slave to communicate over some other network interface card.

mysql_replication_master_inventory_host defaults to mysql_replication_master so it's a non-breaking change

@giorgioma
Copy link
Contributor Author

I have upgraded some dependencies in my dev environment (MariaDB) and my slave data from getreplica is now

ok: [db2] => {
    "slave": {
        "Is_Replica": false,
        "changed": false,
        "failed": false,
        "msg": "Server is not configured as mysql replica",
        "queries": []
    }
}

but the current check is
(slave.Is_Slave is defined and not slave.Is_Slave) or (slave.Is_Slave is not defined and slave is failed)
I am guessing it should now be
(slave.Is_Slave is defined and not slave.Is_Slave) or (slave.Is_Replica is defined and not slave.Is_Replica) or (slave.Is_Slave is not defined and slave.Is_Replica is not defined and slave is failed)
to cover both cases for the naming transition

@giorgioma giorgioma changed the title Allow mysql_replication_master to be different from local inventory Allow replica master to be differ from local inventory + fix Is_Replica or Is_Slave Nov 17, 2022
This was referenced Nov 17, 2022
@geerlingguy geerlingguy merged commit ae3d39b into geerlingguy:master Nov 17, 2022
@giorgioma
Copy link
Contributor Author

Well that was a quick merge! Cheers

@liammcdermott
Copy link
Contributor

liammcdermott commented Dec 11, 2022

Hey @giorgioma, I'm just wonder if there's a reason the task: - name: Start replication. didn't get the same treatment? It still has the old behaviour of only checking slave.Is_Slave.

I notice the logic of that when might be incorrect, is that the reason you didn't touch it?

Edit: what I mean when I say the logic of the Start replication task's when clause might be incorrect, is that it never triggers for me. I'm not 100% sure why, but I believe it's because earlier tasks set the replication up, so not slave.Is_Replica always evaluates to false. Removing the not from not slave.Is_Replica works for me.

@hahayusuf
Copy link

hahayusuf commented Dec 12, 2022

I am having the same issue of Start replication never triggering. Not sure why this is the case.

See below for logs that may help:

image

Update: when I comment out the slave.Is_Replica it works as expected. Still not sure what is wrong with the when conditions.

@liammcdermott
Copy link
Contributor

liammcdermott commented Dec 13, 2022

@hahayusuf I think what's wrong with it is mentioned in my edit. not save.Is_Replica evaluates to false, since the replication is setup (even though it's not started). I tested and at least this was the case for me.

I changed the when for Start replication to this:

- (slave.Is_Slave is defined and slave.Is_Slave) or (slave.Is_Replica is defined and slave.Is_Replica) or (slave.Is_Slave is not defined and slave.Is_Replica is not defined and slave is failed)

@giorgioma
Copy link
Contributor Author

Ah yes! I was informed i broke my staging env as well, i'll open a pr in the morning
I simply didn't notice that the last command had that condition as well

@liammcdermott
Copy link
Contributor

@giorgioma No worries, I created #511. Would you mind trying that out and seeing if it works for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants