mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-26 13:50:20 +00:00
51 lines
1.6 KiB
YAML
51 lines
1.6 KiB
YAML
|
---
|
||
|
- name: Assert usage of systemd as an init system
|
||
|
ansible.builtin.assert:
|
||
|
that: ansible_service_mgr == 'systemd'
|
||
|
msg: "This role only works with systemd"
|
||
|
|
||
|
- name: Install package fact dependencies
|
||
|
become: true
|
||
|
ansible.builtin.package:
|
||
|
name: "{{ _pkg_fact_req }}"
|
||
|
state: present
|
||
|
when: (_pkg_fact_req)
|
||
|
vars:
|
||
|
_pkg_fact_req: "{% if (ansible_pkg_mgr == 'apt') %}\
|
||
|
{{ ('python-apt' if ansible_python_version is version('3', '<') else 'python3-apt') }}
|
||
|
{% else %}\
|
||
|
{% endif %}"
|
||
|
|
||
|
- name: Gather package facts
|
||
|
ansible.builtin.package_facts:
|
||
|
when: "not 'packages' in ansible_facts"
|
||
|
|
||
|
- name: Check if cadvisor is installed
|
||
|
ansible.builtin.stat:
|
||
|
path: "{{ cadvisor_binary_install_dir }}/cadvisor"
|
||
|
register: __cadvisor_is_installed
|
||
|
check_mode: false
|
||
|
tags:
|
||
|
- cadvisor_install
|
||
|
|
||
|
- name: Gather currently installed cadvisor version (if any)
|
||
|
ansible.builtin.command: "{{ cadvisor_binary_install_dir }}/cadvisor --version"
|
||
|
changed_when: false
|
||
|
register: __cadvisor_current_version_output
|
||
|
check_mode: false
|
||
|
when: __cadvisor_is_installed.stat.exists
|
||
|
tags:
|
||
|
- cadvisor_install
|
||
|
|
||
|
- name: Discover latest version
|
||
|
ansible.builtin.set_fact:
|
||
|
cadvisor_version: "{{ (lookup('url', 'https://api.github.com/repos/{{ _cadvisor_repo }}/releases/latest', headers=_github_api_headers,
|
||
|
split_lines=False) | from_json).get('tag_name') | replace('v', '') }}"
|
||
|
run_once: true
|
||
|
until: cadvisor_version is version('0.0.0', '>=')
|
||
|
retries: 10
|
||
|
when:
|
||
|
- cadvisor_version == "latest"
|
||
|
- cadvisor_binary_local_dir | length == 0
|
||
|
- not cadvisor_skip_install
|