@@ -355,7 +355,63 @@ In the example below, ``{{ instance_name }}`` is replaced with *instance001*.
355
355
356
356
As a result, the paths to :ref: `snapshots and write-ahead logs <configuration_persistence >` differ for different instances.
357
357
358
+ .. _configuration_conditional :
358
359
360
+ Conditional configuration sections
361
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
362
+
363
+ A YAML configuration can include parts that apply only to instances that meet certain conditions.
364
+ This is useful for cluster upgrade scenarios: during an upgrade, instances can be running
365
+ different Tarantool versions and therefore require different configurations.
366
+
367
+ Conditional parts are defined in the :ref: `conditional <configuration_reference_conditional >` configuration section in the global scope.
368
+ It includes one or more ``if `` subsections. Each ``if `` subsection defines conditions
369
+ and configuration parts that apply to instances that meet these conditions.
370
+
371
+ The example below shows a ``conditional `` section for cluster upgrade from Tarantool 3.0.0
372
+ to Tarantool 3.1.0:
373
+
374
+ - The user-defined :ref: `label <configuration_labels >` ``upgraded `` is ``true ``
375
+ on instances that are running Tarantool 3.1.0 or later. On older versions, it is ``false ``.
376
+ - Two :ref: `compat <configuration_reference_compat >` options that were introduced in 3.1.0 are defined for Tarantool 3.1.0
377
+ instances. On older versions, they would cause an error.
378
+
379
+ .. literalinclude :: /code_snippets/snippets/config/instances.enabled/conditional/config.yaml
380
+ :language: yaml
381
+ :start-at: conditional:
382
+ :end-before: groups:
383
+ :dedent:
384
+
385
+ Example on GitHub: `conditional <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/config/instances.enabled/conditional >`_
386
+
387
+
388
+ ``if `` sections can use one variable -- ``tarantool_version ``. It contains
389
+ a three-number Tarantool version and compares with values of the same format
390
+ using the comparison operators ``> ``, ``< ``, ``>= ``, ``<= ``, ``== ``, and ``!= ``.
391
+ You can write complex conditions using the logical operators ``|| `` (OR) and ``&& `` (AND).
392
+ Parentheses ``() `` can be used to define the operators precedence.
393
+
394
+ .. code-block :: yaml
395
+
396
+ conditional :
397
+ - if : (tarantool_version > 3.2.0 || tarantool_version == 3.1.3) && tarantool_version <= 3.99.0
398
+ -- < ... >
399
+
400
+
401
+ If the same option is set in multiple ``if `` sections that are true for an instance,
402
+ this option receives the value from the section declared last in the configuration.
403
+
404
+ Example:
405
+
406
+ .. code-block :: yaml
407
+
408
+ conditional :
409
+ - if : tarantool_version >= 3.0.0
410
+ labels :
411
+ version : ' 3.0' # applies to versions >= 3.0.0 and < 3.1.0
412
+ - if : tarantool_version >= 3.1.0
413
+ labels :
414
+ version : ' 3.1+' # applies to versions >= 3.1.0
359
415
360
416
.. _configuration_environment_variable :
361
417
0 commit comments