diff --git a/data/common/common.yaml b/data/common/common.yaml --- a/data/common/common.yaml +++ b/data/common/common.yaml @@ -2914,6 +2914,9 @@ nginx::names_hash_max_size: 1024 nginx::worker_processes: "%{::processorcount}" +# prometheus::pve-exporter::password in credential +prometheus::pve-exporter::user: pve_exporter@pve + prometheus::server::defaults_config: web: enable_admin_api: true diff --git a/site-modules/profile/manifests/prometheus/pve_exporter.pp b/site-modules/profile/manifests/prometheus/pve_exporter.pp new file mode 100644 --- /dev/null +++ b/site-modules/profile/manifests/prometheus/pve_exporter.pp @@ -0,0 +1,42 @@ +class profile::prometheus::pve_exporter { + $user = lookup('prometheus::pve-exporter::user') + $password = lookup('prometheus::pve-exporter::password') + + $config_dir = '/etc/pve-exporter' + $config_file = "${config_dir}/pve-exporter.yml" + + $packages = ['python3-prometheus-pve-exporter']; + + file { $config_dir: + ensure => present, + owner => 'root', + group => 'root', + mode => '0644', + } + + # template uses $user and $password + + file { $config_file: + ensure => present, + owner => 'root', + group => 'root', + mode => '0600', + content => template('profile/pve-exporter/pve-exporter.yml.erb'), + } + + package {$packages: + ensure => 'present', + } + + # template uses $config_file + + $service_name = 'prometheus-pve-exporter.service' + file {$service_name: + ensure => present, + mode => '0755', + owner => 'root', + group => 'root', + content => template("profile/pve-exporter/${service_name}.erb"), + } + +} diff --git a/site-modules/profile/templates/pve-exporter/prometheus-pve-exporter.service.erb b/site-modules/profile/templates/pve-exporter/prometheus-pve-exporter.service.erb new file mode 100644 --- /dev/null +++ b/site-modules/profile/templates/pve-exporter/prometheus-pve-exporter.service.erb @@ -0,0 +1,10 @@ +[Unit] +Description=Proxmox VE Prometheus Exporter +After=network.target +Wants=network.target +[Service] +Restart=on-failure +WorkingDirectory=/tmp +ExecStart=/usr/bin/pve_exporter <%= @config_file %> +[Install] +WantedBy=multi-user.target diff --git a/site-modules/profile/templates/pve-exporter/pve-exporter.yml.erb b/site-modules/profile/templates/pve-exporter/pve-exporter.yml.erb new file mode 100644 --- /dev/null +++ b/site-modules/profile/templates/pve-exporter/pve-exporter.yml.erb @@ -0,0 +1,4 @@ +default: + user: <%= @user %> + password: <%= @password %> + verify_ssl: false diff --git a/site-modules/role/manifests/swh_hypervisor.pp b/site-modules/role/manifests/swh_hypervisor.pp --- a/site-modules/role/manifests/swh_hypervisor.pp +++ b/site-modules/role/manifests/swh_hypervisor.pp @@ -1,3 +1,4 @@ class role::swh_hypervisor inherits role::swh_server { include profile::megacli + include profile::prometheus::pve_exporter }