fixes: ghost image upgrades and smartctl exporter

This commit is contained in:
2026-07-27 12:51:28 -04:00
parent b3fdf181a1
commit 386e165f6b
6 changed files with 116 additions and 7 deletions
+13
View File
@@ -63,6 +63,19 @@ def extract_ver(content):
def strip_volatile_fields(content): def strip_volatile_fields(content):
content = re.sub(r'^pkgver=.*$', '', content, flags=re.MULTILINE) content = re.sub(r'^pkgver=.*$', '', content, flags=re.MULTILINE)
content = re.sub(r'^pkgrel=.*$', '', content, flags=re.MULTILINE) content = re.sub(r'^pkgrel=.*$', '', content, flags=re.MULTILINE)
source_vars = set()
source_matches = re.finditer(r'^source(?:_[a-zA-Z0-9_]+)?=\((.*?)\)', content, flags=re.MULTILINE | re.DOTALL)
for match in source_matches:
source_content = match.group(1)
vars_in_source = re.findall(r'\$(?:\{(_[a-zA-Z0-9_]+)\}|(_[a-zA-Z0-9_]+))', source_content)
for v1, v2 in vars_in_source:
if v1: source_vars.add(v1)
if v2: source_vars.add(v2)
for var in source_vars:
content = re.sub(r'^' + re.escape(var) + r'=.*$', '', content, flags=re.MULTILINE)
sum_patterns = [ sum_patterns = [
r'md5sums', r'sha1sums', r'sha224sums', r'sha256sums', r'md5sums', r'sha1sums', r'sha224sums', r'sha256sums',
r'sha384sums', r'sha512sums', r'b2sums', r'cksums' r'sha384sums', r'sha512sums', r'b2sums', r'cksums'
+19 -3
View File
@@ -1,10 +1,26 @@
--- ---
- name: Pull latest images and update Docker Compose stacks - name: Pre-build images to ensure base images are pulled
become: true
ansible.builtin.command:
cmd: docker compose build --pull
chdir: "{{ item }}"
loop: "{{ docker_compose_dirs | default([]) }}"
changed_when: false
register: _build_result
- name: Pull latest non-buildable service images
become: true
ansible.builtin.command:
cmd: docker compose pull --ignore-buildable
chdir: "{{ item }}"
loop: "{{ docker_compose_dirs | default([]) }}"
changed_when: false
- name: Update Docker Compose stacks
become: true become: true
community.docker.docker_compose_v2: community.docker.docker_compose_v2:
project_src: "{{ item }}" project_src: "{{ item }}"
state: present state: present
pull: always pull: never
build: always build: always
loop: "{{ docker_compose_dirs | default([]) }}" loop: "{{ docker_compose_dirs | default([]) }}"
+15
View File
@@ -0,0 +1,15 @@
---
node_exporter_base_flags: >-
--collector.systemd
--collector.processes
--collector.tcpstat
--no-collector.infiniband
--no-collector.tapestats
--no-collector.zfs
# Disable ARP collector by default unless this is the bastion router in barbican
node_exporter_disable_arp: "{{ not (inventory_hostname == 'bastion' and 'barbican' in group_names) }}"
node_exporter_flags: >-
{{ node_exporter_base_flags }}
{% if node_exporter_disable_arp %}--no-collector.arp{% endif %}
+6
View File
@@ -0,0 +1,6 @@
---
- name: Restart node_exporter
ansible.builtin.systemd:
name: prometheus-node-exporter
state: restarted
become: true
+59
View File
@@ -0,0 +1,59 @@
---
- name: Install node_exporter (Debian)
ansible.builtin.apt:
name: prometheus-node-exporter
state: present
when: ansible_facts["os_family"] == "Debian"
become: true
- name: Install node_exporter (Arch)
community.general.pacman:
name: prometheus-node-exporter
state: present
when: ansible_facts["os_family"] == "Archlinux"
become: true
- name: Configure node_exporter flags (Debian)
ansible.builtin.copy:
dest: /etc/default/prometheus-node-exporter
content: |
ARGS="{{ node_exporter_flags }}"
owner: root
group: root
mode: '0644'
when: ansible_facts["os_family"] == "Debian"
become: true
notify: Restart node_exporter
- name: Configure node_exporter flags (Arch)
ansible.builtin.copy:
dest: /etc/conf.d/prometheus-node-exporter
content: |
NODE_EXPORTER_ARGS="{{ node_exporter_flags }}"
owner: root
group: root
mode: '0644'
when: ansible_facts["os_family"] == "Archlinux"
become: true
notify: Restart node_exporter
- name: Enable and start node_exporter service
ansible.builtin.systemd:
name: prometheus-node-exporter
state: started
enabled: true
become: true
- name: Populate service facts
ansible.builtin.service_facts:
- name: Open port 9100 for prometheus scraping
ansible.posix.firewalld:
port: 9100/tcp
permanent: true
state: enabled
immediate: true
become: true
when: >
ansible_facts.services['firewalld.service'] is defined and
ansible_facts.services['firewalld.service'].state == 'running'
+4 -4
View File
@@ -3,15 +3,15 @@
ansible.builtin.apt: ansible.builtin.apt:
name: prometheus-smartctl-exporter name: prometheus-smartctl-exporter
state: present state: present
when: ansible_os_family == "Debian" when: ansible_facts["os_family"] == "Debian"
become: true become: true
- name: Install smartctl_exporter (Arch) - name: Install smartctl_exporter (Arch)
aur: aur:
name: prometheus-smartctl-exporter-bin name: prometheus-smartctl-exporter
use: pikaur use: "{{ aur_helper }}"
state: present state: present
when: ansible_os_family == "Archlinux" when: ansible_facts["os_family"] == "Archlinux"
- name: Enable and start smartctl_exporter service - name: Enable and start smartctl_exporter service
ansible.builtin.systemd: ansible.builtin.systemd: