
주어진 glob 패턴과 일치하는 최신 버전을 찾기 위해 아티팩트를 쿼리하려고 합니다. 이 출력을 나중에 모듈에서 사용할 수 있는 변수로 설정하고 싶습니다 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 }}"