aboutsummaryrefslogtreecommitdiff
path: root/tasks/main.yml
blob: 866f00ec9202aefe173ff39435e18431b3ece58d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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