ansible/dns : switch to grafana alloy
This commit is contained in:
139
ansible/roles/grafana_alloy/tasks/main.yml
Normal file
139
ansible/roles/grafana_alloy/tasks/main.yml
Normal file
@@ -0,0 +1,139 @@
|
||||
---
|
||||
# ================================================================
|
||||
# Rôle : grafana_alloy
|
||||
# Tâches principales
|
||||
#
|
||||
# Objectif : Installer Grafana Alloy depuis le dépôt officiel
|
||||
# Grafana sur une distribution Debian/Ubuntu, puis
|
||||
# déployer la configuration et le service systemd.
|
||||
#
|
||||
# Étapes CLI équivalentes :
|
||||
# 1. sudo apt install gpg
|
||||
# 2. sudo mkdir -p /etc/apt/keyrings/
|
||||
# 3. wget -q -O - https://apt.grafana.com/gpg.key | \
|
||||
# gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg >/dev/null
|
||||
# 4. echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] \
|
||||
# https://apt.grafana.com stable main" \
|
||||
# | sudo tee /etc/apt/sources.list.d/grafana.list
|
||||
# 5. sudo apt-get update
|
||||
# 6. sudo apt-get install alloy
|
||||
# 7. sudo systemctl start alloy
|
||||
# 8. sudo systemctl enable alloy.service
|
||||
#
|
||||
# Cette implémentation reprend ces étapes en Ansible et ajoute
|
||||
# les déploiements de configuration + unité systemd.
|
||||
# ================================================================
|
||||
|
||||
- name: "[grafana_alloy] Paquets de base (gpg, wget, apt-transport-https, ca-certificates)"
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- gpg
|
||||
- wget
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
state: present
|
||||
update_cache: true
|
||||
tags:
|
||||
- grafana_alloy
|
||||
- install
|
||||
|
||||
- name: "[grafana_alloy] Création du répertoire /etc/apt/keyrings"
|
||||
ansible.builtin.file:
|
||||
path: /etc/apt/keyrings
|
||||
state: directory
|
||||
mode: "0755"
|
||||
tags:
|
||||
- grafana_alloy
|
||||
- repo
|
||||
|
||||
- name: "[grafana_alloy] Téléchargement de la clé GPG Grafana"
|
||||
ansible.builtin.get_url:
|
||||
url: https://apt.grafana.com/gpg.key
|
||||
dest: /tmp/grafana.gpg.key
|
||||
mode: "0644"
|
||||
notify: Convert GPG key
|
||||
tags:
|
||||
- grafana_alloy
|
||||
- repo
|
||||
|
||||
- name: "[grafana_alloy] Conversion de la clé GPG au format keyring"
|
||||
ansible.builtin.command:
|
||||
cmd: gpg --dearmor -o /etc/apt/keyrings/grafana.gpg /tmp/grafana.gpg.key
|
||||
creates: /etc/apt/keyrings/grafana.gpg
|
||||
tags:
|
||||
- grafana_alloy
|
||||
- repo
|
||||
|
||||
- name: "[grafana_alloy] Ajout du dépôt Grafana"
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main"
|
||||
filename: grafana
|
||||
state: present
|
||||
tags:
|
||||
- grafana_alloy
|
||||
- repo
|
||||
|
||||
- name: "[grafana_alloy] Installation du paquet alloy"
|
||||
ansible.builtin.apt:
|
||||
name: alloy
|
||||
state: present
|
||||
update_cache: true
|
||||
tags:
|
||||
- grafana_alloy
|
||||
- install
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Déploiement de la configuration d'Alloy (River)
|
||||
# ----------------------------------------------------------------
|
||||
- name: "[grafana_alloy] Dossier de configuration /etc/alloy"
|
||||
ansible.builtin.file:
|
||||
path: /etc/alloy
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
tags:
|
||||
- grafana_alloy
|
||||
- config
|
||||
|
||||
- name: "[grafana_alloy] Déploiement de la configuration Alloy"
|
||||
ansible.builtin.template:
|
||||
src: config.alloy.j2
|
||||
dest: "{{ alloy_config_file | default('/etc/alloy/config.alloy') }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify:
|
||||
- Restart alloy
|
||||
tags:
|
||||
- grafana_alloy
|
||||
- config
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Déploiement/override de l’unité systemd
|
||||
# ----------------------------------------------------------------
|
||||
- name: "[grafana_alloy] Déploiement du service systemd (override)"
|
||||
ansible.builtin.template:
|
||||
src: alloy.service.j2
|
||||
dest: /etc/systemd/system/alloy.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify:
|
||||
- Reload systemd
|
||||
- Restart alloy
|
||||
tags:
|
||||
- grafana_alloy
|
||||
- config
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Activation et démarrage du service
|
||||
# ----------------------------------------------------------------
|
||||
- name: "[grafana_alloy] Démarrage et activation du service alloy"
|
||||
ansible.builtin.service:
|
||||
name: alloy
|
||||
state: started
|
||||
enabled: true
|
||||
tags:
|
||||
- grafana_alloy
|
||||
- service
|
||||
Reference in New Issue
Block a user