
我正在嘗試查詢神器以查找與給定全域模式相符的最新版本。我想將其輸出設為一個變量,以便稍後在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
所以現在我只需要進入{{ app_dir }}/version
一個變數。
答案1
您也可以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'] }}"
答案2
好的,我知道了。使用命令模組我能夠使cat
該文件能夠讀取下載文件的內容。
- 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"
- name: Read App Version
command: cat {{ app_dir }}/version
register: app_version
- debug:
msg: "App Version {{ app_version.stdout }}"