2023-12-17 20:25:53 +01:00
The variables
2024-10-21 15:25:00 +02:00
==============
2023-12-17 20:25:53 +01:00
Synopsis
2024-10-21 15:25:00 +02:00
---------
2023-12-17 20:25:53 +01:00
.. glossary ::
variable
2026-06-01 19:47:26 +02:00
A variable is an abstract black box (container) paired with an associated symbolic name, most often an option configuration, which contains some defined or undefined data setting referred to as a :term: `value` .
2024-07-01 14:06:59 +02:00
2024-10-21 15:03:34 +02:00
value
2025-05-26 22:09:29 +02:00
A value is a variable's setting.
Variable can have a default value, that is a setting defined in the :term: `structure file` ,
or no value at all, then the value needs to be define later by the :term: `operator` .
2024-10-21 15:03:34 +02:00
.. discussion :: Discussion
2025-02-09 11:20:36 +01:00
The variable is, by definition, strongly typed.
Rougail uses static type definition and even type inference.
Indeed, the constistency handling system heavyly relies on the type system definition.
2025-02-03 20:20:15 +01:00
Variables may only be able to store a specified data type.
OK, variables are the containers for storing the values. It has something to do with typing.
2025-02-09 11:20:36 +01:00
2025-02-03 20:20:15 +01:00
But consitency handling system is is not just about strong typing. It is more than that.
2023-12-17 20:25:53 +01:00
2025-02-03 20:20:15 +01:00
Names
2024-10-21 15:25:00 +02:00
------
2024-07-01 14:06:59 +02:00
2026-06-01 19:47:26 +02:00
It is with its name that we will be able to interact with the variable.
2025-02-03 20:20:15 +01:00
2025-02-09 11:20:36 +01:00
.. seealso ::
2025-02-03 20:20:15 +01:00
2026-06-01 19:47:26 +02:00
Have a look at the :ref: `variable naming convention <namingconvention>`
2024-07-01 14:06:59 +02:00
2023-12-17 20:25:53 +01:00
Parameters
-------------
2024-07-01 14:06:59 +02:00
.. list-table ::
2023-12-17 20:25:53 +01:00
:widths: 15 45
:header-rows: 1
2024-07-01 14:06:59 +02:00
2023-12-17 20:25:53 +01:00
* - Parameter
- Comments
2024-07-01 14:06:59 +02:00
2026-06-01 08:55:35 +02:00
* - **description**
`string`
- Description of the variable.
User information to understand the usefulness of the variable.
2026-06-01 12:36:47 +02:00
.. seealso :: tutorial with a real world sample :doc: `description parameter <tutorial/preliminary>`
2026-06-01 08:55:35 +02:00
2023-12-17 20:25:53 +01:00
* - **help**
2024-07-01 14:06:59 +02:00
`string`
2023-12-17 20:25:53 +01:00
- Additional help associated with the variable.
2024-07-01 14:06:59 +02:00
2026-06-01 12:36:47 +02:00
.. seealso :: tutorial with a real world sample :doc: `help parameter <tutorial/examples>`
2024-07-01 14:06:59 +02:00
2026-06-01 08:55:35 +02:00
* - **mode**
`string`
- Variable's mode.
The mode is a way of classifying the importance, the level of expertise required, or the access rights to a variable.
This parameter allows you to define the variable mode.
.. attention :: Mode is not configured by default. You have to define mode level before use this parameter.
**Default value** : The `default` mode of a variable is the mode of the parent family, but there is special cases:
- a variable with an automatically modified value or an automatic read-only variable is by default in the smaller mode
- if the variable is not in a family, the variable will have a medium mode by default
- a :term: `mandatory` variable without default value (calculate or not) will have the smaller mode
2026-06-01 12:36:47 +02:00
.. seealso :: tutorial with a real world sample :doc: `mode parameter <tutorial/mode>`
2026-06-01 08:55:35 +02:00
* - **tags**
`list of strings`
- A tag allows you to specialize a variable.
A tag can have several functions:
- Additional information in the documentation
- Variable exclusion
- Variable selection
- and so on
* - **examples**
`list`
- List of examples to illustrate possible values for a variable
2026-06-01 12:36:47 +02:00
.. seealso :: tutorial with a real world sample :doc: `examples parameter <tutorial/examples>`
2026-06-01 08:55:35 +02:00
* - **test**
`list`
- The `test` parameter is a special parameter that allows :term: `structure file` designers to influence a test robot by specifying useful values to test.
Concretely, the content of this parameter is recorded in the `information` parameter of the corresponding `Tiramisu` option object.
* - **type**
`string`
- Type of the variable.
See the list of available type below.
2026-06-01 12:36:47 +02:00
.. seealso :: tutorial with a real world sample :doc: `type parameter <tutorial/types>`
2026-06-01 08:55:35 +02:00
* - **params**
`object`
- Parameters to adjust type validation of the variable.
See the list of available parameters for each type below.
2026-06-01 12:36:47 +02:00
.. seealso :: tutorial with a real world sample :doc: `params parameter <tutorial/types>`
2026-06-01 08:55:35 +02:00
* - **multi**
`boolean`
2026-06-01 12:36:47 +02:00
2026-06-01 08:55:35 +02:00
- The value of the variable is a list.
2026-06-01 12:36:47 +02:00
**Default value** : mostly `false` , but there is special cases:
2026-06-01 08:55:35 +02:00
- the default value is a list
- a variable with a variable :term: `multiple <multi>` has default value
It possible to adjust multi parameters with **params** :
- multi_length: number of expected values for a multiple variable
- multi_min_length: maximum number of expected values for a multiple variable
- multi_max_length: minimum number of expected values for a minimum variable
2024-07-01 14:06:59 +02:00
2026-06-01 12:36:47 +02:00
.. seealso :: tutorial with a real world sample :doc: `multi parameter <tutorial/multiple>`
2023-12-17 20:25:53 +01:00
* - **validators**
`list`
- Value validators.
2024-07-01 14:06:59 +02:00
2026-06-01 08:55:35 +02:00
The value of the variable will be considered invalid if the Jinja template return an error.
2026-06-01 12:36:47 +02:00
.. seealso :: tutorial with a real world sample :doc: `validators parameter <tutorial/validators>`
2026-06-01 08:55:35 +02:00
* - **default**
- Default value(s) of the variable.
This value is typed, you must correctly fill out the YAML file to avoid defining a value with an incorrect type. For example, a `integer` must be a digit type, a :term: `multiple <multi>` variable must be a `list` type, ...
For a non :term: `leading` :term: `multiple <multi>` variable, the first value defined in the list will also be the default value proposed if a new value is added to this variable.
2026-06-01 12:36:47 +02:00
.. seealso :: tutorial with a real world sample :doc: `default parameter <tutorial/preliminary>`
2026-06-01 08:55:35 +02:00
* - **secret_manager**
- The variable use a secret manager to get value
2026-06-02 12:03:38 +02:00
.. todo :: document it
2026-06-01 08:55:35 +02:00
2023-12-17 20:25:53 +01:00
* - **auto_save**
2024-07-01 14:06:59 +02:00
`boolean`
2023-12-17 20:25:53 +01:00
- Variable with automatically modified value.
2024-07-01 14:06:59 +02:00
2023-12-17 20:25:53 +01:00
A variable with automatically modified value is a variable whose value will be considered as *modified* (that is, it is no longer the variable's default value).
For example, if the value of this variable comes from a calculation, the value will no longer be recalculated.
These variables are usually :term: `required` variables. In fact, these variables are only automatically modified if they have a value.
2024-07-01 14:06:59 +02:00
2023-12-17 20:25:53 +01:00
**Default value** : `false`
2026-06-01 12:36:47 +02:00
.. seealso :: tutorial with a real world sample :doc: `auto_save parameter <tutorial/autosave>`
2024-07-01 14:06:59 +02:00
2026-06-01 08:55:35 +02:00
* - **mandatory**
2023-12-17 20:25:53 +01:00
2026-06-01 08:55:35 +02:00
`boolean` or :term: `calculation`
- Mandatory variable.
2024-07-01 14:06:59 +02:00
2026-06-01 08:55:35 +02:00
Variable whose value is `required` .
2023-12-17 20:25:53 +01:00
2026-06-01 08:55:35 +02:00
For a :term: `multiple <multi>` variable, this means that the list shall not be empty (means `null` (`None` ) or empty list for a i:term: `multiple <multi>` ).
2023-12-17 20:25:53 +01:00
2026-06-01 08:55:35 +02:00
**Default value** : `true`
2025-11-06 21:54:48 +01:00
2026-06-01 12:36:47 +02:00
.. seealso :: tutorial with a real world sample :doc: `mandatory parameter <tutorial/nullable>`
2026-06-01 08:55:35 +02:00
* - **empty**
`boolean` or :term: `calculation`
- The value `null` (`None` ) is not allowed in :term: `multiple <multi>` variable.
The `mandatory` control only if the length :term: `multiple <multi>` variable is not 0. But the `null` value is not allowed. With empty parameter we can allowed it.
If `null` is an appropriate value, set empty: false.
**Default value** : `true`
2025-11-06 21:54:48 +01:00
2023-12-17 20:25:53 +01:00
* - **unique**
`boolean`
2026-06-01 08:55:35 +02:00
- The :term: `multiple <multi>` variable accepts the same value several times.
If unique is set to `false` , a :term: `multiple <multi>` variable only accepts the same value once in the list.
2023-12-17 20:25:53 +01:00
**Default value** : `false`
2026-06-01 08:55:35 +02:00
2023-12-17 20:25:53 +01:00
* - **hidden**
2024-07-01 14:06:59 +02:00
`boolean` or :term: `calculation`
2023-12-17 20:25:53 +01:00
- Invisible variable.
2024-07-01 14:06:59 +02:00
2023-12-17 20:25:53 +01:00
Enables us to *hide* a variable.
This means that the variable will no longer be visible in `read-write` mode, but only for calculations or in `read-only` mode.
2024-07-01 14:06:59 +02:00
2023-12-17 20:25:53 +01:00
When a variable is made invisible, the user will not be able to modify its value; if he has already succeeded in modifying it, this value will not be taken into account.
**Default value** : `false`
2026-06-01 08:55:35 +02:00
2026-06-01 12:36:47 +02:00
.. seealso :: tutorial with a real world sample :doc: `hidden parameter <tutorial/properties>` (the tutorial focuses on family, but the principle is the same for a variable)
2026-06-01 08:55:35 +02:00
2023-12-17 20:25:53 +01:00
* - **disabled**
2024-07-01 14:06:59 +02:00
`boolean` or :term: `calculation`
2023-12-17 20:25:53 +01:00
- Disabled variable.
2026-06-01 08:55:35 +02:00
Allows us to *deactivate* a variable.
2023-12-17 20:25:53 +01:00
This means that the variable will no longer be visible to the user but also to a :term: `calculation` .
**Default value** : `false` .
2026-06-01 08:55:35 +02:00
**Default value** : `false`
2026-06-01 12:36:47 +02:00
.. seealso :: tutorial with a real world sample :doc: `disabled parameter <tutorial/properties>` (the tutorial focuses on family, but the principle is the same for a variable)
2026-06-01 08:55:35 +02:00
* - **frozen**
2023-12-17 20:25:53 +01:00
2024-07-01 14:06:59 +02:00
`boolean` or :term: `calculation`
2026-06-01 08:55:35 +02:00
- Read only variable.
2023-12-17 20:25:53 +01:00
2026-06-01 08:55:35 +02:00
Enables us to have an immutable variable.
This means that the variable will be visible but user will not allowed to change the value.
**Default value** : `false`
2023-12-17 20:25:53 +01:00
* - **redefine**
`boolean`
2025-02-09 11:20:36 +01:00
- It is possible to define a variable in one :term: `structure file` and change its behavior in a second :term: `structure file` . In this case you must explicitly redefine the variable.
2023-12-17 20:25:53 +01:00
**Default value** : `false`
2026-06-01 08:55:35 +02:00
2023-12-17 20:25:53 +01:00
* - **exists**
`boolean`
2026-06-01 08:55:35 +02:00
- This parameter does two things:
2023-12-17 20:25:53 +01:00
2026-06-01 08:55:35 +02:00
- creates a variable if it does not exist in another :term: `structure file` (otherwise do nothing), in this case the value of the parameter must be `true`
- in conjunction with the `redefine` parameter set to `true` , only modifies the behavior if it is pre-existing, in which case the parameter's value must be `false` .
2024-07-01 14:06:59 +02:00
2023-12-17 20:25:53 +01:00
**Default value** : `null`
2026-06-01 19:47:26 +02:00
* - **choices**
:term: `calculation` or a list of :term: `calculation` or data
- Available choices.
.. important :: This parameter is only available for variable with `choice` type.
* - **regexp**
`string`
- Validation with a regular expressions.
.. important :: This parameter is only available for variable with `regexp` type.
Shorthand declaration
----------------------------
Shorthand declaration is a way to declare a variable in a condenced number of line.
To create a variable, just add a key with it's name:
.. code-block :: yaml
%YAML 1.2
---
version: 1.1
my_variable:
...
You can add a default value:
.. code-block :: yaml
%YAML 1.2
---
version: 1.1
my_variable: my_value
...
Or a multi default value:
.. code-block :: yaml
%YAML 1.2
---
version: 1.1
my_variable:
- my_value_1
- my_value_2
...
By default, the description of the variable is the variable name.
It's a best practice to description a variable. Just add comment in same line of name, this comment is use as description:
.. code-block :: yaml
%YAML 1.2
---
version: 1.1
my_variable: my_value # This is a great variable
...
But in shorthand notation, you can only define variable name, default value, multi and description.
.. attention :: Any other parameters will create extra variables or families
..
.. .. glossary::
..
.. short-hand notation
..
.. A short-hand notation in Rougail is the ability to define a variable in
.. a short-hand way, there are several example:
..
.. - a default value:
..
.. .. code-block:: yaml
..
.. my_var: true
..
.. instead of:
..
.. .. code-block:: yaml
..
.. my_var:
.. default: true
Variable's types
-----------------
2024-07-01 14:06:59 +02:00
2025-11-08 09:45:56 +01:00
A variable **always has a type** . The system is **strongly** typed.
2023-12-17 20:25:53 +01:00
2026-06-01 19:47:26 +02:00
Depending on the definition of the variable type, the defined variable will accept values of the associated type.
Primitive Types
'''''''''''''''''''
2023-12-17 20:25:53 +01:00
2024-07-01 14:06:59 +02:00
.. list-table ::
2023-12-17 20:25:53 +01:00
:widths: 15 25 20 15
:header-rows: 1
2024-07-01 14:06:59 +02:00
2023-12-17 20:25:53 +01:00
* - Value
- Comments
- Parameters
- Samples
2024-07-01 14:06:59 +02:00
2023-12-17 20:25:53 +01:00
* - string
- character string (default type)
2024-07-01 14:06:59 +02:00
-
2026-06-01 19:47:26 +02:00
- example
2024-07-01 14:06:59 +02:00
2023-12-17 20:25:53 +01:00
"1"
"true"
2026-06-01 19:47:26 +02:00
2025-10-26 13:31:47 +01:00
* - integer
- a integer
2026-06-01 19:47:26 +02:00
- `min_integer` : minimum integer allowed (unlimited by default)
`max_integer` : maximum integer allowed (unlimited by default)
- 42
2024-07-01 14:06:59 +02:00
2023-12-17 20:25:53 +01:00
* - float
- a floating number
2024-07-01 14:06:59 +02:00
-
2026-06-01 19:47:26 +02:00
- 1.42
2023-12-17 20:25:53 +01:00
* - boolean
- A boolean, if no value is defined the default value of this variable will be `true` , the variable will also be :term: `mandatory` by default
2026-06-01 19:47:26 +02:00
.. seealso :: tutorial with a real world sample :doc: `boolean type variable <tutorial/types>`
2024-07-01 14:06:59 +02:00
-
2023-12-17 20:25:53 +01:00
- `true`
2024-07-01 14:06:59 +02:00
2023-12-17 20:25:53 +01:00
`false`
2026-06-01 19:47:26 +02:00
Specialized type
''''''''''''''''''
.. list-table ::
:widths: 15 25 20 15
:header-rows: 1
* - Value
- Comments
- Parameters
- Samples
2023-12-17 20:25:53 +01:00
* - secret
- a secret (like a password, a private key, etc.)
2026-06-01 19:47:26 +02:00
.. seealso :: tutorial with a real world sample :doc: `secret type variable <tutorial/redefine>`
- `min_len` : minimum characters length for the secret (unlimited by default)
`max_len` : maximum characters length for the secret (unlimited by default)
`forbidden_char` : forbidden characters (no character default)
2023-12-17 20:25:53 +01:00
- `hO_'hi`
2026-06-01 19:47:26 +02:00
2024-07-01 14:06:59 +02:00
* - mail
- a mail address
-
2023-12-17 20:25:53 +01:00
- test@rougail.example
2026-06-01 19:47:26 +02:00
2023-12-17 20:25:53 +01:00
* - unix_filename
- a file name in the Unix meaning
2026-06-01 19:47:26 +02:00
- `allow_relative` : this filename could be a relative path (`false` by default)
`test_existence` : this file must exist (`false` by default)
`types` : "file type allowed ("file", "directory")
2023-12-17 20:25:53 +01:00
- :file: `/etc/passwd`
2026-06-01 19:47:26 +02:00
2024-07-01 14:06:59 +02:00
* - date
2023-12-17 20:25:53 +01:00
- a date in the format `%Y-%m-%d`
2024-07-01 14:06:59 +02:00
-
2023-12-17 20:25:53 +01:00
- `2021-01-30`
2026-06-01 19:47:26 +02:00
2023-12-17 20:25:53 +01:00
* - unix_user
2024-07-01 14:06:59 +02:00
- a user in the Unix meaning
2026-06-01 19:47:26 +02:00
.. seealso :: tutorial with a real world sample :doc: `unix type variable <tutorial/redefine>`
2024-07-01 14:06:59 +02:00
-
2023-12-17 20:25:53 +01:00
- test
2026-06-01 19:47:26 +02:00
2023-12-17 20:25:53 +01:00
* - ip
- any kind of IPv4 address
- `private_only` : only private IPs (`false` by default)
`allow_reserved` : allows reserved IPs (`true` by default)
2026-06-01 19:47:26 +02:00
`cidr` : IP must be in CIDR format (`false` by default)
2023-12-17 20:25:53 +01:00
- `1.2.3.4`
2024-07-01 14:06:59 +02:00
2023-12-17 20:25:53 +01:00
* - netmask
- mask of an IPv4 address
2024-07-01 14:06:59 +02:00
-
2023-12-17 20:25:53 +01:00
- `255.255.255.0`
2026-06-01 19:47:26 +02:00
2023-12-17 20:25:53 +01:00
* - network
- network address
2026-06-01 19:47:26 +02:00
- `cidr` : network must be in CIDR format (`false` by default)
`private_only` : private network are allowed (`false` by default)
`allow_reserved` : reserved network are allowed (`false` by default)
2023-12-17 20:25:53 +01:00
- `192.168.1.0`
2026-06-01 19:47:26 +02:00
2023-12-17 20:25:53 +01:00
* - broadcast
- broadcast address
2024-07-01 14:06:59 +02:00
-
2026-06-01 19:47:26 +02:00
- `1.1.1.255`
2023-12-17 20:25:53 +01:00
* - domainname
2024-07-01 14:06:59 +02:00
- domain name
2026-06-01 19:47:26 +02:00
- `type` : type of domain name (`domainname` (by default), `netbios` , `hostname` )
`allow_ip` : the domain name can be an IP (`false` by default)
`allow_cidr_network` : the domain name can be network in CIDR format (`false` by default)
2024-07-01 14:06:59 +02:00
2026-06-01 19:47:26 +02:00
`allow_without_dot` : the domain name can be a hostname (`false` by default)
2024-07-01 14:06:59 +02:00
2026-06-01 19:47:26 +02:00
`allow_startswith_dot` : the domain name can starts by a dot (`false` by default)
2024-07-01 14:06:59 +02:00
2026-06-01 19:47:26 +02:00
`test_existence` : the domain name must exist (`false` by default)
.. seealso :: tutorial with a real world sample :doc: `domainname type variable <tutorial/types>` or :doc: `a more complet domainname type variable <tutorial/multiple>`
2023-12-17 20:25:53 +01:00
- `rougail.example`
2026-06-01 19:47:26 +02:00
2023-12-17 20:25:53 +01:00
* - web_address
- web address
2026-06-01 19:47:26 +02:00
- `type` : type of domain name (`domainname` (by default), `netbios` , `hostname` )
`allow_ip` : the domain name can be an IP (`false` by default)
`allow_cidr_network` : the domain name can be network in CIDR format (`false` by default)
`allow_without_dot` : the domain name can be a hostname (`false` by default)
`allow_startswith_dot` : the domain name can starts by a dot (`false` by default)
`test_existence` : the domain name must exist (`false` by default)
2026-06-02 12:03:38 +02:00
`allow_range` : can be range of port, for example 80:85 (`false` by default)
2026-06-01 19:47:26 +02:00
`allow_zero` : port 0 is allowed (false by default)
`allow_wellknown` : well-known ports (1 to 1023) are allowed (`true` by default)
2024-07-01 14:06:59 +02:00
2026-06-01 19:47:26 +02:00
`allow_registred` : registred ports (1024 to 49151) are allowed (`true` by default)
`allow_private` : private ports (greater than 49152) are allowed (`false` by default)
.. seealso :: tutorial with a real world sample :doc: `web_address type variable <tutorial/webaddress>`
2023-12-17 20:25:53 +01:00
- http://rougail.example
2026-06-01 19:47:26 +02:00
2024-07-01 14:06:59 +02:00
* - port
- port
2026-06-01 19:47:26 +02:00
- `allow_range` : can be range of port, for example 80:85 (`false` by default)
2023-12-17 20:25:53 +01:00
2026-06-01 19:47:26 +02:00
`allow_zero` : port 0 is allowed (false by default)
2023-12-17 20:25:53 +01:00
2026-06-01 19:47:26 +02:00
`allow_wellknown` : well-known ports (1 to 1023) are allowed (`true` by default)
2024-07-01 14:06:59 +02:00
2026-06-01 19:47:26 +02:00
`allow_registred` : registred ports (1024 to 49151) are allowed (`true` by default)
2024-07-01 14:06:59 +02:00
2026-06-01 19:47:26 +02:00
`allow_private` : private ports (greater than 49152) are allowed (`false` by default)
2024-07-01 14:06:59 +02:00
2026-06-01 19:47:26 +02:00
.. seealso :: tutorial with a real world sample :doc: `port type variable <tutorial/types>`
2023-12-17 20:25:53 +01:00
- 8080
2026-06-01 19:47:26 +02:00
2023-12-17 20:25:53 +01:00
* - mac
- MAC address
2024-07-01 14:06:59 +02:00
-
2023-12-17 20:25:53 +01:00
- 11:11:11:11:11:11
2026-06-01 19:47:26 +02:00
2023-12-17 20:25:53 +01:00
* - unix_permissions
- access rights to the file, directory, etc.
2024-07-01 14:06:59 +02:00
-
2023-12-17 20:25:53 +01:00
- 644
2026-06-01 19:47:26 +02:00
2024-07-01 14:06:59 +02:00
* - choice
2026-06-01 19:47:26 +02:00
- available choices
.. seealso :: tutorial with a real world sample :doc: `choice type variable <tutorial/choice>`
2024-07-01 14:06:59 +02:00
-
-
2026-06-01 19:47:26 +02:00
* - regexp
- Validation with a regular expressions
.. seealso :: tutorial with a real world sample :doc: `regexp type variable <tutorial/regexp>`
-
- r"^#(?:[0-9a-f]{3}){1,2}$"
Default type
''''''''''''''
If the `type` parameter is not set, Rougail has to define a logical type to valid correctly values:
- if `choices` or `regexp` parameter is set, Rougail will set the `choice` or `regexp` type
.. seealso :: tutorial with a real world sample :doc: `choice deducted type <tutorial/choice>` or :doc: `regexp deducted type <tutorial/regexp>`
- if a default value is define, Rougail will infers default value type and set a primitive type to the variable
.. seealso :: tutorial with a real world sample :doc: `type inference <tutorial/types>`
- if a variable calculation is define as default value, Rougail copy the type
.. seealso :: tutorial with a real world sample :doc: `type copying <tutorial/calculated>`
- the default type is `string`