# ansible-playbook -i inventory agent.yaml -u centos --key-file=node.pem -b

#- hosts: {"{ hostvars[hostname].ansible_host }"}

---
- name: Gather client information
  hosts: "{{'hostname'}}"
  gather_facts: yes
  vars:
    ansible_python_interpreter: /usr/bin/python3
  tasks:
    - name: get zabbix package 
      get_url:
        url: https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix/zabbix-agent_6.4.0-1%2Bdebian11_amd64.deb
        dest: /tmp 

    - name: dpkg zabbix
      ansible.builtin.dpkg_selections:
        name: zabbix-release_6.0-3+ubuntu22.04_all.deb
        selection: install

    - name: update package index 
      ansible.builtin.apt:
        update_cache: yes
        
    # - name: Copy zabbix_agentd.conf file with owner and permissions
      # ansible.builtin.copy:
        # src: zabbix_agentd.conf
        # dest: /etc/zabbix/zabbix_agentd.conf    

    - name: install zabbix-agent #Zabbixエージェントをインストールします。
      ansible.builtin.apt:
        name:
          - zabbix-agent
        state: present