Salt: различия между версиями
Материал из noname.com.ua
Перейти к навигацииПерейти к поискуSirmax (обсуждение | вклад) (→Grains) |
Sirmax (обсуждение | вклад) |
||
Строка 35: | Строка 35: | ||
<PRE> |
<PRE> |
||
</PRE> |
</PRE> |
||
+ | |||
+ | |||
+ | |||
+ | |||
+ | =Jinja= |
||
+ | Check Variable in Jinja2 |
||
+ | |||
+ | Check if variable is defined (exists): |
||
+ | <PRE> |
||
+ | {% if variable is defined %} |
||
+ | variable is defined |
||
+ | {% else %} |
||
+ | variable is not defined |
||
+ | {% endif %} |
||
+ | </PRE> |
||
+ | |||
+ | |||
+ | Check if variable is empty: |
||
+ | <PRE> |
||
+ | {% if variable|length %} |
||
+ | variable is not empty |
||
+ | {% else %} |
||
+ | variable is empty |
||
+ | {% endif %} |
||
+ | </PRE> |
||
+ | |||
+ | Check if variable is true: |
||
+ | <PRE> |
||
+ | {% if variable is sameas true %} |
||
+ | variable is true |
||
+ | {% else %} |
||
+ | variable is not true |
||
+ | {% endif %} |
||
+ | </PRE> |
||
+ | Check if variable is defined and not empty: |
||
+ | <PRE> |
||
+ | {% if variable is defined and variable|length %} |
||
+ | variable is defined and not empty |
||
+ | {% else %} |
||
+ | variable is not defined or empty |
||
+ | {% endif %} |
||
+ | </PRE> |
||
+ | Check if variable is defined and true: |
||
+ | <PRE> |
||
+ | {% if variable is defined and variable is sameas true %} |
||
+ | variable is defined and true |
||
+ | {% else %} |
||
+ | variable is not defined or not set to true |
||
+ | {% endif %} |
||
+ | <PRE> |
Версия 15:21, 2 сентября 2021
Salt
Это просто напоминалка про команды Salt которые часть вылетают из головы
Pillar
salt 'minion' pillar.data
salt 'minion' pillar.get 'remote-log-filebeat-server'
salt 'minion' pillar.raw
salt 'minion' saltutil.refresh_pillar
Grains
salt 'minion' grains.get 'role'
Salt Apply
- filebeat - имя формулы
- saltenv=kilda-server42 pillrend=kilda-server42 - имя saltenv/pillarenv
salt 'minion' state.sls filebeat saltenv=kilda-server42 pillrend=kilda-server42 test=True
Jinja
Check Variable in Jinja2
Check if variable is defined (exists):
{% if variable is defined %} variable is defined {% else %} variable is not defined {% endif %}
Check if variable is empty:
{% if variable|length %} variable is not empty {% else %} variable is empty {% endif %}
Check if variable is true:
{% if variable is sameas true %} variable is true {% else %} variable is not true {% endif %}
Check if variable is defined and not empty:
{% if variable is defined and variable|length %} variable is defined and not empty {% else %} variable is not defined or empty {% endif %}
Check if variable is defined and true:
{% if variable is defined and variable is sameas true %} variable is defined and true {% else %} variable is not defined or not set to true {% endif %}