我收到以下saltstack
YAML错误:
Rendering SLS 'openstack:openstack.horizon.CentOS' failed: could not found expected ':'; line 63
horizon_https:
file.prepend:
- text: |-
<VirtualHost *:80>
ServerName openstack.example.com <======================
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>
对于YAML的以下位:
horizon_https:
file.prepend:
- text: |-
<VirtualHost *:80>
ServerName openstack.example.com
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>
<IfModule !mod_rewrite.c>
RedirectPermanent / https://openstack.example.com
</IfModule>
</VirtualHost>
<VirtualHost *:443>
ServerName openstack.example.com
SSLEngine On
# Remember to replace certificates and keys with valid paths in your environment
SSLCertificateFile /etc/apache2/SSL/openstack.example.com.crt
SSLCACertificateFile /etc/apache2/SSL/openstack.example.com.crt
SSLCertificateKeyFile /etc/apache2/SSL/openstack.example.com.key
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
# HTTP Strict Transport Security (HSTS) enforces that all communications
# with a server go over SSL. This mitigates the threat from attacks such
# as SSL-Strip which replaces links on the wire, stripping away https prefixes
# and potentially allowing an attacker to view confidential information on the
# wire
Header add Strict-Transport-Security "max-age=15768000"
知道问题是什么吗?
答案 0 :(得分:2)
text
是映射键,字符串<VirtualHost *:80>\nServername ...
是其值。该值不能缩进到与键相同的级别。
所以你必须这样做:
horizon_https:
file.prepend:
- text: |-
<VirtualHost *:80>
ServerName openstack.example.com
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>
错误消息抱怨无法找到的冒号是缺少&#34; :
&#34;在指示之前的线上。因为它在text
映射键的相同级别缩进,所以它期望它包含一个键,后跟冒号+空格。
(这并没有解决无法找到错误信息的不合语法,但至少应该摆脱它)