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:
-
paths:
- /var/log/redis/redis.log
- /var/log/redis/sentinel.log
- /var/log/php-fpm/error.log
I will really appreciate some help over here. Which of the modules are
most recommended in this case? Code examples? etc.
Here is what i've done so far, which contain the installation part only.
- name: Install filebeat
gather_facts: False
remote_user: myUser
become: yes
vars:
elasticsearch_repo_base_url:
"https://packages.elastic.co/beats/yum/el/$basearch"
elasticsearch_repo_gpg_key_url:
"http://packages.elastic.co/GPG-KEY-elasticsearch"
tasks:
- name: Importing Elasticsearch public GPG key
rpm_key:
key: "{{ elasticsearch_repo_url }}"
state: present
- name: Add repository for filebeat
yum_repository:
name: Elastic Beats Repository
description: Elastic Beats Repository
baseurl: "{{ elasticsearch_repo_base_url }}"
gpgkey: "{{ elasticsearch_repo_gpg_key_url }}"
gpgcheck: yes
- name: Install filebeat
yum:
name: filebeat
state: latest
- name: Enabling filebeat service on boot and starting
service:
name: filebeat
state: restarted
enabled: yes
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1825bafc-00c7-4d39-af64-c093cd941a47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.