I am trying to use a template which generate the config file containing tinformations like the hosts, port, username, password, ...
I want to use one template and pass the tag in the template task, so the template will pick variables which are defined within the corresponding tag, i.e.:
- name: generate config
template:
src: /test/debezium_oracle_cdc_source.j2
dest: "/config/debz-oracle-test_1.json"
vars:
tags: "{{ oracle['tag1'] }}"
bootstrap_servers: "kafka:9092"
- name: generate config
template:
src: /test/debezium_oracle_cdc_source.j2
dest: "/config/debz-oracle-test_2.json"
vars:
tags: "{{ oracle['tag2'] }}"
bootstrap_servers: "kafka:9092"
My variable file
oracle:
tag1:
tables:
- DEPT
- EMPLOYEE
db_host: localhost
db_name: root
db_user: root
db_port: 1521
tag2:
tables:
- SALES
- SALES_ITEM
db_host: localhost
db_name: root
db_user: root
db_port: 1521
debezium_oracle_cdc_source.j2:
{
"database.hostname": "{{ db_host }}",
"database.port": "{{ db_port }}"
}
Basically, I want to make my variable file more readable.