diff --git a/roles/nginx/files/netdata_httpcheck.conf b/roles/nginx/files/netdata_httpcheck.conf new file mode 100644 index 0000000..6487637 --- /dev/null +++ b/roles/nginx/files/netdata_httpcheck.conf @@ -0,0 +1,4 @@ +jobs: + - name: local + url: https://127.0.0.1 + tls_skip_verify: yes diff --git a/roles/nginx/files/netdata_nginx.conf b/roles/nginx/files/netdata_nginx.conf new file mode 100644 index 0000000..b0071bc --- /dev/null +++ b/roles/nginx/files/netdata_nginx.conf @@ -0,0 +1,4 @@ +jobs: + - name: local + url: https://127.0.0.1/stub_status + tls_skip_verify: yes diff --git a/roles/nginx/tasks/main.yml b/roles/nginx/tasks/main.yml index 67eb77e..ee19096 100644 --- a/roles/nginx/tasks/main.yml +++ b/roles/nginx/tasks/main.yml @@ -102,6 +102,10 @@ - name: Firewall configuration ansible.builtin.include_tasks: firewall.yml +- name: Netdata configuration + ansible.builtin.include_tasks: netdata.yml + when: common_netdata_enable | bool + - name: Ensure Nginx "rpmnew" and "rpmsave" files are absent ansible.builtin.file: path: "{{ item }}" diff --git a/roles/nginx/tasks/netdata.yml b/roles/nginx/tasks/netdata.yml new file mode 100644 index 0000000..b37d0c7 --- /dev/null +++ b/roles/nginx/tasks/netdata.yml @@ -0,0 +1,22 @@ +--- + +- name: Ensure Netdata configuration directory is present + ansible.builtin.file: + path: /etc/netdata/go.d + state: directory + mode: '0755' + +- name: Ensure Netdata collectors are configured + ansible.builtin.copy: + src: "netdata_{{ item }}.conf" + dest: "/etc/netdata/go.d/{{ item }}.conf" + mode: '0644' + with_items: + - nginx + - httpcheck + +- name: Ensure Systemd Netdata service is restarted + ansible.builtin.systemd: + name: netdata + state: restarted + changed_when: false diff --git a/roles/nginx/templates/nginx-site.conf.j2 b/roles/nginx/templates/nginx-site.conf.j2 index 58bce7c..c5285f9 100644 --- a/roles/nginx/templates/nginx-site.conf.j2 +++ b/roles/nginx/templates/nginx-site.conf.j2 @@ -64,6 +64,16 @@ server { # replace with the IP address of your resolver resolver {{ nginx_resolver }}; + {% if common_netdata_enable is defined -%} + # Local status page for monitoring + location = /stub_status { + stub_status on; + access_log off; + allow 127.0.0.1; + deny all; + } + {%- endif %} + # Starting Extra security configuration # =====================================