Type string error with mariadb master slave replication setup using mysql_replication module.

63 views
Skip to first unread message

Alex Lien

unread,
Jul 17, 2017, 2:01:44 PM7/17/17
to Ansible Project

Hi,


I am trying to setup master-slave replication on mariadb 10.2. I am running ansible version 2.3.1.0. When running the playbook, I received errors about argument of type string. This is very odd because from the output of debug, the log position is obviously of type integer. I have tried to convert it (using | int) without any luck. Would anyone be able to shed some light and if there’s any work around to the problem? Thanks for all your help.


TASK [corexdb : Display output of "SHOW MASTER STATUS"] ************************

skipping: [pdus-servdb1.us.roamvu.net]

ok: [pdmaster.us.roamvu.net] => {

"master_status": {

"Binlog_Do_DB": "pdmaster",

"Binlog_Ignore_DB": "",

"File": "mysql-bin.000007",

"Is_Master": true,

"Position": 342,

"changed": false

}

}


failed: [pdus-servdb1.us.roamvu.net] (item={u'password': u'slaveservice', u'name': u'slaveservice'}) => {"failed": true, "item": {"name": "slaveservice", "password": "slaveservice"}, "msg": "argument master_log_pos is of type <type 'str'> and we were unable to convert to int: invalid literal for int() with base 10: 'master_status.Position | int'"}


- name: Check master replication status.

  mysql_replication: mode=getmaster

  delegate_to: "{{ db_master }}"

  register: master_status

  when: db_repl_type == "master"


- name: Display output of "SHOW MASTER STATUS"

  debug: var=master_status

  when: db_repl_type == "master"


- name: Configure replication on the slave.

  mysql_replication:

    mode: changemaster

    master_host: "{{ db_master }}"

    master_user: "{{ item.name }}"

    master_password: "{{ item.password }}"

    master_log_file: master_status.File

    master_log_pos: master_status.Position | int

  with_items:

    "{{ db_repl_user }}"

  when: db_repl_type == "slave"



Toshio Kuratomi

unread,
Jul 18, 2017, 9:11:17 AM7/18/17
to ansible...@googlegroups.com
Hi, at minimum you'll need double curly braces around the variables to make them expand like this:


- name: Configure replication on the slave.

  mysql_replication:

    mode: changemaster

    master_host: "{{ db_master }}"

    master_user: "{{ item.name }}"

    master_password: "{{ item.password }}"

    master_log_file: "{{ master_status.File }}"

    master_log_pos: "{{ master_status.Position | int }}"

  with_items:

    "{{ db_repl_user }}"


I added the braces around master_log_file's argument and master_log_pos's argument.


-Toshio


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1147ec2c-f556-42f5-b49a-a8920806046b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Lien

unread,
Jul 19, 2017, 12:54:54 PM7/19/17
to ansible...@googlegroups.com
Hi Toshio,

I found my mistake in the check master replication status which should be:

when: db_repl_type == "slave"

And you are right, the double curly braces are needed.

Thanks for your help.

Alex

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/cAR3VIXqggs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.

To post to this group, send email to ansible-project@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages