Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernization rewrite #16

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
cc17d7f
Add .gitignore
pid1 Dec 9, 2024
95b65bb
Initial rewrite commit
pid1 Dec 9, 2024
0504b83
Debian functional
pid1 Dec 9, 2024
e2b3c91
Apply config, remove hosts file
pid1 Dec 9, 2024
c52085f
Re-organize, moving everything up a directory.
pid1 Dec 9, 2024
3655ec8
Update to match current rewrite
pid1 Jan 8, 2025
2708fb6
Install chart support if configured, false by default
pid1 Jan 13, 2025
08916da
Merge pull request #5 from pid1/chart-support
pid1 Jan 13, 2025
12a97eb
Repos and chart support for OpenSUSE
pid1 Jan 13, 2025
a00b949
Merge pull request #6 from pid1/chart-support
pid1 Jan 13, 2025
b0cbeda
Lay down and enable chart files
pid1 Jan 14, 2025
5bb6839
Allow setting custom directory of chart templates
pid1 Jan 14, 2025
d38d319
Update node claim to Netdata 2.0
pid1 Jan 14, 2025
88504b2
Merge pull request #8 from pid1/chart-support
pid1 Jan 14, 2025
952392f
Add missing newlines, bump version
pid1 Jan 15, 2025
f4877bf
Linting fixes
pid1 Jan 15, 2025
4592532
Merge pull request #9 from pid1/linting
pid1 Jan 15, 2025
39ae227
Fix line length
pid1 Jan 15, 2025
55b9cc2
Merge pull request #10 from pid1/linting
pid1 Jan 15, 2025
d773a16
Fix chart directory path
pid1 Jan 15, 2025
ceb87cd
Various small bugfixes
pid1 Jan 15, 2025
1e7ab47
Update installation handling on Debian
pid1 Jan 15, 2025
a906ce2
Set role name and fix Suse install
pid1 Jan 15, 2025
517dd8b
Fix node claim and chart management
pid1 Jan 15, 2025
0e23623
Fixed wrong permissions
pid1 Jan 15, 2025
9087198
Match upstream
pid1 Jan 15, 2025
0348820
Clarity
pid1 Jan 15, 2025
74b3958
Further permissions adjustments
pid1 Jan 15, 2025
999e16d
Ignore swapfiles
pid1 Jan 15, 2025
75b22dd
Remove erroneously committed swap file
pid1 Jan 15, 2025
628ef48
Missing newline
pid1 Jan 15, 2025
9343c49
Make this an explicit binary
pid1 Feb 8, 2025
ef78456
this doesn’t need an explicit truthy value
pid1 Feb 8, 2025
fa09a37
Better service management
pid1 Feb 8, 2025
55de4fd
Update claim logic everywhere else
pid1 Feb 10, 2025
4bff69c
Remove trailing space
pid1 Feb 10, 2025
4c43291
Improve distribution handling
pid1 Feb 10, 2025
4c2614e
Add Ubuntu CI
pid1 Feb 10, 2025
74ec6ed
Permissions
pid1 Feb 10, 2025
bf7be5d
Modular per-distro tests
pid1 Feb 10, 2025
fd38a49
Permissions
pid1 Feb 10, 2025
9830e41
Bypass apt prompts
pid1 Feb 10, 2025
6552cb0
Add prerequisites so service management works
pid1 Feb 10, 2025
acc0bfb
Fix capitalization
pid1 Feb 10, 2025
ea2afc1
Bypass systemd when in a container
pid1 Feb 10, 2025
4ea2115
Add OpenSUSE
pid1 Feb 10, 2025
c2549fa
Install dependencies before CI
pid1 Feb 10, 2025
247ca6b
Whitespace cleanup
pid1 Feb 10, 2025
68019db
Add gzip
pid1 Feb 10, 2025
1483015
Add just ansible-lint
pid1 Feb 11, 2025
21dc987
Ignore tests and galaxy config
pid1 Feb 11, 2025
ca997bf
Add role name explicitly to skip list
pid1 Feb 11, 2025
567edd9
Use skip list instead
pid1 Feb 11, 2025
9a1a78e
Install recommends on all platforms
pid1 Feb 18, 2025
989fced
Merge pull request #11 from pid1/jr/install-recommends
pid1 Feb 18, 2025
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.

3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# For the time being, @Ferroin is responsible for everything here.
# For the time being, @Ferroin is responsible for everything here

* @netdata/agent-sre
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vscode
hosts
ansible.cfg
.swp
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

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.

43 changes: 43 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
role_version: 1.0.0

# Define the Netdata release version we install
netdata_release_version: "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.

8 changes: 8 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: Restart Netdata
ansible.builtin.systemd:
name: netdata
state: started
daemon_reload: true
enabled: true
when: ansible_service_mgr == "systemd"
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,10 @@
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.

Loading