diff --git a/roles/zabbix-cli/tasks/main.yml b/roles/zabbix-cli/tasks/main.yml index 9a30729..2ae6bb5 100644 --- a/roles/zabbix-cli/tasks/main.yml +++ b/roles/zabbix-cli/tasks/main.yml @@ -23,15 +23,14 @@ state: restarted enabled: yes - - name: config - template: - src: zabbix_agentd.conf.temp - dest: /etc/zabbix/zabbix_agentd.conf - vars: - PidFile: "/run/zabbix/zabbix_agentd.pid" - LogFile: "/var/log/zabbix/zabbix_agentd.log" - LogFileSize: "0" - Server: "127.0.0.1" - ServerActive: "192.168.99.8" - Hostname: "{{ ansible_hostname }}" - Include: "/etc/zabbix/zabbix_agentd.d/*.conf" + - name: Replace Zabbix agent config + replace: + path: /etc/zabbix/zabbix_agentd.conf + regexp: '{{ item.regexp }}' + replace: '{{ item.replace }}' + backup: true + loop: + - { regexp: '^(Server\s*=\s*).*$', replace: 'Server = 127.0.0.1' } + - { regexp: '^(ServerActive\s*=\s*).*$', replace: 'ServerActive = 192.168.99.8' } + - { regexp: '^(Hostname\s*=\s*).*$', replace: 'Hostname = {{ ansible_hostname }}' } + - { regexp: '^(Include\s*=\s*).*$', replace: 'Include = /etc/zabbix/zabbix_agentd.d/*.conf' } diff --git a/roles/zabbix-cli/templates/zabbix_agentd.conf.temp b/roles/zabbix-cli/templates/zabbix_agentd.conf.temp deleted file mode 100644 index 9191ff5..0000000 --- a/roles/zabbix-cli/templates/zabbix_agentd.conf.temp +++ /dev/null @@ -1,7 +0,0 @@ -PidFile={{ PidFile }} -LogFile={{ LogFile }} -LogFileSize={{ LogFileSize }} -Server={{ Server }} -ServerActive={{ ServerActive }} -Hostname={{ Hostname }} -Include={{ Include }} diff --git a/s-itil.yml b/s-itil.yml index 2e2dbc7..4b1eb02 100644 --- a/s-itil.yml +++ b/s-itil.yml @@ -13,7 +13,7 @@ roles: - base - goss - #- zabbix-cli + - zabbix-cli - glpi - ssh-cli # - syslog-cli