在 Ansible 的 get_uri 模块中注册此网页后设置事实或调试网页时出错
error while setting a fact or debug a webpage after registering this webpage in the get_uri module in Ansible
我在为已注册的网页设置事实时每次都遇到问题,错误是:
u'redirected': False}]}: 模板化字符串时出现模板错误:意外字符 u'&' at 1238
剧本如:
- name: check webpage
uri:
url: http://{{ item.host }}.x.x.x
validate_certs: False
return_content: yes
status_code: 200
register: webpage3
with_items: "{{ servers }}"
when:
- lb is defined
- lb == "true"
- name: debug webpage
set_fact:
fact: "{{ webpage3 }}"
when:
- lb is defined
ignore_errors: yes
我的ansible版本是ansible 2.2.1.0
那么,我的网页本身有问题吗?有没有解决方案可以跳过这个错误?
在排除故障后,我发现它失败是因为一行以
开头
<!-->
那么如何跳过这个字符的这一行?
谢谢大家,我已经解决了这个问题,方法是将 uri 模块中的 dest 提供给一个文件,然后使用 sed 删除不需要的字符,然后将输出注册为 set_fact 的新值,最后 greping使用 grep 命令获取所需的值。因为很难跳过输出中的那些字符
我在为已注册的网页设置事实时每次都遇到问题,错误是:
u'redirected': False}]}: 模板化字符串时出现模板错误:意外字符 u'&' at 1238
剧本如:
- name: check webpage
uri:
url: http://{{ item.host }}.x.x.x
validate_certs: False
return_content: yes
status_code: 200
register: webpage3
with_items: "{{ servers }}"
when:
- lb is defined
- lb == "true"
- name: debug webpage
set_fact:
fact: "{{ webpage3 }}"
when:
- lb is defined
ignore_errors: yes
我的ansible版本是ansible 2.2.1.0
那么,我的网页本身有问题吗?有没有解决方案可以跳过这个错误?
在排除故障后,我发现它失败是因为一行以
开头 <!-->
那么如何跳过这个字符的这一行?
谢谢大家,我已经解决了这个问题,方法是将 uri 模块中的 dest 提供给一个文件,然后使用 sed 删除不需要的字符,然后将输出注册为 set_fact 的新值,最后 greping使用 grep 命令获取所需的值。因为很难跳过输出中的那些字符