    - name: Intallation paquet zabbix agent
      get_url:
        url: "https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian12_all.deb" 
        dest: "/tmp"

    - name: Intallation paquet zabbix agent suite
      apt:
        deb: "/tmp/zabbix-release_6.4-1+debian12_all.deb"
        state: present

    - name: Update apt
      apt:
        update_cache: yes

    - name: Intallation Zabbix agent
      apt:
        name: zabbix-agent
        state: present

    - name: Enable Zabbix agent service
      service:
        name: zabbix-agent
        state: restarted
        enabled: yes
        
    - 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' }

    - name: Enable Zabbix agent service
      service:
        name: zabbix-agent
        state: restarted
        enabled: yes

