Wei-Yu Chen | 0a90167 | 2021-06-22 08:22:03 +0800 | [diff] [blame^] | 1 | --- |
| 2 | # node_exporter tasks/main.yml |
| 3 | # |
| 4 | # SPDX-FileCopyrightText: © 2021 Open Networking Foundation <support@opennetworking.org> |
| 5 | # SPDX-License-Identifier: Apache-2.0 |
| 6 | |
| 7 | - name: include OS-specific vars |
| 8 | include_vars: "{{ ansible_os_family }}.yml" |
| 9 | |
| 10 | - name: include OS-specific tasks |
| 11 | include_tasks: "{{ ansible_os_family }}.yml" |
| 12 | |
| 13 | - name: Create group for Node Exporter |
| 14 | group: |
| 15 | name: "{{ node_exporter_name }}" |
| 16 | |
| 17 | - name: Create user for Node Exporter |
| 18 | user: |
| 19 | name: "{{ node_exporter_name }}" |
| 20 | group: "{{ node_exporter_group }}" |
| 21 | comment: "{{ node_exporter_comment }}" |
| 22 | shell: "{{ node_exporter_shell }}" |
| 23 | system: true |
| 24 | password_lock: true |
| 25 | |
| 26 | - name: Create Node Exporter dist dir |
| 27 | file: |
| 28 | path: "{{ node_exporter_dist_dir }}" |
| 29 | state: directory |
| 30 | owner: "root" |
| 31 | group: "root" |
| 32 | mode: "0755" |
| 33 | |
| 34 | - name: Download Node Exporter distro .tgz file |
| 35 | get_url: |
| 36 | url: "https://github.com/prometheus/node_exporter/releases/download/\ |
| 37 | v{{ node_exporter_ver }}/node_exporter-{{ node_exporter_ver }}.linux-amd64.tar.gz" |
| 38 | dest: "{{ node_exporter_dist_dir }}/node_exporter-{{ node_exporter_ver }}.tar.gz" |
| 39 | owner: "root" |
| 40 | group: "root" |
| 41 | mode: "0644" |
| 42 | checksum: "{{ node_exporter_checksum }}" |
| 43 | |
| 44 | - name: Unarchive Node Exporter distribution |
| 45 | unarchive: |
| 46 | remote_src: true |
| 47 | src: "{{ node_exporter_dist_dir }}/node_exporter-{{ node_exporter_ver }}.tar.gz" |
| 48 | dest: "{{ node_exporter_dist_dir }}" |
| 49 | owner: "root" |
| 50 | group: "root" |
| 51 | creates: "{{ node_exporter_dist_dir }}/node_exporter-{{ node_exporter_ver }}.linux-amd64" |
| 52 | |
| 53 | - name: Link Node Exporter distro to working dir |
| 54 | file: |
| 55 | state: "link" |
| 56 | src: "{{ node_exporter_dist_dir }}/node_exporter-{{ node_exporter_ver }}.linux-amd64" |
| 57 | dest: "{{ node_exporter_working_dir }}" |
| 58 | notify: |
| 59 | - "start-node-exporter" |