mirror of
https://github.com/roles-ansible/ansible_role_prometheus_ping_exporter.git
synced 2024-08-16 10:19:51 +02:00
Set version
This commit is contained in:
parent
2eec966811
commit
c71c6fb17d
5 changed files with 51 additions and 1 deletions
|
@ -1,10 +1,12 @@
|
|||
---
|
||||
# Unix vars
|
||||
ping_exporter__user: 'ping_exporter'
|
||||
ping_exporter__grpup: 'ping_exporter'
|
||||
ping_exporter__group: 'ping_exporter'
|
||||
ping_exporter__user_home: '/var/lib/ping_exporter'
|
||||
ping_exporter__shell: '/bin/false'
|
||||
|
||||
# Version
|
||||
ping_exporter__version: 'latest'
|
||||
|
||||
# should we do a version check? (recomended)
|
||||
submodules_versioncheck: false
|
||||
|
|
4
handlers/main.yml
Normal file
4
handlers/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
- name: Systemctl restart ping_exporter.service
|
||||
ansible.builtin.debug:
|
||||
msg: "in progress..."
|
|
@ -5,3 +5,6 @@
|
|||
|
||||
- name: Create User for ping exporter
|
||||
ansible.builtin.include_tasks: create_user.yml
|
||||
|
||||
- name: Get latest release and define version
|
||||
ansible.builtin.include_tasks: set_version.yml
|
||||
|
|
38
tasks/set_version.yml
Normal file
38
tasks/set_version.yml
Normal file
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
- name: "Determine 'latest' version release"
|
||||
when: ping_exporter__version == "latest"
|
||||
block:
|
||||
- name: "Get latest ping_exporter release metadata"
|
||||
ansible.builtin.uri:
|
||||
url: "{{ ping_exporter__repo_api }}"
|
||||
return_content: true
|
||||
register: ping_exporter_remote_metadata
|
||||
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 Ping Exporter version with the variable 'ping_exporter__version', because the
|
||||
URI module cannot detect the latest version in this mode."
|
||||
when: ansible_check_mode and (ping_exporter__version == 'latest' or ping_exporter__version == 'present')
|
||||
|
||||
- name: "Set fact latest ping_exporter release"
|
||||
ansible.builtin.set_fact:
|
||||
ping_exporter_remote_version: "{{ ping_exporter_remote_metadata.json.tag_name }}"
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: "Set ping_exporter version target (latest)"
|
||||
ansible.builtin.set_fact:
|
||||
ping_exporter_version_target: "{{ ping_exporter_remote_version }}"
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: "Set ping_exporter version target {{ ping_exporter__version }}"
|
||||
ansible.builtin.set_fact:
|
||||
ping_exporter_version_target: "{{ ping_exporter__version }}"
|
||||
when: ping_exporter__version != "latest"
|
||||
|
||||
- name: Print Ping Exporter Version
|
||||
ansible.builtin.debug:
|
||||
verbosity: 1
|
||||
msg: "Set Ping Exporter Version to {{ ping_exporter_version_target }}"
|
|
@ -1,4 +1,7 @@
|
|||
---
|
||||
ping_exporter__repo: 'https://github.com/czerwonk/ping_exporter.git'
|
||||
ping_exporter__repo_api: 'https://api.github.com/repos/czerwonk/ping_exporter/releases/latest'
|
||||
|
||||
# versionscheck
|
||||
playbook_version_number: 02 # should be a integer
|
||||
playbook_version_path: 'do1jlr.prometheus_ping_exporter.version'
|
||||
|
|
Loading…
Reference in a new issue