无法从具有较旧 ansible 版本和 python 2.x 的 rhel 机器访问 json



我正在使用 uri 模块对 api 执行相同的请求/任务。 当我在 python 3.7.1 和 ansible 2.8.1 上的 mac 上执行时,它可以工作。 当我从带有python 2.7.5和ansible 2.4.2.0的红帽Linux机器执行时,它不起作用,并且出现错误'dict object' has no attribute 'json'

以下是使用虚拟值的任务:

- name: get request
uri:
url: https://url.com{{ foo }}
method: GET
user:  user
validate_certs: False
password: password
return_content: yes
body_format: json
register: page_contents
until: page_contents.json.{{ foo }}[0].status == "deployed"
retries: 30
delay: 5

我将 ansible 和 python 版本都更新为最新版本,现在它工作正常。

最新更新