Hi
i want to create a mariaDB active - active replication. And so i need to modify the my.cnf with ansible.
I have two hosts both are defined undser the host variables with:
File for host 1:
default_ip: 127.0.0.1
ansible_ssh_host: 127.0.0.1
host_id : 7
File for host 2:
default_ip: 127.0.0.2
ansible_ssh_host: 127.0.0.2
host_id : 8
in my playbook i copy the my.cnf template from local to both hosts and want to modify it:
- name: modify it
replace:
path: "{{ mysql_conf_dir }}/my.cnf"
regexp: 'server-id = 7'
replace: 'server-id = {{ hostvars.host_id }}'
i got:
[WARNING]: While constructing a mapping from /mnt/c/svn/SystemsEngineering/Ansible/UBS-OST/roles/maria_cluster/tasks/main.yml, line 15, column 3, found a duplicate dict key (replace). Using last defined value
only.
[WARNING]: Ignoring invalid attribute: path
[WARNING]: Ignoring invalid attribute: regexp
....
fatal:
[ubsostvm001.ka2.smarthouse.local]: FAILED! => {"changed": false,
"msg": "missing required arguments: path, regexp"}
fatal:
[ubsostvm001.ffm3.smarthouse.local]: FAILED! => {"changed": false,
"msg": "missing required arguments: path, regexp"}
What is the correct way to set an host id in the my.cnf based on the host number.