initialize ansible role
This commit is contained in:
parent
f9adf283eb
commit
a64df1bba1
6 changed files with 43 additions and 2 deletions
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2023 win_ansible
|
Copyright (c) 2023 L3D <l3d@c3woc.de>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
# ansible_role_win_exporter
|
# ansible_role_win_exporter
|
||||||
|
|
||||||
Ansible role to install a prometheus exporter on windows
|
Ansible role to install a prometheus exporter on windows
|
||||||
|
https://github.com/prometheus-community/windows_exporter/releases
|
||||||
|
|
2
defaults/main.yml
Normal file
2
defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
win_exporter__version: 'latest'
|
33
tasks/get_exporter_version.yml
Normal file
33
tasks/get_exporter_version.yml
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
---
|
||||||
|
- name: "Determine 'latest' version release"
|
||||||
|
when: win_exporter__version == "latest"
|
||||||
|
block:
|
||||||
|
- name: "Get latest windows_exporter release metadata"
|
||||||
|
ansible.builtin.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: "{{ win_exporter__version_target }}"
|
3
tasks/main.yml
Normal file
3
tasks/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
- name: Get latest windows_exporter version
|
||||||
|
ansible.builtin.include_tasks: get_exporter_version.yml
|
2
vars/main.yml
Normal file
2
vars/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
win_exporter__repo_api: 'https://api.github.com/repos/prometheus-community/windows_exporter/releases/latest'
|
Loading…
Reference in a new issue