Skip to content

Instantly share code, notes, and snippets.

@pcnoic
Created October 1, 2021 11:42
Show Gist options
  • Save pcnoic/a8ba9051a9521f70379d8c8dd2a99468 to your computer and use it in GitHub Desktop.
Save pcnoic/a8ba9051a9521f70379d8c8dd2a99468 to your computer and use it in GitHub Desktop.
Jinja variable interpolation in bash scripts (SaltStack context)
# maps.jinja
{%- set Home_path= "/suser/app/HC_CIFP/ci/nodel" %}
{%- set port = 8068 %}
# init.sls
test:
file.managed:
- name: /tmp/script
- source:
- salt://linux/test/script.sh
- template: jinja
- user: root
- group: root
- mode: 644
# script.sh
{% from "map.jinja" import Home_path, port with context -%}
#!/bin/bash
port="{{ port }}"
Home_path="{{ Home_path }}"
echo $port
echo $Home_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment