diff --git a/roles/zabbix_proxy/defaults/main.yml b/roles/zabbix_proxy/defaults/main.yml index d6bad87..c19dba6 100644 --- a/roles/zabbix_proxy/defaults/main.yml +++ b/roles/zabbix_proxy/defaults/main.yml @@ -17,4 +17,10 @@ zabbix_proxy_cache_size: 32M # If update is set to False, the role will only ensure packages are installed # If set to True, it will update components to their latest version zabbix_proxy_update: False + +# You might want to ignore system proxy for Zabbix proxy itself, +# so its web monitoring can be direct +# This will only have an effect if system_proxy is defined +zabbix_proxy_uses_system_proxy: True + ... diff --git a/roles/zabbix_proxy/tasks/service.yml b/roles/zabbix_proxy/tasks/service.yml index f161430..a0951b6 100644 --- a/roles/zabbix_proxy/tasks/service.yml +++ b/roles/zabbix_proxy/tasks/service.yml @@ -1,5 +1,40 @@ --- +- name: Remove custom unit + file: path=/etc/systemd/system/zabbix-proxy.service state=absent + register: zabbix_proxy_custom_unit + notify: restart zabbix-proxy + tags: zabbix + +- name: Create unit snippet dir + file: path=/etc/systemd/system/zabbix-proxy.service.d state=directory + tags: zabbix + +- name: Customize systemd unit + copy: + content: | + [Service] + ExecReload=/usr/sbin/zabbix_proxy -R config_cache_reload + PrivateTmp=yes + PrivateDevices=yes + ProtectSystem=full + ProtectHome=yes + {% if not zabbix_proxy_uses_system_proxy %} + # Disable system proxy + {% for proto in ['http_proxy','https_proxy','HTTP_PROXY','HTTPS_PROXY'] %} + Environment={{ proto }}= + {% endfor %} + {% endif %} + dest: /etc/systemd/system/zabbix-proxy.service.d/99-ansible.conf + register: zabbix_proxy_snippet_unit + notify: restart zabbix-proxy + tags: zabbix + +- name: Reload systemd + systemd: daemon_reload=True + when: zabbix_proxy_custom_unit.changed or zabbix_proxy_snippet_unit.changed + tags: zabbix + - name: Start and enable the service service: name=zabbix-proxy state=started enabled=True register: zabbix_proxy_started diff --git a/roles/zabbix_server/defaults/main.yml b/roles/zabbix_server/defaults/main.yml index ba83c20..6d6b269 100644 --- a/roles/zabbix_server/defaults/main.yml +++ b/roles/zabbix_server/defaults/main.yml @@ -55,3 +55,8 @@ zabbix_server_auth_http: False # pre-backup will skip history tables from the dump. Except if called with # pre-backup full zabbix_server_backup_on_full_only: False + +# You might want to ignore system proxy for Zabbix server itself, +# so its web monitoring can be direct +# This will only have an effect if system_proxy is defined +zabbix_server_uses_system_proxy: True diff --git a/roles/zabbix_server/tasks/service.yml b/roles/zabbix_server/tasks/service.yml index 861c680..a9c0152 100644 --- a/roles/zabbix_server/tasks/service.yml +++ b/roles/zabbix_server/tasks/service.yml @@ -1,5 +1,40 @@ --- +- name: Remove custom unit + file: path=/etc/systemd/system/zabbix-server.service state=absent + register: zabbix_server_custom_unit + notify: restart zabbix-server + tags: zabbix + +- name: Create unit snippet dir + file: path=/etc/systemd/system/zabbix-server.service.d state=directory + tags: zabbix + +- name: Customize systemd unit + copy: + content: | + [Service] + ExecReload=/usr/sbin/zabbix_server -R config_cache_reload + PrivateTmp=yes + PrivateDevices=yes + ProtectSystem=full + ProtectHome=yes + {% if not zabbix_server_uses_system_proxy %} + # Disable system proxy + {% for proto in ['http_proxy','https_proxy','HTTP_PROXY','HTTPS_PROXY'] %} + Environment={{ proto }}= + {% endfor %} + {% endif %} + dest: /etc/systemd/system/zabbix-server.service.d/99-ansible.conf + register: zabbix_server_snippet_unit + notify: restart zabbix-server + tags: zabbix + +- name: Reload systemd + systemd: daemon_reload=True + when: zabbix_server_custom_unit.changed or zabbix_server_snippet_unit.changed + tags: zabbix + - name: Start and enable the service service: name=zabbix-server state=started enabled=True register: zabbix_server_started