Hello, ansible experts.
I'm trying to parameterize eth interface in `group_vars/all` so that I can use it in playbook easier.
group_vars/all file looks like this.
my_int_if: eth1
my_int_ip: "{{ ansible_eth1.ipv4.address }}"
my_int_obj: "{{ ansible_eth1 }}"
I could successfuly use those variables with following playbook and template file.
- name: copy mysql file
tempalte: src=galera.cnf.j2 dest=/etc/my.cnf.d/galera.cnf
bind-address={{ my_int_ip }}
# becomes this as intended.
bind-address=192.168.50.126
But now, when I tried to use "{{my_int_ip}}" from playbook directly, It didin't work as intended.
- name: galera cluster replication bluh
mysql_user:
name: wsrep_sst-user
host: "{{ hostvars[item].my_int_ip }}"
password: password
priv: "*.*:ALL"
with_items: play_hosts
According to the Error message, it looked like this variable was not expanded well.
msg: (1396, "Operation CREATE USER failed for 'wsrep_sst-user'@'{# ansible_eth1.ipv4.address #}'")
I would like to know why I could use it at template, and not at playbook.
And if you have any good advice to parameterize the ethernet for firewall, bind address, and etc., please show me!!
Thank you!