如何将变量的内容设置为 HTTP 调用的结果?

Bre*_*yan 3 ansible ansible-playbook

我正在尝试查询神器以查找与给定全局模式匹配的最新版本。我想将其输出设置为一个变量,以便稍后在maven_artifact模块中使用。我正在考虑查找,但这是在控制器机器上执行的。

使用get_url我有以下内容:

- name: Get App Version
  get_url:
    url: "{{ artifactory_search }}?g=com.test.app&a=my-app&v=*qa*&repos=libs-release-local"
    dest: "{{ app_dir }}/version"
  tags:
  - testing
Run Code Online (Sandbox Code Playgroud)

所以现在我只需要进入{{ app_dir }}/version一个变量。

小智 5

uri您还可以像这样使用该模块:

- name: Fetch instance metadata
  uri:
    url: http://169.254.169.254/path/to/ip_address
    return_content: yes
  register: jsondata

- debug: msg="Operating on instance {{ jsondata['content'] }}"
Run Code Online (Sandbox Code Playgroud)