The disabled property
Objectives
In this section we will learn:
what a property is (actually we already used one: the mandatory property
how to disable a family (yes, a family can disapear in the outerspace)
explain the
disabledproperty
We will see what is a disabled variable or family is, and why it is interesting to do that.
Reminder
We have three variables:
proxy_mode,addressandportplaced in thehttp_proxysubfamily.
A disabled property assigned to a family
- property
A property is a state (disabled, frozen, read_write, read_only, hidden …) of a family, a subfamily or a variable. These properties may vary depending on the context.
- disabled
The disabled property is a property of a variable or a family that is kind of deactivated for the whole configuration.
Let’s come back to our use case, we have a choice between five options in order to set the proxy mode:
The five choices are:
No proxy
Auto-detect proxy settings for this network
Use system proxy settings
Manual proxy configuration
Automatic proxy configuration URL
If the Manual proxy configuration is not selected, we don’t need to set
the address and port variables, there is no point
in setting them. It’s not just that: if we fill them in, there might be a problem in the overall integrity of the configuration. We shall fill and use in these variables
only in the Manual proxy configuration context. Otherwise, we need to disable them when they are not necessary.
Important
We need to have the ability to disable variables that are not used in a given context.
disabling the address and port variables
If we don’t choose the manual mode, we need to disable these variables. They are not used anymore.
Note that we’ve placed theses variables in the http_proxy
subfamily. We can then disable the whole http_proxy subfamily in order to
disable the variables that are placed in it.
Error
extinclude: URL not found (404): https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_027/firefox/10-manual.yml
We can see here the disabled: true parameter set in the manual family.
A conditional disabled family
Warning
In this section, we will intentionally create an inconsistency in the configuration
in order to explore the disabled property’s behavior.
We are going to
select the manual mode value for the
proxy_modeassing the
example.netvalue to theaddressvalidate in the user data file.
Error
extinclude: URL not found (404): https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_027/config/03/config.yaml
Warning
Remember that the manual family is disabled, so are the variables it contains.
Now let’s validate the consitency of the configuration:
rougail -v 1.1 -m firefox/ -u file -ff config/03/config.yaml
As expected, we encounter an error:
Question
How to avoid these error messages?
Contextual setting of a property
To avoid this type of error, what we need is a dynamic setting of the disable/enable property of the manual family.
The conditional disabled property
If the manual mode for the proxy is not selected, then the manual family shall be disabled.
On the other hand, if the manual proxy’s configuration mode is selected,
then we need to activate (enable) the manual family.
And we understand that this activation/deactivation of the manual family
depends on the value of the proxy_mode variable.
In rougail, we can set a property’s value depending on the value of another variable. That is, it is conditioned by another variable.
Here is how we can achieve this:
Error
extinclude: URL not found (404): https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_028/firefox/10-manual.yml
Explanation
Here we have the disabled property like this:
disabled:
type: variable
variable: proxy_mode
when_not: 'Manual proxy configuration'
Here the disabled property depends on the value of another variable.
The variable parameter allows you to define the name of the target variable on which the disabled property depends.
Key points progress
summary
We have the ability to build a contextual setting:
if
proxy_modeis not'Manual proxy configuration'it disables themanualfamilyif
proxy_mode == 'Manual proxy configuration'it enables themanualfamily
Keywords
the property concept
the
disabledpropertythe
variabletarget propertya disabled variable or family
raising a configuration’s consistency error
a variable based contextual disabled family
Progress
we have a family named
manualand a sub family namedhttp_proxyAnd we have now two variables:
proxy_modeandaddress.We have dynamically disabled the
manualfamily (and thehttp_proxysub family).