在 salt 中使用 dns_check (其中文档似乎有误)
Using dns_check in salt (wherein the documention seems wrong)
saltstack docs 注意 dns_check
jinja 过滤器在 2017.7.3 中的存在:
{{ 'www.google.com' | dns_check }}
哪个应该 return 一个字符串形式的 ip4v 地址。
但是当我尝试的时候:
test_this_one:
cmd.run:
- name: |
echo {{ 'www.google.com' | dns_check }}
我反而看到了
local:
Data failed to compile:
----------
Rendering SLS 'base:firewall' failed: Jinja error: dns_check() takes at least 2 arguments (1 given)
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 418, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "<template>", line 42, in top-level template code
TypeError: dns_check() takes at least 2 arguments (1 given)
我错过了什么吗?我倾向于相信我犯了一个错误,而不是文档是公开错误的。
查看源代码,看起来 dns_check
现在需要一个 port
参数 - 文档字符串说:
Tries to connect to the address before considering it useful. If no address can be reached, the first one resolved is used as a fallback.
所以在这里放置任何端口可能就足够了,它应该可以工作。 (也许应该提出一个关于使端口可选的问题?)
saltstack docs 注意 dns_check
jinja 过滤器在 2017.7.3 中的存在:
{{ 'www.google.com' | dns_check }}
哪个应该 return 一个字符串形式的 ip4v 地址。
但是当我尝试的时候:
test_this_one:
cmd.run:
- name: |
echo {{ 'www.google.com' | dns_check }}
我反而看到了
local:
Data failed to compile:
----------
Rendering SLS 'base:firewall' failed: Jinja error: dns_check() takes at least 2 arguments (1 given)
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 418, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "<template>", line 42, in top-level template code
TypeError: dns_check() takes at least 2 arguments (1 given)
我错过了什么吗?我倾向于相信我犯了一个错误,而不是文档是公开错误的。
查看源代码,看起来 dns_check
现在需要一个 port
参数 - 文档字符串说:
Tries to connect to the address before considering it useful. If no address can be reached, the first one resolved is used as a fallback.
所以在这里放置任何端口可能就足够了,它应该可以工作。 (也许应该提出一个关于使端口可选的问题?)