aboutsummaryrefslogtreecommitdiff
path: root/tasks/main.yml
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2021-10-17 20:41:13 -0400
committerMitchell Riedstra <mitch@riedstra.dev>2021-10-17 20:41:13 -0400
commit4db1380d6e401fdcafdea847d5a74a86be51f8c4 (patch)
treecea2b2b60ecb2adbb4ace7be24ac7d52660707b5 /tasks/main.yml
downloadnode_exporter-4db1380d6e401fdcafdea847d5a74a86be51f8c4.tar.gz
node_exporter-4db1380d6e401fdcafdea847d5a74a86be51f8c4.tar.xz
InitialHEADmaster
Diffstat (limited to 'tasks/main.yml')
-rw-r--r--tasks/main.yml57
1 files changed, 57 insertions, 0 deletions
diff --git a/tasks/main.yml b/tasks/main.yml
new file mode 100644
index 0000000..866f00e
--- /dev/null
+++ b/tasks/main.yml
@@ -0,0 +1,57 @@
+---
+- set_fact: "node_exporter_extract_dir=node_exporter-{{node_exporter_version}}.{{node_exporter_os}}-{{node_exporter_architecture}}"
+- name: Create configuration directory
+ file:
+ state: directory
+ dest: "{{node_exporter_home_dir}}/conf"
+ mode: '0700'
+- name: Download Node Exporter
+ get_url:
+ url: "{{node_exporter_url}}"
+ dest: "{{node_exporter_home_dir}}/node_exporter-{{node_exporter_version}}.tgz"
+ mode: '0600'
+ checksum: 'sha256:{{node_exporter_checksum}}'
+# There's a bug in become_user that doesn't set permissions on the temp directory
+# which is asinine when my user has sudo persmissions.
+- name: Extract Node exporter
+ shell: |
+ #!/bin/sh
+ set -e
+ if ! [ -e "{{node_exporter_home_dir}}/{{node_exporter_extract_dir}}" ] ; then
+ cd "{{node_exporter_home_dir}}"
+ tar xzf node_exporter-{{node_exporter_version}}.tgz
+ exit 50
+ fi
+ register: res
+ changed_when: res is defined and res.rc == 50
+ ignore_errors: true
+ notify: Restart node_exporter
+- name: Link node_exporter directory
+ file:
+ state: link
+ src: '{{node_exporter_extract_dir}}'
+ dest: '{{node_exporter_home_dir}}/node_exporter'
+ force: yes
+- name: Link configuration files
+ file:
+ state: link
+ src: '../conf/{{item}}'
+ dest: '{{node_exporter_home_dir}}/node_exporter/{{item}}'
+ force: yes
+ loop:
+ - web_config.yml
+ notify: Restart node_exporter
+- name: Include tls tasks
+ include_tasks: tls.yml
+ when: node_exporter_tls
+- name: Write node_exporter configuration file
+ copy:
+ content: '{{node_exporter_web_config | to_nice_yaml}}'
+ dest: '{{node_exporter_home_dir}}/conf/web_config.yml'
+ mode: '0600'
+ notify: Restart node_exporter
+ tags:
+ - configuration
+ when: node_exporter_web_config is defined
+- name: Include Runit tasks
+ include_tasks: runit.yml