diff --git a/group_vars/all/vars.yml b/group_vars/all/vars.yml index 71c0ba0..6ee1111 100644 --- a/group_vars/all/vars.yml +++ b/group_vars/all/vars.yml @@ -96,9 +96,16 @@ nextcloud_dbname: owncloud nextcloud_dbuser: owncloud nextcloud_dbpass: "{{ vault_owncloud_dbpass }}" +prometheus_pve_user: prometheus@pve +prometheus_pve_pass: "{{ vault_prometheus_pve_pass }}" + prosody_admin: moepman@jabber.binary-kitchen.de prosody_domain: jabber.binary-kitchen.de +pve_targets: +- wurst.binary.kitchen +- salat.binary.kitchen + radius_secret: "{{ vault_radius_secret }}" rocketchat_domain: chat.binary-kitchen.de diff --git a/group_vars/all/vault.yml b/group_vars/all/vault.yml index d74b15d..f5df42a 100644 --- a/group_vars/all/vault.yml +++ b/group_vars/all/vault.yml @@ -1,38 +1,40 @@ $ANSIBLE_VAULT;1.1;AES256 -31316565653436313436663337323938356535343436663335626534623164323933346132623738 -3336623562623536366566626338326233643766353963610a363566623666636162653464383363 -34653566643437383437356131383637303466303433663031376638623634643161306564336536 -3262626566333632380a313261313837646636336433343839623062316637636535396333656330 -34316636336236666465396464623162666337613861643536313436366461383365376436303864 -30636438363166363537333130323638383431623537366234363332633965616232393366623130 -30313664303961393733653066383663356436336139363234666636633835636663626366306664 -32653039393732306138316138333138323034363836643436666436613065373162363634616334 -30633031303166613161623262323866383664353335653566303265363061663636323966653735 -38386162393532333562306233663534613134633662376135323338613263326163643961363236 -38323331316633663032376530383862373463323633303739303637646139383561306439353430 -38323736386334303834346637393933306532393962626635326364363034643236336338623565 -66346666633935633933636132373730646664303239376532633935626565356238366337306133 -64626263396538363039326663663934323339303461386538643837383833303264656463306161 -30663964316438626636653337356630653638616238626563336366646134373461636265343138 -37396630613033306636306533356462316336333562346633646239646332386138346431303661 -37336436623963396135336339656337363864666235343832313839313633623632613939636636 -31613233383366386335376132323635643332643930646137333639656236373766363365313435 -63653530323532396465386533653836346265353861336331323735316231653335396337643635 -38373066313037363638333337353430346331396134366136373731333265616662316337373539 -65383035656334376363613033316133376233333463613963356135366665346530613861636466 -31656435636661383066303163636364356538343431383636353963306139393864633037326332 -63343165313464333138393439313235323263633034376530323934326238653366353331343234 -31313663353534336233363361343065636561653536393036346461656530393739653535623832 -33626236653965626366346235383163303030623365356536663135353933646266326434336634 -66373733323831333834303462346536373865343732663762633865343435343361656537336266 -35326431313961663262393461363932333334653239306132646538383464343461336633336261 -66313633616464323931393962666133356362383135666338303635353363353639303935336533 -63383137343136383630333136313361626364383738333563333063336661613436336465326132 -31383933633632613265363262653365366239343732366166356134646631333461643432333239 -33633065666531313039303765663138396266356431306636303561386435636365623534396632 -32346366343665656262663663663934636230323334396332313030386237306633386563396661 -33643562376530623961383830313065396330333134383736613135636338633432326236383632 -63643066303665373762656565303265313132313334653336613464396566326335366433303235 -36363735363734393936646461326230316535616462643933643933373462613063656265666561 -39393433343437363537626331333534373632663065376636336363306537396263353766626662 -3633 +65386365643062373630613165666663396337336335653562663134376664306466663463613637 +3364303661616431613138653162333536343234633839310a306366646266346238333538326633 +35633264353932633361616531623336386331663038363832363038373833356139313065383065 +6462356264373862650a313166323366623963643839643564613462366232653361393331353430 +32393936636161653339393531363761643137306639376564613134643763333861653764373563 +65656364353964343033326266353062396330363934633933646632303236666130303838623332 +37333237316235343430333762346534636636353332363332323433666262333833636638623862 +66343239656461336138356334666363653039353861656363363963383831373962613637376631 +38323432396435373433653165386634306332323137326365643764353161616330663638376163 +64646438323331633138343932653038636638386639623433636139623266376465373266653137 +36313138396230616335653334653233333430366631383835363231393333663661646133313732 +61303430393933326432626135333637666135616634643430633433633832373435663338643130 +30666664623435303462376363313666353633313766353631343939313862356139643164333865 +38306237613735663565346266363263656161303164626632366465653939363932373631623938 +30633762376432353231323437303638313939613034303235336261303530646333656432393661 +38616366353461323839643465663039363339356330336262616539373032353466613633653662 +32373733326266323335386365633232383732383432333265333066623463616165376539356234 +63326438653530336264326437386164303139383036383361333737343861646133353464366533 +63343731366535343330616162333465633966383262313531636430383735343135306233616138 +61656432343938363430363636373533373832363565353538356462366663633639356630653331 +32386533303366353262643464653831383937333736366239633030323432653234656536393435 +63376564623361653864316462613434323932666561356532646536636130616534376231373563 +64393365653163336635366663323239363436363064353461326261363837323663623162323234 +36643436316331643331383133393830373838363865393130333864383136323064383731353065 +64633236613437646138373635396563666533393533333464633062326337623037616266636664 +31633435353266323163356434353461633763396261393762313437353162373464313534383638 +30616665623831653565613764313237333333343034326437323436323139613637333161623031 +39636238306464643635613836623361396562623366653263396633653132643937646139353261 +31623432633965643031346530336333353130666534303162373731376461353237633863303933 +30376331663833353233383161663066373965646536663461323236373466636334353235386530 +38306636666364343732393735383535333866656663613533336439636431323938633739383363 +38366665323339363966636533623635383464393831396431323161626563383432313433353035 +61356362333930653866616635333438353138353532323465633765613466646638646131316531 +34626430643066313461393535323830666266323462373331346261393130353463336362663263 +32333465653237326636306636333265643463363630626238333564613138383132393462616338 +34343237316239653362383831666233613033623964363030313731653532323831376365656535 +34653538313135623362343637663733636366646534373538303331323433653135303936336664 +31373062653338626234653537663136356537663665613864623462623130336363343862636465 +646238313932313833303933643432346133 diff --git a/roles/prometheus/files/prometheus-pve-exporter.service b/roles/prometheus/files/prometheus-pve-exporter.service new file mode 100644 index 0000000..690f1aa --- /dev/null +++ b/roles/prometheus/files/prometheus-pve-exporter.service @@ -0,0 +1,10 @@ +Description=Prometheus exporter for Proxmox VE +Documentation=https://github.com/znerol/prometheus-pve-exporter + +[Service] +Restart=always +User=prometheus +ExecStart=/opt/prometheus-pve-exporter/bin/pve_exporter /etc/prometheus/pve.yml + +[Install] +WantedBy=multi-user.target diff --git a/roles/prometheus/handlers/main.yml b/roles/prometheus/handlers/main.yml index 38f4e38..51336c6 100644 --- a/roles/prometheus/handlers/main.yml +++ b/roles/prometheus/handlers/main.yml @@ -1,4 +1,10 @@ --- +- name: Reload systemd + command: systemctl daemon-reload + - name: Restart prometheus service: name=prometheus state=restarted + +- name: Restart prometheus-pve-exporter + service: name=prometheus-pve-exporter state=restarted diff --git a/roles/prometheus/tasks/main.yml b/roles/prometheus/tasks/main.yml index b732342..8aec574 100644 --- a/roles/prometheus/tasks/main.yml +++ b/roles/prometheus/tasks/main.yml @@ -7,9 +7,35 @@ - name: Install prometheus apt: name=prometheus +- name: Install dependencies + apt: + name: + - python-setuptools + - python3-setuptools + - virtualenv + +- name: Install prometheus-pve-exporter + pip: + name: git+https://github.com/znerol/prometheus-pve-exporter + virtualenv: /opt/prometheus-pve-exporter + virtualenv_python: python3 + +- name: Systemd unit for prometheus-pve-exporter + copy: src=prometheus-pve-exporter.service dest=/etc/systemd/system/prometheus-pve-exporter.service + notify: + - Reload systemd + - Restart prometheus-pve-exporter + - name: Configure prometheus template: src=prometheus.yml.j2 dest=/etc/prometheus/prometheus.yml notify: Restart prometheus +- name: Configure prometheus-pve-exporter + template: src=pve.yml.j2 dest=/etc/prometheus/pve.yml + notify: Restart prometheus-pve-exporter + - name: Enable prometheus service: name=prometheus state=started enabled=yes + +- name: Enable prometheus-pve-exporter + service: name=prometheus-pve-exporter state=started enabled=yes diff --git a/roles/prometheus/templates/prometheus.yml.j2 b/roles/prometheus/templates/prometheus.yml.j2 index 2e7b942..cf43658 100644 --- a/roles/prometheus/templates/prometheus.yml.j2 +++ b/roles/prometheus/templates/prometheus.yml.j2 @@ -26,10 +26,28 @@ rule_files: # Here it's Prometheus itself. scrape_configs: {% if node_targets is defined %} -- job_name: node + - job_name: node static_configs: - targets: {% for target in node_targets %} - {{ target }} {% endfor %} {% endif %} +{% if pve_targets is defined %} + - job_name: pve + static_configs: + - targets: +{% for target in pve_targets %} + - {{ target }} +{% endfor %} + metrics_path: /pve + params: + module: [default] + relabel_configs: + - source_labels: [__address__] + target_label: __param_target + - source_labels: [__param_target] + target_label: instance + - target_label: __address__ + replacement: 127.0.0.1:9221 +{% endif %} diff --git a/roles/prometheus/templates/pve.yml.j2 b/roles/prometheus/templates/pve.yml.j2 new file mode 100644 index 0000000..72c4620 --- /dev/null +++ b/roles/prometheus/templates/pve.yml.j2 @@ -0,0 +1,4 @@ +default: + user: {{ prometheus_pve_user }} + password: {{ prometheus_pve_pass }} + verify_ssl: false