Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .ansible-lint

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Linting

on:
push:
pull_request:


jobs:
build:
name: Ansible Lint # Naming the build is important to use it as a status check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run ansible-lint
uses: ansible/ansible-lint@main
with:
args: "--exclude tests/test.yml --skip-list=role-name"
52 changes: 52 additions & 0 deletions .github/workflows/linux-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Integration Test

on:
push:
pull_request:

jobs:

# Test installation against Debian Bookworm
debian-test-job:
runs-on: ubuntu-latest
container:
image: debian:bookworm
steps:
- name: Install dependencies
run: |
apt-get -y update; apt-get -y upgrade; apt-get -y install ansible
- name: Checkout code
uses: actions/checkout@v4
- name: Test installation
run: |
ansible-playbook tests/test.yml

# Test installation against OpenSUSE Leap 15
opensuse-test-job:
runs-on: ubuntu-latest
container:
image: opensuse/leap:15
steps:
- name: Install dependencies
run: |
zypper -n refresh; zypper -n update; zypper -n install ansible tar gzip
- name: Checkout code
uses: actions/checkout@v4
- name: Test installation
run: |
ansible-playbook tests/test.yml

# Test installation against Ubuntu 24.04
ubuntu-test-job:
runs-on: ubuntu-latest
container:
image: ubuntu:24.04
steps:
- name: Install dependencies
run: |
apt-get -y update; apt-get -y upgrade; apt-get -y install ansible
- name: Checkout code
uses: actions/checkout@v4
- name: Test installation
run: |
ansible-playbook tests/test.yml
83 changes: 39 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,42 @@
# Example of basic Netdata agent management using Ansible
## Prerequisites
Tested with Ansible v. 2.12.1; should work with any Ansible version since 2.9
# Netdata Ansible
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point, possibly not as part of this PR, but definitely before publishing this to Galaxy, we need to expand this (and also https://learn.netdata.cloud/) with all the current tweakables and expand example usage.


You have to edit the inventory file `hosts` and, perhaps, `ansible.cfg`.
It is likely that you will also want to edit netdata agent configuration file(s).

Requires jmespath installed on the host system
## Tested on
`Centos 7, Rocky 8, Oracle Linux 8, Fedora 35`

`Debian 10, Debian 11, Ubuntu 18, Ubuntu 20, Ubuntu22`

## Playbook components, a short description
> netdata-agent.yml:

Installs Netdata Packagecloud repository whenever possible.
Installs Netdata agent latest available version, trying to avoid installation from other repositories. By default, the 'edge' is used. You can change the default in group_vars/all or set it in the command line using external variable:

`ansible-playbook -e "distro=stable" netdata-agent.yml`

Or you can set in on per host basis, using inventory file or hosts_var/hostname.

> purge.yml:

Removes both installed repository and the package, making efforts to remove all possible remains like the log or configuration files.

> claim.yml:

Claims the agent against Netdata Cloud

## Parameters

Playbooks behavior is parameterized to some extent. You may add or change the global settings in `group_vars/all` file or on per host basis in corresponding files in `host_vars/`
You might also want to set some parameters in inventory file, of course. Or directly in the command line. Examples:

`ansible-playbook --limit=debian10,ubuntu20 netdata-agent.yml`

`ansible-playbook -u toor --limit=rocky8 -e "distro=edge" purge.yml`

*Warning.*

You cannot just switch from stable to edge repos (nor visa versa). You have to purge existing installation first.

## To do

- The only agent configuration file used for the time being is `netdata.conf`. Perhaps, other configuration files handling should be added.
- Debian 12
- SUSE Linux Enterprise Server 15

## Utilization

To install Netdata on a host, you can use the following playbook:

```yaml
- hosts: all
roles:
- role: netdata
```

To install Netdata on a host and configure it to send metrics to a Netdata Cloud account, you can use the following playbook:

```yaml
- hosts: all
roles:
- role: netdata
vars:
netdata_claim: true
netdata_claim_token: "YOUR_NETDATA_CLAIM_TOKEN"
```

To install Netdata on a host and enable custom configuration or charts, you can use the following playbook:

```yaml
- hosts: all
roles:
- role: netdata
vars:
netdata_claim: true
netdata_claim_token: "YOUR_NETDATA_CLAIM_TOKEN"
netdata_manage_config: true
netdata_manage_charts: true
netdata_custom_config_path: "/path/to/custom/netdata.conf.j2"
netdata_custom_charts_path: "/path/to/custom/charts/"
```
10 changes: 0 additions & 10 deletions ansible.cfg

This file was deleted.

8 changes: 0 additions & 8 deletions claim.yml

This file was deleted.

42 changes: 42 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# Define the Netdata release channel
# Supported values: stable, nightly (alias for edge), edge
netdata_release_channel: "stable"

# Define if we manage the Netdata configuration
netdata_manage_config: false

# Define if we install chart support
netdata_manage_charts: false

# Define Netdata config file path
netdata_config_dir: "/etc/netdata"

# Define the Netdata custom config directory
netdata_custom_config_path: ""

# Define the Netdata chart directory
netdata_chart_dir: "/usr/libexec/netdata/charts.d"

# Define the Netdata custom chart directory
netdata_custom_charts_path: ""

# Allow for injecting a claim token if using Netdata Cloud
netdata_proxy: ""
netdata_claim: false
netdata_claim_url: "https://app.netdata.cloud"
netdata_claim_token: ""
netdata_claim_rooms: ""

# Define the Netdata repository URLs and associated key files
netdata_repository_url: "http://repo.netdata.cloud/repos/"
netdata_repoconfig_url: "http://repo.netdata.cloud/repoconfig/"
netdata_repository_key_url: "https://repo.netdata.cloud/netdatabot.gpg.key"

# Define config for enabled Go integrations
netdata_go_collector_plugins: []
# - name: prometheus
# config:
# job:
# - name: local
# url: http://127.0.0.1:9090/metrics
5 changes: 0 additions & 5 deletions group_vars/all

This file was deleted.

13 changes: 13 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Restart Netdata
ansible.builtin.systemd:
name: netdata
state: restarted
daemon_reload: true
enabled: true
when: ansible_service_mgr == "systemd"

- name: Reload Netdata claiming state
ansible.builtin.command: netdatacli reload-claiming-state
changed_when: true
failed_when: false
2 changes: 0 additions & 2 deletions host_vars/centos7

This file was deleted.

26 changes: 0 additions & 26 deletions hosts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
version: "0.1.0"

galaxy_info:
author: Netdata packaging team
description: real-time charts for system monitoring (https://netdata.cloud/)
author: Ralph Meijer
description: Deploys the NetData agent
company: Netdata Inc.
role_name: netdata

license: GPL-3.0-or-later
license: Apache-2.0

min_ansible_version: "2.1"

Expand Down
92 changes: 0 additions & 92 deletions molecule/README.md

This file was deleted.

4 changes: 0 additions & 4 deletions molecule/common/Dockerfile_debian10.j2

This file was deleted.

4 changes: 0 additions & 4 deletions molecule/common/Dockerfile_debian11.j2

This file was deleted.

Loading