ansible_role_win_exporter/tasks/get_exporter_version.yml

34 lines
1.3 KiB
YAML

---
- name: "Determine 'latest' version release"
when: win_exporter__version == "latest"
block:
- name: "Get latest windows_exporter release metadata"
ansible.windows.win_uri:
url: "{{ win_exporter__repo_api }}"
return_content: true
register: win_exporter__remote_metadata
become: false
when: not ansible_check_mode
- name: "Fail if running in check mode without versions set."
ansible.builtin.fail:
msg: |
"You are running this playbook in check mode:
Please set the desired version with the variable 'win_exporter__version',
because the URI module cannot detect the latest version in this mode."
when: ansible_check_mode and (win_exporter__version == 'latest')
- name: "Set fact latest windows_exporter release"
ansible.builtin.set_fact:
win_exporter__version_target: "{{ win_exporter__remote_metadata.json.tag_name[1:] }}"
when: not ansible_check_mode
- name: "Set windows_exporter version target {{ win_exporter__version }}"
ansible.builtin.set_fact:
win_exporter__version_target: "{{ win_exporter__version }}"
when: win_exporter__version != "latest"
- name: "Generate windows_exporter download URL"
ansible.builtin.debug:
msg: "Install Version {{ win_exporter__version_target }}"
verbosity: 1