aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.yamllint33
-rw-r--r--README.md38
-rw-r--r--defaults/main.yml29
-rw-r--r--handlers/main.yml6
-rw-r--r--meta/main.yml58
-rw-r--r--molecule/default/INSTALL.rst15
-rw-r--r--molecule/default/converge.yml7
-rw-r--r--molecule/default/molecule.yml27
-rw-r--r--molecule/default/prepare.yml8
-rw-r--r--molecule/default/verify.yml10
-rw-r--r--tasks/main.yml67
-rw-r--r--tasks/uninstall.yml13
-rw-r--r--templates/health_alarm_notify.conf.j29
-rw-r--r--templates/netdata.conf.j26
-rw-r--r--templates/stream.conf.j215
-rw-r--r--tests/inventory2
-rw-r--r--tests/test.yml5
-rw-r--r--vars/main.yml2
18 files changed, 350 insertions, 0 deletions
diff --git a/.yamllint b/.yamllint
new file mode 100644
index 0000000..8827676
--- /dev/null
+++ b/.yamllint
@@ -0,0 +1,33 @@
1---
2# Based on ansible-lint config
3extends: default
4
5rules:
6 braces:
7 max-spaces-inside: 1
8 level: error
9 brackets:
10 max-spaces-inside: 1
11 level: error
12 colons:
13 max-spaces-after: -1
14 level: error
15 commas:
16 max-spaces-after: -1
17 level: error
18 comments: disable
19 comments-indentation: disable
20 document-start: disable
21 empty-lines:
22 max: 3
23 level: error
24 hyphens:
25 level: error
26 indentation: disable
27 key-duplicates: enable
28 line-length: disable
29 new-line-at-end-of-file: disable
30 new-lines:
31 type: unix
32 trailing-spaces: disable
33 truthy: disable
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..d4a2e18
--- /dev/null
+++ b/README.md
@@ -0,0 +1,38 @@
1Netdata\_straight
2=========
3
4A pretty straightforward role to install netdata using curl | bash install
5
6Requirements
7------------
8
9None
10
11Role Variables
12--------------
13
14See [defaults/main.yml]
15
16Dependencies
17------------
18
19None
20
21Example Playbook
22----------------
23
24```
25 - hosts: servers
26 roles:
27 - { role: ansible_straight, netdata_installer: kickstart-static64 }
28```
29
30License
31-------
32
33BSD
34
35Author Information
36------------------
37
38Fretlink
diff --git a/defaults/main.yml b/defaults/main.yml
new file mode 100644
index 0000000..822acf6
--- /dev/null
+++ b/defaults/main.yml
@@ -0,0 +1,29 @@
1---
2# Force installation even if netdata is already installed
3netdata_force_install: false
4netdata_installer: kickstart
5netdata_install_options: "--disable-telemetry"
6netdata_uninstall_before: no
7netdata_prefix: "{{ (netdata_installer == 'kickstart') | ternary('','/opt/netdata') }}"
8# A dict whcih reflect the wanted netdata.conf file
9netdata_config:
10 global:
11 history: 3996
12
13 web:
14 "listen to": 127.0.0.1
15
16# Define streaming configuration
17#netdata_streaming_configuration: {}
18netdata_streaming_configuration:
19 upstream:
20 destination: collector.example.com
21 "api key": XXXXXXX
22 downstreams:
23 - name: main
24 api_key: XXXXXXY
25
26# Define alarm notify configuration
27netdata_alarm_notify_configs: {}
28# Define a custom_sender function to be used in alarm configuration
29netdata_custom_sender_function: ""
diff --git a/handlers/main.yml b/handlers/main.yml
new file mode 100644
index 0000000..33291a6
--- /dev/null
+++ b/handlers/main.yml
@@ -0,0 +1,6 @@
1---
2# handlers file for netdata-straight
3- name: restart netdata
4 service:
5 name: netdata
6 state: restarted
diff --git a/meta/main.yml b/meta/main.yml
new file mode 100644
index 0000000..4edfb50
--- /dev/null
+++ b/meta/main.yml
@@ -0,0 +1,58 @@
1galaxy_info:
2 role_name: netdata_straight
3 author: fretlink
4 description: A role to install netdata using kickstart installer
5 company: Fretlink
6
7 # If the issue tracker for your role is not on github, uncomment the
8 # next line and provide a value
9 # issue_tracker_url: http://example.com/issue/tracker
10
11 # Choose a valid license ID from https://spdx.org - some suggested licenses:
12 # - BSD-3-Clause (default)
13 # - MIT
14 # - GPL-2.0-or-later
15 # - GPL-3.0-only
16 # - Apache-2.0
17 # - CC-BY-4.0
18 license: BSD-3-Clause
19
20 min_ansible_version: 2.8
21
22 # If this a Container Enabled role, provide the minimum Ansible Container version.
23 # min_ansible_container_version:
24
25 #
26 # Provide a list of supported platforms, and for each platform a list of versions.
27 # If you don't wish to enumerate all versions for a particular platform, use 'all'.
28 # To view available platforms and versions (or releases), visit:
29 # https://galaxy.ansible.com/api/v1/platforms/
30 #
31 # platforms:
32 # - name: Fedora
33 # versions:
34 # - all
35 # - 25
36 # - name: SomePlatform
37 # versions:
38 # - all
39 # - 1.0
40 # - 7
41 # - 99.99
42 platforms:
43 - name: Ubuntu
44 versions:
45 - 18.04
46 - 20.04
47
48 galaxy_tags: []
49 # List tags for your role here, one per line. A tag is a keyword that describes
50 # and categorizes the role. Users find roles by searching for tags. Be sure to
51 # remove the '[]' above, if you add tags to this list.
52 #
53 # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
54 # Maximum 20 tags per role.
55
56dependencies: []
57 # List your role dependencies here, one per line. Be sure to remove the '[]' above,
58 # if you add dependencies to this list.
diff --git a/molecule/default/INSTALL.rst b/molecule/default/INSTALL.rst
new file mode 100644
index 0000000..c615318
--- /dev/null
+++ b/molecule/default/INSTALL.rst
@@ -0,0 +1,15 @@
1*******
2Delegated driver installation guide
3*******
4
5Requirements
6============
7
8This driver is delegated to the developer. Up to the developer to implement
9requirements.
10
11Install
12=======
13
14This driver is delegated to the developer. Up to the developer to implement
15requirements.
diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml
new file mode 100644
index 0000000..20810f0
--- /dev/null
+++ b/molecule/default/converge.yml
@@ -0,0 +1,7 @@
1---
2- name: Converge
3 hosts: all
4 tasks:
5 - name: "Include netdata-straight"
6 include_role:
7 name: "netdata_straight"
diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml
new file mode 100644
index 0000000..82a338d
--- /dev/null
+++ b/molecule/default/molecule.yml
@@ -0,0 +1,27 @@
1---
2dependency:
3 name: galaxy
4driver:
5 name: docker
6lint: |
7 set -e
8 yamllint .
9 ansible-lint
10 flake8
11platforms:
12 - name: instance
13 image: jrei/systemd-${MOLECULE_OS:-ubuntu:20.04}
14 privileged: true
15 command: /lib/systemd/systemd
16 tmpfs:
17 - /run
18 volumes:
19 - /sys/fs/cgroup:/sys/fs/cgroup:ro
20provisioner:
21 name: ansible
22 inventory:
23 host_vars:
24 instance:
25 netdata_installer: ${MOLECULE_NETDATA_INSTALLER:-kickstart}
26verifier:
27 name: ansible
diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml
new file mode 100644
index 0000000..99ab4e9
--- /dev/null
+++ b/molecule/default/prepare.yml
@@ -0,0 +1,8 @@
1- name: Prepare
2 hosts: all
3 tasks:
4 - name: Update apt cache
5 apt:
6 update_cache: yes
7 become: true
8 when: ansible_os_family == 'Debian'
diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml
new file mode 100644
index 0000000..79044cd
--- /dev/null
+++ b/molecule/default/verify.yml
@@ -0,0 +1,10 @@
1---
2# This is an example playbook to execute Ansible tests.
3
4- name: Verify
5 hosts: all
6 gather_facts: false
7 tasks:
8 - name: Example assertion
9 assert:
10 that: true
diff --git a/tasks/main.yml b/tasks/main.yml
new file mode 100644
index 0000000..ca849a3
--- /dev/null
+++ b/tasks/main.yml
@@ -0,0 +1,67 @@
1---
2- name: Install requirements (Debian family)
3 apt:
4 name: curl
5 state: present
6 when: ansible_os_family == 'Debian'
7
8- name: Install requirements (Redhat family)
9 yum:
10 name: curl
11 state: present
12 when: ansible_os_family == 'RedHat'
13
14- name: Check if netdata is installed
15 command: "{{ prefix }}netdata -V"
16 ignore_errors: true
17 register: netdata_installed_st
18 changed_when: false
19 vars:
20 prefix: "{{ netdata_prefix | ternary(netdata_prefix~'/bin/', '') }}"
21
22- name: Uninstall netdata
23 include: uninstall.yml
24 when:
25 - netdata_uninstall_before is defined
26 - netdata_uninstall_before | bool
27
28- name: Install netdata
29 shell:
30 cmd: bash <(curl -Ss https://my-netdata.io/{{ netdata_installer }}.sh) --dont-wait {{ netdata_install_options }}
31 args:
32 executable: /bin/bash
33 when:
34 - netdata_installed_st is failed or netdata_force_install or netdata_uninstall_before
35
36- name: Configure netdata
37 template:
38 src: netdata.conf.j2
39 dest: "{{ netdata_prefix }}/etc/netdata/netdata.conf"
40 owner: root
41 group: root
42 mode: 0644
43 notify: restart netdata
44
45- name: Configure streaming
46 template:
47 src: stream.conf.j2
48 dest: "{{ netdata_prefix }}/etc/netdata/stream.conf"
49 owner: root
50 group: netdata
51 mode: 0640
52 when:
53 - netdata_streaming_configuration is defined
54 - netdata_streaming_configuration | count > 0
55 notify: restart netdata
56
57- name: Configure netdata alarm notifications
58 template:
59 dest: "{{ netdata_prefix }}/etc/netdata/health_alarm_notify.conf"
60 src: "health_alarm_notify.conf.j2"
61 owner: netdata
62 group: root
63 mode: 0640
64 when:
65 - netdata_alarm_notify_configs is defined
66 - netdata_alarm_notify_configs | count > 0
67 notify: restart netdata
diff --git a/tasks/uninstall.yml b/tasks/uninstall.yml
new file mode 100644
index 0000000..1b2c4b9
--- /dev/null
+++ b/tasks/uninstall.yml
@@ -0,0 +1,13 @@
1- name: Check uninstaller presence
2 stat:
3 path: "{{ item }}/netdata-uninstaller.sh"
4 loop:
5 - /usr/libexec/netdata
6 - /opt/netdata/usr/libexec/netdata
7 register: uninstaller_presence
8
9- name: Uninstall
10 command: "{{ item }} --yes --force" # noqa 301
11 loop: "{{ uninstallers }}"
12 vars:
13 uninstallers: "{{ uninstaller_presence.results | selectattr('stat.exists') | map(attribute='invocation.module_args.path') | list }}"
diff --git a/templates/health_alarm_notify.conf.j2 b/templates/health_alarm_notify.conf.j2
new file mode 100644
index 0000000..6623d79
--- /dev/null
+++ b/templates/health_alarm_notify.conf.j2
@@ -0,0 +1,9 @@
1{% for key in netdata_alarm_notify_configs %}
2{{ key }}="{{ netdata_alarm_notify_configs[key] }}"
3{% endfor %}
4
5{% if netdata_custom_sender_function is defined %}
6custom_sender() {
7{{ netdata_custom_sender_function }}
8}
9{% endif %}
diff --git a/templates/netdata.conf.j2 b/templates/netdata.conf.j2
new file mode 100644
index 0000000..d22ed37
--- /dev/null
+++ b/templates/netdata.conf.j2
@@ -0,0 +1,6 @@
1{% for (section,configuration) in netdata_config | dictsort %}
2[{{ section }}]
3{% for (key,value) in configuration | dictsort %}
4 {{ key }} = {{ value }}
5{% endfor %}
6{% endfor %}
diff --git a/templates/stream.conf.j2 b/templates/stream.conf.j2
new file mode 100644
index 0000000..f1fb02d
--- /dev/null
+++ b/templates/stream.conf.j2
@@ -0,0 +1,15 @@
1{% if netdata_streaming_configuration.upstream is defined %}
2[stream]
3 enabled = yes
4 destination = {{ netdata_streaming_configuration.upstream["destination"] }}
5 api key = {{ netdata_streaming_configuration.upstream["api key"] }}
6{% endif %}
7{% if netdata_streaming_configuration.downstreams is defined %}
8{% for downstream in netdata_streaming_configuration.downstreams %}
9[{{ downstream.api_key }}]
10 enabled = yes
11{% for (key,value) in downstream | dictsort if not key in ['name','api_key'] %}
12 {{ key }} = {{ value }}
13{% endfor %}
14{% endfor %}
15{% endif %}
diff --git a/tests/inventory b/tests/inventory
new file mode 100644
index 0000000..878877b
--- /dev/null
+++ b/tests/inventory
@@ -0,0 +1,2 @@
1localhost
2
diff --git a/tests/test.yml b/tests/test.yml
new file mode 100644
index 0000000..72866b0
--- /dev/null
+++ b/tests/test.yml
@@ -0,0 +1,5 @@
1---
2- hosts: localhost
3 remote_user: root
4 roles:
5 - netdata-straight \ No newline at end of file
diff --git a/vars/main.yml b/vars/main.yml
new file mode 100644
index 0000000..938a3e3
--- /dev/null
+++ b/vars/main.yml
@@ -0,0 +1,2 @@
1---
2# vars file for netdata-straight \ No newline at end of file