Hi,
I’m looking for a solution to limit size of required setup for set of environments.
Below it is small chunk of bigger setup where I’m defining variables having default values.
`
app_datasources:
- Target: BackendDS
Host: “{{ backed_db.host }}”
Port: “{{ backend_db.port }}”
Connection: “{{ backend_ds_connection }}” - Target: WebDS
Host: “{{ web_db.host }}”
Port: “{{ web_db.port }}”
Connection: “{{ web_ds_connection }}”
backend_ds_connection: “{{ default_ds_connection }}”
web_ds_connection: “{{ default_ds_connection }}”
default_ds_connection:
- { Name: TxQueryTimeout, Value: “true” }
- { Name: BlockingTimeout, Value: 30000 }
`
I define variable backed_db and web_db variable for each inventory and I can re-define backend_ds_connection / web_ds_connection placeholders if I need.
Unfortunately this pattern doesn’t scale well. I need to create hundreds of “placeholders” where there is possibility to change that bit for environment.
I’m looking at vars_plugins or action plugins to generate default values if they are not defined per hosts.
For example if host define variable backend_ds.Connection.TxQueryTimeout = 100 then I would override what is defined with default_ds_connection, otherwise it would use default values.
`
app_datasources:
- “{{ backend_ds }}”
- “{{ web_ds }}”
backend_ds:
Target: BackendDS
Host: “{{ backed_db.host }}”
Port: “{{ backend_db.port }}”
Connection: “{{ backend_ds_connection }}”
web_ds:
Target: WebDS
Host: “{{ web_db.host }}”
Port: “{{ web_db.port }}”
Connection: “{{ default_ds_connection }}”
default_ds_connection:
- { Name: TxQueryTimeout, Value: “true” }
- { Name: BlockingTimeout, Value: 30000 }
`
What do you think is the best way to achieve that? Are vars_plugins or action plugins right way to go?
Regards
Kamil Demecki
``