Skip to content

Commit 63fac40

Browse files
Michael Vasseurvmcj
Michael Vasseur
authored andcommittedMar 31, 2024
Replication fails in the ICPC image
Because we have more interfaces we need to specify which network interface we want to use.
1 parent 258b3f2 commit 63fac40

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed
 

‎provision-contest/ansible/roles/keepalived/templates/keepalived.conf.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
vrrp_instance lb_ipv4 {
22
state MASTER
3-
interface {{ ansible_facts['default_ipv4']['interface'] }}
3+
interface {{ KEEPALIVED_INTERFACE|default(ansible_facts['default_ipv4']['interface']) }}
44
use_vmac
55
virtual_router_id 32
66
priority {{KEEPALIVED_PRIORITY}}

‎provision-contest/ansible/roles/mysql_replication/tasks/main.yml

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
regexp: '^bind-address\s*='
1414
replace: '#bind-address ='
1515

16+
- name: Set the replication interface variable
17+
set_fact:
18+
replication_interface: "{{ REPLICATION_INTERFACE|default(ansible_default_ipv4.interface) }}"
19+
20+
- name: Set the variable for the IP address of the replication interface
21+
set_fact:
22+
replication_interface_ip_address: "{{ vars['ansible_' + replication_interface]['ipv4']['address'] }}"
23+
1624
- name: Add mysql config snippet for replication
1725
template:
1826
src: mysql.replication.cnf.j2

‎provision-contest/ansible/roles/mysql_replication/templates/mysql.replication.cnf.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ log-bin = /var/log/mysql/mysql-bin.log
88
binlog_do_db = domjudge
99

1010
# Host specific replication configuration
11-
server_id = {{ ansible_default_ipv4.address | ipaddr('int') }}
11+
server_id = {{ replication_interface_ip_address | ipaddr('int') }}

‎provision-contest/ansible/roles/mysql_replication/templates/setup-replication.sh.j2

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ service mysql start
181181

182182
echo "Starting replication locally..."
183183
mysql -e "
184-
CHANGE MASTER TO MASTER_HOST='{{ SERVER_IP_PREFIX }}.${PRIMARY_SERVER_ID}',
184+
CHANGE MASTER TO MASTER_HOST='${PRIMARY}',
185185
MASTER_USER='replication',
186186
MASTER_PASSWORD='{{ REPLICATION_PASSWORD }}',
187187
MASTER_LOG_FILE='${PRIMARY_BINLOG}',
@@ -217,7 +217,7 @@ OUR_LOGPOS=$(get_field 'Position' "$OUR_STATUS")
217217
if [ "$SETUP_MASTER_MASTER" -eq 1 ]; then
218218
echo "Starting replication on $PRIMARY..."
219219
ssh "$PRIMARY" "mysql -e '
220-
CHANGE MASTER TO MASTER_HOST=\"{{ SERVER_IP_PREFIX }}.${OUR_SERVER_ID}\",
220+
CHANGE MASTER TO MASTER_HOST=\"{{ replication_interface_ip_address }}\",
221221
MASTER_USER=\"replication\",
222222
MASTER_PASSWORD=\"{{ REPLICATION_PASSWORD }}\",
223223
MASTER_LOG_FILE=\"${OUR_BINLOG}\",

0 commit comments

Comments
 (0)