# Install wazuh agent deb file for linux target hosts

**URL:** <https://forum.ansible.com/t/install-wazuh-agent-deb-file-for-linux-target-hosts/38101>\
**Category:** Ansible Project\
**Created:** [June 14, 2023, 10:35am UTC](https://forum.ansible.com/t/install-wazuh-agent-deb-file-for-linux-target-hosts/38101 "2023-06-14T10:35:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![malek\_sakir](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@malek\_sakir](https://forum.ansible.com/u/malek_sakir)\
**Post date:** [June 14, 2023, 10:35am UTC](https://forum.ansible.com/t/install-wazuh-agent-deb-file-for-linux-target-hosts/38101/1 "2023-06-14T10:35:43Z")

</div>

any one help me to write playbook for wazuh agent(.deb file) installation in linux target hosts.

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [June 14, 2023, 11:59am UTC](https://forum.ansible.com/t/install-wazuh-agent-deb-file-for-linux-target-hosts/38101/2 "2023-06-14T11:59:48Z")

</div>

[https://docs.ansible.com/ansible/latest/playbook\_guide/playbooks\_intro.html#playbook-syntax](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_intro.html#playbook-syntax)  
[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html)

---

<div class="post-metadata">

**Author:** ![khawaja\_Ali](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@khawaja\_Ali](https://forum.ansible.com/u/khawaja_Ali)\
**Post date:** [June 14, 2023, 1:18pm UTC](https://forum.ansible.com/t/install-wazuh-agent-deb-file-for-linux-target-hosts/38101/3 "2023-06-14T13:18:54Z")

</div>

I have not tested it, check it yourself. Ali

---

<div class="post-metadata">

**Author:** ![khawaja\_Ali](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@khawaja\_Ali](https://forum.ansible.com/u/khawaja_Ali)\
**Post date:** [June 14, 2023, 1:21pm UTC](https://forum.ansible.com/t/install-wazuh-agent-deb-file-for-linux-target-hosts/38101/4 "2023-06-14T13:21:01Z")

</div>

correction  
---- name: Install Wazuh agent  
hosts:   
become: yes

tasks:

- name: Add Wazuh repository key  
apt\_key:  
url: [https://packages.wazuh.com/key/GPG-KEY-WAZUH](https://packages.wazuh.com/key/GPG-KEY-WAZUH)  
state: present

- name: Add Wazuh repository  
apt\_repository:  
repo: “deb [https://packages.wazuh.com/4.x/apt/](https://packages.wazuh.com/4.x/apt/) stable main”  
state: present

- name: Update apt cache  
apt:  
update\_cache: yes

- name: Install Wazuh agent  
apt:  
name: wazuh-agent  
state: present

- name: Configure Wazuh agent  
copy:  
src: /path/to/wazuh-agent.conf  
dest: /var/ossec/etc/shared/wazuh-agent.conf  
owner: root  
group: ossec  
mode: ‘0640’  
notify:

- restart wazuh-agent

handlers:

- name: restart wazuh-agent  
service:  
name: wazuh-agent  
state: restarted

![](https://ssl.gstatic.com/ui/v1/icons/mail/images/cleardot.gif)
