
特定の glob パターンに一致する最新バージョンを見つけるために、artifactory をクエリしようとしています。この出力を、後でモジュールで使用できる変数に設定したいと思います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 }}"