-
Notifications
You must be signed in to change notification settings - Fork 32
Fix ansible-lint violations and modernize Netdata ansible quck-start playbook #105
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
Open
guiand888
wants to merge
7
commits into
netdata:main
Choose a base branch
from
guiand888:ansible_linting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f1e0467
Fix ansible-lint violations and restructure playbook
guiand888 4bbb38c
Update README with proper playbook usage instructions
guiand888 b3e04f8
Add comprehensive ansible documentation to configuration-management R…
guiand888 01e322c
Moving sintructions to the parent README
guiand888 db0c0b9
clean up
guiand888 841aa80
Final cleanup: redact secrets, add configurable options, and improve …
guiand888 ecf756e
Updating file mode
guiand888 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,44 @@ | ||
| # Configuration Management | ||
|
|
||
| Sample applications regarding the configuration of Netdata Agents programmatically. | ||
| Sample applications regarding the configuration of Netdata Agents programmatically. | ||
|
|
||
| Examples: Hashicorp Consul, Ansible, etc. | ||
| ## Ansible | ||
|
|
||
| ### Ansible Quickstart | ||
|
|
||
| The [`ansible-quickstart`](ansible-quickstart/) directory contains a ready-to-use Ansible playbook for installing, configuring, and claiming Netdata agents to Netdata Cloud. | ||
|
|
||
| #### Usage | ||
|
|
||
| 1. **Configure inventory**: Edit `ansible-quickstart/hosts` file with your target servers | ||
| 2. **Set variables**: Update `ansible-quickstart/vars/main.yml` with your Netdata Cloud credentials | ||
| 3. **Run playbook**: Execute the main playbook | ||
|
|
||
| ```bash | ||
| cd ansible-quickstart | ||
| ansible-playbook -i hosts playbook.yml | ||
| ``` | ||
|
|
||
| #### Configuration | ||
|
|
||
| **Required Variables (vars/main.yml)** | ||
| - `claim_token`: Your Netdata Cloud claim token | ||
| - `claim_rooms`: Your Netdata Cloud room ID | ||
| - `claim_url`: Netdata Cloud URL (default: https://app.netdata.cloud) | ||
|
|
||
| **Optional Variables** | ||
| - `reclaim`: Force re-claiming of nodes (default: false) | ||
| - `dbengine_multihost_disk_space`: Database size in MiB (default: 2048) | ||
| - `web_mode`: Agent web server mode (default: none) | ||
| - `netdata_channel`: Installation channel - 'stable' or 'nightly' (default: stable) | ||
| - `netdata_auto_updates`: Enable automatic updates (default: false) | ||
|
|
||
| #### Tasks Performed | ||
|
|
||
| 1. **Install**: Downloads and installs Netdata using the official kickstart script | ||
| 2. **Configure**: Applies custom configuration template | ||
| 3. **Claim**: Claims the node to Netdata Cloud (or re-claims if specified) | ||
|
|
||
| ### Other Examples | ||
|
|
||
| Examples: Hashicorp Consul, etc. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| See https://github.com/netdata/netdata/tree/master/packaging/installer/methods/ansible.md | ||
| # Netdata Ansible Quickstart | ||
|
|
||
| For complete usage instructions and configuration options, see the [Configuration Management README](../README.md#ansible). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| --- | ||
| - name: Install and configure Netdata | ||
| hosts: all | ||
| vars_files: | ||
| - vars/main.yml | ||
| become: true | ||
| become_method: sudo | ||
|
|
||
| tasks: | ||
| - name: Import installation tasks | ||
| ansible.builtin.import_tasks: tasks/install.yml | ||
|
|
||
| - name: Import configuration tasks | ||
| ansible.builtin.import_tasks: tasks/configure.yml | ||
|
|
||
| - name: Import claiming tasks | ||
| ansible.builtin.import_tasks: tasks/claim.yml | ||
|
|
||
| handlers: | ||
| - name: Restart Netdata | ||
| ansible.builtin.service: | ||
| name: netdata | ||
| state: restarted |
51 changes: 8 additions & 43 deletions
51
configuration-management/ansible-quickstart/tasks/claim.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,10 @@ | ||
| --- | ||
| - name: Claim the node to Netdata Cloud | ||
| hosts: all | ||
| vars_files: | ||
| - "../vars/main.yml" | ||
| # Claiming is now handled directly in the install.yml using kickstart script | ||
| # This file is kept for compatibility but may be removed in future versions | ||
|
|
||
| - name: Verify Netdata service is running | ||
| ansible.builtin.systemd: | ||
| name: netdata | ||
| state: started | ||
| enabled: true | ||
| become: true | ||
| become_method: sudo | ||
|
|
||
| tasks: | ||
| - name: Claim to Netdata Cloud | ||
| block: | ||
|
|
||
| - name: Claim to Netdata Cloud if not already | ||
| shell: | ||
| cmd: netdata-claim.sh -token={{ claim_token }} -rooms={{ claim_rooms }} -url={{ claim_url }} | ||
| creates: /var/lib/netdata/cloud.d/claimed_id | ||
| become: yes | ||
|
|
||
| when: reclaim == false | ||
|
|
||
| - name: Re-claim a node to Netdata Cloud | ||
| block: | ||
|
|
||
| - name: Ensure `uuidgen` is installed | ||
| stat: | ||
| path: /usr/bin/uuidgen | ||
| register: uuidgen_result | ||
|
|
||
| - name: Fail if `uuidgen` is not installed | ||
| fail: | ||
| msg: The system needs `uuidgen` installed to enable re-claiming. | ||
| when: uuidgen_result.stat.exists == false | ||
|
|
||
| - name: Reclaim the node with `-id=` | ||
| shell: netdata-claim.sh -token={{ claim_token }} -rooms={{ claim_rooms }} -url={{ claim_url }} -id=$(uuidgen) | ||
| when: uuidgen_result.stat.exists == true | ||
| notify: Restart Netdata | ||
| become: yes | ||
| when: reclaim == true | ||
|
|
||
| handlers: | ||
| - name: Restart Netdata | ||
| service: | ||
| name: netdata | ||
| state: restarted |
29 changes: 8 additions & 21 deletions
29
configuration-management/ansible-quickstart/tasks/configure.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,10 @@ | ||
| --- | ||
| - name: Configure Netdata | ||
| hosts: all | ||
| vars_files: | ||
| - "../vars/main.yml" | ||
| - name: Configure Netdata with template | ||
| ansible.builtin.template: | ||
| src: "{{ playbook_dir }}/templates/netdata.conf.j2" | ||
| dest: /etc/netdata/netdata.conf | ||
| owner: root | ||
| group: root | ||
| mode: '0755' | ||
| become: true | ||
| become_method: sudo | ||
|
|
||
| tasks: | ||
| - template: | ||
| src: ../templates/netdata.conf.j2 | ||
| dest: /etc/netdata/netdata.conf | ||
| owner: root | ||
| group: root | ||
| mode: u=wrx,g=rx,o=r,+x | ||
| notify: Restart Netdata | ||
| become: true | ||
|
|
||
| handlers: | ||
| - name: Restart Netdata | ||
| service: | ||
| name: netdata | ||
| state: restarted | ||
| notify: Restart Netdata | ||
64 changes: 47 additions & 17 deletions
64
configuration-management/ansible-quickstart/tasks/install.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,52 @@ | ||
| --- | ||
| - name: Install Netdata | ||
| hosts: all | ||
| vars_files: | ||
| - "../vars/main.yml" | ||
| - name: Download the Netdata kickstart script | ||
| ansible.builtin.get_url: | ||
| url: https://get.netdata.cloud/kickstart.sh | ||
| dest: /tmp/netdata-kickstart.sh | ||
| mode: +x | ||
|
|
||
| - name: Check if Netdata is already installed | ||
| ansible.builtin.stat: | ||
| path: /usr/sbin/netdata | ||
| register: netdata_installed | ||
| when: reclaim | ||
|
|
||
| - name: Install and claim Netdata (new installation) | ||
| ansible.builtin.command: > | ||
| /tmp/netdata-kickstart.sh | ||
| {% if netdata_channel == 'stable' %}--stable-channel{% endif %} | ||
| {% if netdata_channel == 'nightly' %}--nightly-channel{% endif %} | ||
| --non-interactive | ||
| {% if not netdata_auto_updates %}--no-updates{% endif %} | ||
| --claim-token {{ claim_token }} | ||
| --claim-rooms {{ claim_rooms }} | ||
| --claim-url {{ claim_url }} | ||
| when: not reclaim or (reclaim and not netdata_installed.stat.exists) | ||
| changed_when: true | ||
| become: true | ||
| become_method: sudo | ||
|
|
||
| tasks: | ||
| - name: Download the installation script | ||
| get_url: | ||
| url: https://my-netdata.io/kickstart.sh | ||
| dest: ~/kickstart.sh | ||
| mode: +x | ||
| - name: Uninstall existing Netdata (for clean reclaim) | ||
| ansible.builtin.command: /tmp/netdata-kickstart.sh --uninstall --non-interactive | ||
| when: reclaim and netdata_installed.stat.exists | ||
| changed_when: true | ||
| become: true | ||
| failed_when: false | ||
|
|
||
| - name: Install Netdata | ||
| command: ~/kickstart.sh --dont-wait | ||
| - name: Fresh install and claim Netdata (after uninstall) | ||
| ansible.builtin.command: > | ||
| /tmp/netdata-kickstart.sh | ||
| {% if netdata_channel == 'stable' %}--stable-channel{% endif %} | ||
| {% if netdata_channel == 'nightly' %}--nightly-channel{% endif %} | ||
| --non-interactive | ||
| {% if not netdata_auto_updates %}--no-updates{% endif %} | ||
| --claim-token {{ claim_token }} | ||
| --claim-rooms {{ claim_rooms }} | ||
| --claim-url {{ claim_url }} | ||
| when: reclaim and netdata_installed.stat.exists | ||
| changed_when: true | ||
| become: true | ||
|
|
||
| - name: Cleanup installation script | ||
| file: | ||
| path: ~/kickstart.sh | ||
| state: absent | ||
| - name: Cleanup installation script | ||
| ansible.builtin.file: | ||
| path: /tmp/netdata-kickstart.sh | ||
| state: absent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| --- | ||
| # Tasks file for Netdata | ||
|
|
||
| - import_playbook: install.yml | ||
| - name: Import installation tasks | ||
| ansible.builtin.import_tasks: install.yml | ||
|
|
||
| - import_playbook: configure.yml | ||
| - name: Import configuration tasks | ||
| ansible.builtin.import_tasks: configure.yml | ||
|
|
||
| - import_playbook: claim.yml | ||
| - name: Import claiming tasks | ||
| ansible.builtin.import_tasks: claim.yml |
4 changes: 2 additions & 2 deletions
4
configuration-management/ansible-quickstart/templates/netdata.conf.j2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.