ansible-collection-prometheus/roles/chrony_exporter/molecule/alternative/prepare.yml
SuperQ 2f1e8a4be8
feat: Add chrony_exporter role
Add role for deploying the chrony_exporter.

Signed-off-by: SuperQ <superq@gmail.com>
2023-07-23 23:18:40 +02:00

56 lines
1.8 KiB
YAML

---
- name: Prepare
hosts: localhost
gather_facts: false
vars:
go_arch: amd64
chrony_exporter_version: 0.6.0
tasks:
- name: Download chrony_exporter binary to local folder
become: false
ansible.builtin.get_url:
url: "https://github.com/superq/chrony_exporter/releases/download/v{{ chrony_exporter_version }}/\
chrony_exporter-{{ chrony_exporter_version }}.linux-{{ go_arch }}.tar.gz"
dest: "/tmp/chrony_exporter-{{ chrony_exporter_version }}.linux-{{ go_arch }}.tar.gz"
mode: 0644
register: _download_binary
until: _download_binary is succeeded
retries: 5
delay: 2
check_mode: false
- name: Unpack chrony_exporter binary
become: false
ansible.builtin.unarchive:
src: "/tmp/chrony_exporter-{{ chrony_exporter_version }}.linux-{{ go_arch }}.tar.gz"
dest: "/tmp"
creates: "/tmp/chrony_exporter-{{ chrony_exporter_version }}.linux-{{ go_arch }}/chrony_exporter"
check_mode: false
- name: Link to chrony_exporter binaries directory
become: false
ansible.builtin.file:
src: "/tmp/chrony_exporter-{{ chrony_exporter_version }}.linux-amd64"
dest: "/tmp/chrony_exporter-linux-amd64"
state: link
check_mode: false
- name: Install pyOpenSSL for certificate generation
ansible.builtin.pip:
name: "pyOpenSSL"
- name: Create private key
community.crypto.openssl_privatekey:
path: "/tmp/tls.key"
- name: Create CSR
community.crypto.openssl_csr:
path: "/tmp/tls.csr"
privatekey_path: "/tmp/tls.key"
- name: Create certificate
community.crypto.x509_certificate:
path: "/tmp/tls.cert"
csr_path: "/tmp/tls.csr"
privatekey_path: "/tmp/tls.key"
provider: selfsigned