Import
Tasks can also be defined in external files and imported into the current runbook. The basic syntax is:
1 2 3 4 |
|
Inside the external file we can define any set of tasks:
1 2 3 4 5 6 |
|
The package will:
- load the main runbook file
- loop through the tasks and find
import
tasks - loads the
import
file and replace the definedimport
tasks with the content of the loaded file- this loop will continue until no
import
task is found. This means thatimport of import of import ...
is a valid scenario
- this loop will continue until no
- continue from here as usual
Warning
Once all external files are loaded the resulted runbook should have unique names of tasks!
Variables
Once all external files are loaded the defined variables will be replaced.
Since the external files can be templates and used in different runbooks we cant change the variables names to match the current runbook. For this reason when loading external files we can provide mapping of current runbook variables to external file variables.
Main runbook:
1 2 3 4 5 6 |
|
external-file.yaml
1 2 3 4 5 6 7 8 9 |
|
In the example above we a passing additional vars
property when loading external file. In this property we can define our mapping.
The example above will load external-file.yaml
and will:
- replace
blah
variable with the stringTEMP
- replace
blah1
variable with the stringTEMP 123
- replace
temp
variable with the content of thehost
variable from the main runbook.