Created
October 1, 2021 11:42
-
-
Save pcnoic/a8ba9051a9521f70379d8c8dd2a99468 to your computer and use it in GitHub Desktop.
Jinja variable interpolation in bash scripts (SaltStack context)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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