# Type string error with mariadb master slave replication setup using mysql\_replication module.

**URL:** <https://forum.ansible.com/t/type-string-error-with-mariadb-master-slave-replication-setup-using-mysql-replication-module/25007>\
**Category:** Ansible Project\
**Created:** [July 17, 2017, 6:01pm UTC](https://forum.ansible.com/t/type-string-error-with-mariadb-master-slave-replication-setup-using-mysql-replication-module/25007 "2017-07-17T18:01:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Lien](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@Alex\_Lien](https://forum.ansible.com/u/Alex_Lien)\
**Post date:** [July 17, 2017, 6:01pm UTC](https://forum.ansible.com/t/type-string-error-with-mariadb-master-slave-replication-setup-using-mysql-replication-module/25007/1 "2017-07-17T18:01:44Z")

</div>

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](http://pdus-servdb1.us.roamvu.net)]

ok: [[pdmaster.us.roamvu.net](http://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](http://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”

---

<div class="post-metadata">

**Author:** ![tkuratom](https://avatars.discourse-cdn.com/v4/letter/t/b19c9b/32.png) [@tkuratom](https://forum.ansible.com/u/tkuratom)\
**Post date:** [July 18, 2017, 3:52am UTC](https://forum.ansible.com/t/type-string-error-with-mariadb-master-slave-replication-setup-using-mysql-replication-module/25007/2 "2017-07-18T03:52:35Z")

</div>

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](http://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

---

<div class="post-metadata">

**Author:** ![Alex\_Lien](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@Alex\_Lien](https://forum.ansible.com/u/Alex_Lien)\
**Post date:** [July 19, 2017, 4:54pm UTC](https://forum.ansible.com/t/type-string-error-with-mariadb-master-slave-replication-setup-using-mysql-replication-module/25007/3 "2017-07-19T16:54:41Z")

</div>

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
