- hosts: datacenter name: Install zabbix agent become: true tasks: - name: Print all available facts ansible.builtin.debug: var: ansible_facts # - name: Upload zabbix package # ansible.builtin.copy: # src: packages/zabbix-release_6.4-1+ubuntu22.04_all.deb # dest: /tmp/ - name: Install a .deb package from the internet ansible.builtin.apt: deb: https://repo.zabbix.com/zabbix/6.4/ubuntu-arm64/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb # - name: Install a .deb package localy # ansible.builtin.apt: # deb: /tmp/zabbix-release_6.4-1+ubuntu22.04_all.deb - name: Install zabbix packages ansible.builtin.apt: name: - zabbix-agent2 - zabbix-agent2-plugin-* update_cache: yes - name: Reconfigure zabbix agent Server ansible.builtin.lineinfile: path: /etc/zabbix/zabbix_agent2.conf regexp: "^Server=.*" insertafter: '^# Server=' line: "Server=192.168.77.106" - name: Reconfigure zabbix agent ServerActive ansible.builtin.lineinfile: path: /etc/zabbix/zabbix_agent2.conf regexp: "^ServerActive=.*" line: "ServerActive=192.168.77.106" - name: Reconfigure zabbix agent ListenPort ansible.builtin.lineinfile: path: /etc/zabbix/zabbix_agent2.conf regexp: "^ListenPort=.*" line: "ListenPort=10050" # - name: Reconfigure zabbix agent ListenIP # ansible.builtin.lineinfile: # path: /etc/zabbix/zabbix_agent2.conf # regexp: "^ListenIP=.*" # line: "ListenIP=0.0.0.0" - name: Reconfigure zabbix-agent2 hostname ansible.builtin.lineinfile: path: /etc/zabbix/zabbix_agent2.conf regexp: "^Hostname=.*" line: "Hostname={{ansible_hostname}}" - name: Restart zabbix-agent2 service ansible.builtin.service: name: zabbix-agent2.service state: restarted enabled: true