initialize ansible role

This commit is contained in:
L3D 2023-10-26 17:26:46 +02:00
parent f9adf283eb
commit a64df1bba1
Signed by: l3d
GPG key ID: CD08445BFF4313D1
6 changed files with 43 additions and 2 deletions

View file

@ -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:

View file

@ -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
View file

@ -0,0 +1,2 @@
---
win_exporter__version: 'latest'

View 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
View 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
View file

@ -0,0 +1,2 @@
---
win_exporter__repo_api: 'https://api.github.com/repos/prometheus-community/windows_exporter/releases/latest'