darkwizard242.node_exporter

构建状态 Ansible角色 Ansible角色 Ansible质量分数 质量门状态 GitHub标签(最新SemVer) GitHub仓库大小

Ansible角色:Node Exporter

此角色用于在Debian/UbuntuEL系统上安装(默认)node_exporter

要求

没有特别的要求。

为node_exporter创建的systemd服务文件将标准输出和标准错误流发送到syslogSyslogIdentifier设置为node_exporter。因此,您可以通过在系统上执行命令sudo journalctl -u node_exporter.service来检查node_exporter日志。此外,您可能希望配置rsyslog来收集程序名为node_exporter的日志,并输出到特定文件以维护日志文件。有关日志轮换,darkwizard242.logrotate角色可在Ansible Galaxy中找到。

角色变量

可用的变量在下面列出(位于defaults/main.yml):

变量列表:

node_exporter_app: node_exporter
node_exporter_version: 1.5.0
node_exporter_osarch: linux-amd64
node_exporter_archive_format: tar.gz
node_exporter_dl_url: "https://github.com/prometheus/{{ node_exporter_app }}/releases/download/v{{ node_exporter_version }}/{{ node_exporter_app }}-{{ node_exporter_version }}.{{ node_exporter_osarch }}.{{ node_exporter_archive_format }}"

node_exporter_app_group: "{{ node_exporter_app }}"
node_exporter_app_group_desired_state: present

node_exporter_app_user: "{{ node_exporter_app }}"
node_exporter_app_user_desired_state: present
node_exporter_app_user_home_state: no
node_exporter_app_user_shell: /bin/false

node_exporter_temp_path: /tmp

node_exporter_bin_path: /usr/local/bin
node_exporter_bin_path_mode: '0755'
node_exporter_bin_path_remote_src: yes

node_exporter_systemd_service_setup: true
node_exporter_systemd_service_name: "{{ node_exporter_app }}"
node_exporter_systemd_service_flags: --collector.systemd --collector.processes --collector.mountstats
node_exporter_systemd_service_template: "{{ node_exporter_app }}.service.j2"
node_exporter_systemd_service_template_dest: "/etc/systemd/system/{{ node_exporter_app }}.service"
node_exporter_systemd_service_template_user: root
node_exporter_systemd_service_template_group: root
node_exporter_systemd_service_template_dest_mode: '0644'
node_exporter_systemd_service_template_backup: yes
node_exporter_systemd_service_desired_state: restarted
node_exporter_systemd_service_desired_boot_enabled: yes

node_exporter_app_port: 9100
node_exporter_app_check_status_code: 200
node_exporter_app_check_status_code_retries: 10
node_exporter_app_check_status_code_delay: 5

变量表:

变量 描述
node_exporter_app 定义要安装的应用程序,即node_exporter
node_exporter_version 用于动态提取所需的安装版本。默认为:1.5.0
node_exporter_osarch 定义操作系统架构。用于根据操作系统体系结构获取正确类型的二进制文件。默认为:linux-amd64
node_exporter_archive_format 下载存档时使用的格式。
node_exporter_dl_url 定义下载node_exporter二进制文件的URL。
node_exporter_app_group node_exporter所有者所属的组名。默认为node_exporter
node_exporter_app_group_desired_state present表示如果组不存在则创建该组。替代为absent。
node_exporter_app_user node_exporter的拥有者用户名。默认为node_exporter
node_exporter_app_user_desired_state present表示如果用户不存在则创建该用户。替代为absent。
node_exporter_app_user_home_state 设置为'no'以不为node_exporter用户创建主目录。
node_exporter_app_user_shell 用于定义用户是否应该具有默认shell。设置为/bin/false,因为不需要。
node_exporter_temp_path node_exporter档案下载和解压缩的临时路径。
node_exporter_bin_path 存放实际node_exporter的路径。
node_exporter_bin_path_mode node_exporter二进制文件的权限。
node_exporter_bin_path_remote_src 定义让ansible处理远程主机的解压操作。
node_exporter_systemd_service_setup 用作条件以设置node_exporter的systemd服务文件。如果设置为false,则不创建node_exporter的systemd服务文件。
node_exporter_systemd_service_name 当node_exporter_systemd_service_setup设置为true时的systemd服务文件名称。
node_exporter_systemd_service_flags 变量用于存储和传递在node_exporter_systemd_service_setup设置为true时,node_exporter服务文件中的任何命令行标志。
node_exporter_systemd_service_template 当node_exporter_systemd_service_setup设置为true时,将放置在主机上的Jinja2源systemd服务模板文件。
node_exporter_systemd_service_template_dest 当node_exporter_systemd_service_setup设置为true时,node_exporter systemd服务的目标文件名。
node_exporter_systemd_service_template_user 当node_exporter_systemd_service_setup设置为true时,node_exporter systemd服务文件的所有者。
node_exporter_systemd_service_template_group 当node_exporter_systemd_service_setup设置为true时,node_exporter systemd服务文件的组。
node_exporter_systemd_service_template_dest_mode 当node_exporter_systemd_service_setup设置为true时,node_exporter systemd服务文件的权限。
node_exporter_systemd_service_template_backup 当node_exporter_systemd_service_setup设置为true时,备份任何现有的node_exporter systemd服务文件。
node_exporter_systemd_service_desired_state 当node_exporter_systemd_service_setup设置为true时,node_exporter systemd服务的期望状态。
node_exporter_systemd_service_desired_boot_enabled 当node_exporter_systemd_service_setup设置为true时,设置node_exporter服务为启用状态。
node_exporter_app_port 默认情况下node_exporter的端口是9100,使用此变量在处理程序中检查node_exporter是否在9100端口运行。
node_exporter_app_check_status_code 处理程序运行node_exporter检查时查找的状态码。
node_exporter_app_check_status_code_retries 处理程序尝试检查node_exporter运行的次数。
node_exporter_app_check_status_code_delay 处理程序在检查node_exporter之间等待的延迟时间(秒)。

依赖性

示例剧本

用于ansible剧本中的角色(即安装node_exporter)的默认行为。

- hosts: servers
  roles:
    - role: darkwizard242.node_exporter

用于定制角色行为(即指定所需的node_exporter版本)在ansible剧本中。

- hosts: servers
  roles:
    - role: darkwizard242.node_exporter
      vars:
        node_exporter_version: 1.0.1

用于定制角色行为(即禁用node_exporter的systemd服务设置)在ansible剧本中。

- hosts: servers
  roles:
    - role: darkwizard242.node_exporter
      vars:
        node_exporter_systemd_service_setup: false

许可证

MIT

作者信息

此角色由Ali Muhammad创建。

关于项目

Installs & configures 'node_exporter' for scraping node metrics.

安装
ansible-galaxy install darkwizard242.node_exporter
许可证
mit
下载
5.3k
拥有者
Senior DevOps/CloudOps Engineer. Dedicated to Automating everything I come across. Love to work on and learn new technologies/tools everyday!