# File beat installation and configuration with Ansible

**URL:** <https://forum.ansible.com/t/file-beat-installation-and-configuration-with-ansible/24900>\
**Category:** Ansible Project\
**Created:** [July 5, 2017, 1:01pm UTC](https://forum.ansible.com/t/file-beat-installation-and-configuration-with-ansible/24900 "2017-07-05T13:01:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Omri](https://avatars.discourse-cdn.com/v4/letter/o/bc79bd/32.png) [@Omri](https://forum.ansible.com/u/Omri)\
**Post date:** [July 5, 2017, 1:01pm UTC](https://forum.ansible.com/t/file-beat-installation-and-configuration-with-ansible/24900/1 "2017-07-05T13:01:57Z")

</div>

Hello,  
I’m writing an Ansible script that install and configure filebeat (agent of logstash).

I’ve finished the installation part. Now i need to add the configuration part to the script. I pretty new with Ansible and i need some help.

The user that suppose to run the script will have to select a few groups from a list, and each group from the list contains a few logs paths, which need to be added to the filebeat configuration file.

For example:  
Groups to select foe example: redis, nginx, php-fpm

Redis logs:

/var/log/redis/redis.log  
/var/log/redis/sentinel.log

Nginx logs:  
/var/log/nginx/access.log

/var/log/nginx/error.log

php-fpm logs:  
/var/log/php-fpm/error.log

If the user will select redis and php-fpm, these logs will be added to filebeat configuration file (on the remote host), which located on /etc/filebeat/filebeat.yml, under paths section:

`  
filebeat:  
prospectors:

---

<div class="post-metadata">

**Author:** ![Sergey\_Baranov](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@Sergey\_Baranov](https://forum.ansible.com/u/Sergey_Baranov)\
**Post date:** [July 6, 2017, 6:26pm UTC](https://forum.ansible.com/t/file-beat-installation-and-configuration-with-ansible/24900/2 "2017-07-06T18:26:40Z")

</div>

Here is my example. I am using hash\_behaviour = merge.

Layout:  
`  
├── group\_vars  
│ ├── php-fpm  
│ └── nginx  
├── roles  
│ └── filebeat  
│ ├── defaults  
│ │ └── main.yml  
│ ├── handlers  
│ │ └── main.yml  
│ ├── meta  
│ │ └── main.yml  
│ ├── README.md  
│ ├── tasks  
│ │ ├── configure.yml  
│ │ ├── install.yml  
│ │ ├── main.yml  
│ │ ├── prepare.yml  
│ │ ├── redhat  
│ │ │ ├── install.yml  
│ │ │ └── prepare.yml  
│ │ └── debian  
│ │ ├── install.yml  
│ │ └── prepare.yml  
│ ├── templates  
│ │ └── filebeat.yml.j2  
│ └── vars

> ├── debian.yml  
> │ └── redhat.yml  
> ├── filebeat.yml  
> └── inventory

`

templates/filebeat.yml.j2:

`  
{{ ansible\_managed}}  
{{ filebeat.options | to\_nice\_yaml }}

`

tasks/configure.yml:

`
