|
|
Functions are called with the following syntax:
|
|
|
```
|
|
|
{% <function> <arguments> %}
|
|
|
```
|
|
|
|
|
|
## assign
|
|
|
|
|
|
Concatenates any combination of (space separated) variables and strings and assigns it to a new variable.
|
|
|
|
|
|
### Usage
|
|
|
```
|
|
|
{% assign <varname> = <str|var> [[str|var] [str|var] [..]]
|
|
|
```
|
|
|
|
|
|
### Examples
|
|
|
```
|
|
|
{% assign newvar = <space seperated list of strings/vars> %}
|
|
|
```
|
|
|
|
|
|
```
|
|
|
{% assign myabbreviation = 'bla' %}
|
|
|
```
|
|
|
|
|
|
```
|
|
|
{% assign file_name = '/var/tmp/rack-' rack.label '.txt' %}
|
|
|
```
|
|
|
|
|
|
```
|
|
|
{% assign elite = 'foo' host.label 'bar' %}
|
|
|
```
|
|
|
|
|
|
## getbasenets
|
|
|
|
|
|
Get list of basenets in a network (name).
|
|
|
|
|
|
### Usage
|
|
|
```
|
|
|
{% getbasenets <network name> as <listname> %}
|
|
|
```
|
|
|
|
|
|
### Examples
|
|
|
|
|
|
Let's assume "MY ADMIN" network is: 192.168.10.0/23
|
|
|
```
|
|
|
{% getbasenets 'MY ADMIN' as network_basenets %}
|
|
|
|
|
|
{% for bnet in network_basenets %}
|
|
|
{{ bnet }}
|
|
|
{% endfor %}
|
|
|
```
|
|
|
|
|
|
### Example output
|
|
|
|
|
|
```
|
|
|
192.168.10
|
|
|
192.168.11
|
|
|
```
|
|
|
|
|
|
## getracks
|
|
|
|
|
|
Get list of all racks in a cluster.
|
|
|
|
|
|
### Usage
|
|
|
```
|
|
|
{% getracks <cluster> as <listname> %}
|
|
|
```
|
|
|
|
|
|
### Examples
|
|
|
|
|
|
Let's assume the cluster with name "TINA" consists of 3 racks with the labels: r1, r5, r6
|
|
|
```
|
|
|
{% getracks 'TINA' as tina_racks %}
|
|
|
|
|
|
{% for r in tina_racks %}
|
|
|
{{ r.label }}
|
|
|
{% endfor %}
|
|
|
```
|
|
|
|
|
|
### Example output
|
|
|
```
|
|
|
r1
|
|
|
r5
|
|
|
r6
|
|
|
```
|
|
|
|
|
|
## read
|
|
|
Compilation function to define Querysets for later use.
|
|
|
|
|
|
### Usage
|
|
|
```
|
|
|
{% read <entity> --get <attribute>=<value> as <variable> %}
|
|
|
```
|
|
|
|
|
|
'''Examples'''
|
|
|
{{{
|
|
|
{% read equipment --get cluster__name=Gina as gina_hosts %}
|
|
|
}}}
|
|
|
|
|
|
{{{
|
|
|
{% read network --get name__contains="gina" as gina_networks %}
|
|
|
}}}
|
|
|
|
|
|
{{{
|
|
|
{% read network --get name="gina admin" as net_gina_admin %}
|
|
|
}}}
|
|
|
|
|
|
{{{
|
|
|
{% read interface --get network__name="gina admin" as ifaces_gina_admin %}
|
|
|
}}} |