I have the following dictionary :
mariadb_custom_cnf: { mysqld: { log-bin: '', server_id: '{{ groups[host_group_name].index(inventory_hostname) | int + 1 }}', replicate-do-db: 'replicate' }}
What I want to do is for it to be created when a condition is met (e.g. my_var: "{{ 'foo' if my_condition }}"
) but I can't find the right syntax to get it to work.
I've tried several ways but with no success :
mariadb_custom_cnf: { mysqld: { log-bin: '', server_id: '{{ groups[host_group_name].index(inventory_hostname) | int + 1 }}', replicate-do-db: 'replicate' }} if mariadb_replication_user is defined
mariadb_custom_cnf: "{ mysqld: { log-bin: '', server_id: '{{ groups[host_group_name].index(inventory_hostname) | int + 1 }}', replicate-do-db: 'replicate' }} if mariadb_replication_user is defined"
mariadb_custom_cnf: "{{ { mysqld: { log-bin: '', server_id: '{{ groups[host_group_name].index(inventory_hostname) | int + 1 }}', replicate-do-db: 'replicate' }} if mariadb_replication_user is defined }}"
Any idea(s)?