gem 'kitchen-docker' | gem 'kitchen-docker' | ||||
gem 'kitchen-inspec' | gem 'kitchen-inspec' | ||||
gem 'inspec' | gem 'inspec' | ||||
gem 'kitchen-salt', :git => 'https://github.com/salt-formulas/kitchen-salt.git' | |||||
gem 'kitchen-salt' #, :git => 'https://github.com/salt-formulas/kitchen-salt.git' | |||||
- bundle install | - bundle install | ||||
env: | env: |
salt-call event.send 'salt/key/remove' | salt-call event.send 'salt/key/remove' | ||||
Encrypted Pillars | |||||
Jinja options | |||||
------------- | |||||
Use following options to update default jinja renderer options. Salt recognize Jinja options for templates and for sls files. | |||||
For full list of options check jinja documentation: http://jinja.pocoo.org/docs/api/#high-level-api. | |||||
.. code-block:: yaml | |||||
salt: | |||||
renderer: | |||||
# for templates | |||||
jinja: &jina_env | |||||
# Default Jinja environment options | |||||
block_start_string: '{%' | |||||
block_end_string: '%}' | |||||
variable_start_string: '{{' | |||||
variable_end_string: '}}' | |||||
comment_start_string: '{#' | |||||
comment_end_string: '#}' | |||||
keep_trailing_newline: False | |||||
newline_sequence: '\n' | |||||
# Next two are enabled by default in Salt | |||||
trim_blocks: True | |||||
lstrip_blocks: True | |||||
# Next two are not enabled by default in Salt | |||||
# but worth to consider to enable in future for salt-formulas | |||||
line_statement_prefix: '%' | |||||
line_comment_prefix: '##' | |||||
# for .sls state files | |||||
jinja_sls: *jinja_env | |||||
With the line_statement/comment* _prefix options enabled following code statements are valid: | |||||
.. code-block:: yaml | |||||
%- set myvar = 'one' | |||||
## You can mix even with '{%' | |||||
{%- set myvar = 'two' %} ## comment | |||||
%- set mylist = ['one', 'two', 'three'] ## comment | |||||
## comment | |||||
%- for item in mylist: ## comment | |||||
{{- item }} | |||||
%- endfor | |||||
Encrypted pillars | |||||
~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~~ | ||||
Note: NACL + below configuration will be available in Salt > 2017.7. | Note: NACL + below configuration will be available in Salt > 2017.7. |
{%- from "salt/map.jinja" import renderer with context %} | |||||
{%- if renderer.get('jinja_sls', {}) | length > 0 %} | |||||
jinja_sls_env: | |||||
{% for key, value in renderer.jinja_sls.iteritems() %} | |||||
{{ key }}: "{{ value }}" | |||||
{%- endfor %} | |||||
{%- endif %} | |||||
{%- if renderer.get('jinja', {}) | length > 0 %} | |||||
jinja_env: | |||||
{% for key, value in renderer.jinja.iteritems() %} | |||||
{{ key }}: "{{ value }}" | |||||
{%- endfor %} | |||||
{%- endif %} | |||||
{#- | |||||
vim: syntax=jinja | |||||
-#} |
- pkg-config | - pkg-config | ||||
{%- endload %} | {%- endload %} | ||||
{%- load_yaml as renderer_defaults %} | |||||
default: | |||||
renderer: {} | |||||
{%- endload %} | |||||
{%- set renderer = salt['grains.filter_by'](renderer_defaults, merge=salt['pillar.get']('salt:renderer')) %} | |||||
{%- if pillar.salt.control is defined %} | {%- if pillar.salt.control is defined %} | ||||
{%- set raw_control = salt['grains.filter_by'](control_specific, merge=salt['pillar.get']('salt:control')) %} | {%- set raw_control = salt['grains.filter_by'](control_specific, merge=salt['pillar.get']('salt:control')) %} | ||||
{%- set control = salt['grains.filter_by'](control_common, merge=raw_control) %} | {%- set control = salt['grains.filter_by'](control_common, merge=raw_control) %} |
{%- from "salt/map.jinja" import master with context %} | |||||
{%- from "salt/map.jinja" import master, renderer with context %} | |||||
{%- if master.enabled %} | {%- if master.enabled %} | ||||
{%- if master.source.get('engine', 'pkg') == 'pkg' %} | {%- if master.source.get('engine', 'pkg') == 'pkg' %} | ||||
{%- endif %} | {%- endif %} | ||||
{%- if renderer | length > 0 %} | |||||
/etc/salt/master.d/_renderer.conf: | |||||
file.managed: | |||||
- source: salt://salt/files/_renderer.conf | |||||
- user: root | |||||
- template: jinja | |||||
- require: | |||||
- {{ master.install_state }} | |||||
- watch_in: | |||||
- service: salt_master_service | |||||
{%- endif %} | |||||
salt_master_service: | salt_master_service: | ||||
service.running: | service.running: | ||||
- name: {{ master.service }} | - name: {{ master.service }} |
{%- from "salt/map.jinja" import minion with context %} | |||||
{%- from "salt/map.jinja" import minion,renderer with context %} | |||||
{%- if minion.enabled %} | {%- if minion.enabled %} | ||||
{%- if minion.source.get('engine', 'pkg') == 'pkg' %} | {%- if minion.source.get('engine', 'pkg') == 'pkg' %} | ||||
{%- endif %} | {%- endif %} | ||||
{%- endfor %} | {%- endfor %} | ||||
{%- if renderer | length > 0 %} | |||||
/etc/salt/minion.d/_renderer.conf: | |||||
file.managed: | |||||
- source: salt://salt/files/_renderer.conf | |||||
- user: root | |||||
- template: jinja | |||||
- require: | |||||
- {{ minion.install_state }} | |||||
- watch_in: | |||||
- service: salt_minion_service | |||||
{%- endif %} | |||||
salt_minion_service: | salt_minion_service: | ||||
service.running: | service.running: | ||||
- name: {{ minion.service }} | - name: {{ minion.service }} |
source: git | source: git | ||||
address: 'https://github.com/salt-formulas/salt-formula-bind.git' | address: 'https://github.com/salt-formulas/salt-formula-bind.git' | ||||
revision: master | revision: master | ||||
renderer: | |||||
jinja: | |||||
block_start_string: {{ '"{%"' }} | |||||
block_end_string: {{ '"%}"' }} | |||||
variable_start_string: {{ '"{{"' }} | |||||
variable_end_string: {{ '"}}"' }} | |||||
comment_start_string: {{ '"{#"' }} | |||||
comment_end_string: {{ '"#}"' }} | |||||
keep_trailing_newline: False | |||||
newline_sequence: '\n' | |||||
trim_blocks: True | |||||
lstrip_blocks: True | |||||
line_statement_prefix: "%" | |||||
line_comment_prefix: "##" | |||||
jinja_sls: | |||||
block_start_string: {{ '"{%"' }} | |||||
block_end_string: {{ '"%}"' }} | |||||
variable_start_string: {{ '"{{"' }} | |||||
variable_end_string: {{ '"}}"' }} | |||||
comment_start_string: {{ '"{#"' }} | |||||
comment_end_string: {{ '"#}"' }} | |||||
keep_trailing_newline: False | |||||
newline_sequence: '\n' | |||||
trim_blocks: True | |||||
lstrip_blocks: True | |||||
line_statement_prefix: "%" | |||||
line_comment_prefix: "##" |