Add support for Ubuntu containers and WSL verification

- Implemented tasks for managing Ubuntu containers using Podman, including inspection, creation, starting, and SSH setup.
- Added verification tasks for WSL and Podman installation, machine existence, and NSSM service status.
- Created PowerShell scripts for Podman auto-start on Windows boot.
- Introduced Prometheus role with default configurations and installation tasks.
- Updated Windows SSH role to improve authorized_keys management and permissions handling.
- Modified inventory to include Windows containers host.
- Updated Grafana datasource configurations with direct IP addresses for Prometheus instances.
This commit is contained in:
2026-06-07 20:35:59 +02:00
parent 3775fa4b6e
commit 25d3eafa5b
34 changed files with 1475 additions and 155 deletions
+17 -33
View File
@@ -1,25 +1,16 @@
---
# Install Prometheus + Windows Exporter on Windows and open firewall for Grafana
- name: Define Prometheus Versions and install dir
- name: Define internal paths
ansible.builtin.set_fact:
prometheus_version: "{{ prometheus_version | default('3.6.0') }}"
prometheus_install_dir: "{{ prometheus_install_dir | default('C:\\Prometheus') }}"
prometheus_listen_address: "{{ prometheus_listen_address | default('0.0.0.0:9090') }}"
nssm_dir: "{{ nssm_dir | default('C:\\nssm') }}"
nssm_version: "{{ nssm_version | default('2.24') }}"
windows_exporter_version: "{{ windows_exporter_version | default('0.31.3') }}"
windows_exporter_collectors: "{{ windows_exporter_collectors | default(['cache', 'cpu', 'cpu_info', 'diskdrive', 'memory', 'net', 'os', 'process', 'service', 'tcp', 'time', 'update']) }}"
- name: Define Windows Exporter defaults
ansible.builtin.set_fact:
__nssm_url: "https://nssm.cc/release/nssm-{{ nssm_version }}.zip"
__prometheus_zip_url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.windows-amd64.zip"
__prometheus_zip_url: >-
https://github.com/prometheus/prometheus/releases/download/v{{
prometheus_version }}/prometheus-{{ prometheus_version }}.windows-amd64.zip
__prometheus_zip_path: "{{ (ansible_env.TEMP | default('C:\\Windows\\Temp')) }}\\prometheus-{{ prometheus_version }}.zip"
__prometheus_home: "{{ prometheus_install_dir }}\\prometheus-{{ prometheus_version }}.windows-amd64"
__windows_exporter_msi_url: "https://github.com/prometheus-community/windows_exporter/releases/download/v{{ windows_exporter_version }}/windows_exporter-{{ windows_exporter_version }}-amd64.msi"
__windows_exporter_msi_path: "{{ (ansible_env.TEMP | default('C:\\Windows\\Temp')) }}\\windows_exporter-{{ windows_exporter_version }}-amd64.msi"
__nssm_zip_path: "{{ (ansible_env.TEMP | default('C:\\Windows\\Temp')) }}\\nssm.zip"
__nssm_exe: "{{ nssm_dir }}\\nssm.exe"
__windows_exporter_msi_url: >-
https://github.com/prometheus-community/windows_exporter/releases/download/v{{
windows_exporter_version }}/windows_exporter-{{ windows_exporter_version }}-amd64.msi
__windows_exporter_msi_path: "{{ (ansible_env.TEMP | default('C:\\Windows\\Temp')) }}\\windows_exporter-{{ windows_exporter_version }}.msi"
- name: Create Prometheus installation directories
ansible.windows.win_file:
@@ -28,9 +19,8 @@
loop:
- "{{ prometheus_install_dir }}"
- "{{ prometheus_install_dir }}\\data"
- "{{ nssm_dir }}"
- name: Download required files (Prometheus, NSSM, Windows Exporter)
- name: Download required files (Prometheus, Windows Exporter)
ansible.windows.win_get_url:
url: "{{ item.url }}"
dest: "{{ item.dest }}"
@@ -38,8 +28,6 @@
loop:
- url: "{{ __prometheus_zip_url }}"
dest: "{{ __prometheus_zip_path }}"
- url: "{{ __nssm_url }}"
dest: "{{ __nssm_zip_path }}"
- url: "{{ __windows_exporter_msi_url }}"
dest: "{{ __windows_exporter_msi_path }}"
@@ -53,8 +41,6 @@
- src: "{{ __prometheus_zip_path }}"
dest: "{{ prometheus_install_dir }}"
creates: "{{ __prometheus_home }}\\prometheus.exe"
- src: "{{ __nssm_zip_path }}"
dest: "{{ nssm_dir }}"
- name: Verify Prometheus binary is present
ansible.windows.win_stat:
@@ -100,11 +86,9 @@
failed_when: promtool_check.rc != 0
when: promtool_bin.stat.exists
- name: Copy NSSM executable (win64)
ansible.windows.win_copy:
src: "{{ nssm_dir }}\\nssm-2.24\\win64\\nssm.exe"
dest: "{{ __nssm_exe }}"
remote_src: true
- name: Install NSSM
ansible.builtin.include_role:
name: nssm
- name: Remove existing Prometheus service if present
ansible.windows.win_service:
@@ -114,7 +98,7 @@
- name: Install Prometheus service via NSSM
ansible.windows.win_command: >-
"{{ __nssm_exe }}"
"nssm.exe"
install Prometheus
"{{ __prometheus_home }}\prometheus.exe"
--config.file={{ prometheus_install_dir }}\prometheus.yml
@@ -129,21 +113,21 @@
- name: Set Prometheus AppDirectory via NSSM
ansible.windows.win_command: >-
"{{ __nssm_exe }}" set Prometheus AppDirectory "{{ __prometheus_home }}"
"nssm.exe" set Prometheus AppDirectory "{{ __prometheus_home }}"
- name: Configure Prometheus stdout log via NSSM
ansible.windows.win_command: >-
"{{ __nssm_exe }}" set Prometheus AppStdout
"nssm.exe" set Prometheus AppStdout
"{{ prometheus_install_dir }}\prometheus-service.out.log"
- name: Configure Prometheus stderr log via NSSM
ansible.windows.win_command: >-
"{{ __nssm_exe }}" set Prometheus AppStderr
"nssm.exe" set Prometheus AppStderr
"{{ prometheus_install_dir }}\prometheus-service.err.log"
- name: Set Prometheus Start mode to AUTO via NSSM
ansible.windows.win_command: >-
"{{ __nssm_exe }}" set Prometheus Start SERVICE_AUTO_START
"nssm.exe" set Prometheus Start SERVICE_AUTO_START
- name: Ensure Prometheus service is running (skip in check mode)
ansible.windows.win_service: