
為什麼我使用 saltstack apache-formula 無法設定“id”變數?我的代碼是休閒的嗎?
apache:
sites:
changed.com:
template_file: salt://salt/formulas/salt/apache-formula/apache/vhosts/standard.tmpl
template_engine: jinja
interface: '*'
port: '80'
ServerName: {{ id }}
ServerAdmin: webmaster@{{ id }}
LogLevel: Debug
ErrorLog: {{ logdir }}/{{ id }}-error.log
WSGIScriptAlias: / /var/www/project2/django.wsgi
錯誤訊息如下:
Rendering SLS "base:netchosis" failed: Jinja variable 'id' is undefined; line 15
port: '80'
ServerName: {{ id }}
ServerAdmin: webmaster@{{ id }}
LogLevel: Debug
ErrorLog: {{ logdir }}/{{ id }}-error.log <======================
WSGIScriptAlias: / /var/www/project2/django.wsgi
我期待“changed.com”作為 ID,謝謝。
答案1
範例支柱檔案在這裡:https://github.com/saltstack-formulas/apache-formula/blob/master/pillar.example
我建議每個縮排等級使用 2 個空格並確保它們對齊。