-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathansible-role-logstash.txt
81 lines (65 loc) · 2.04 KB
/
ansible-role-logstash.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Playbook install logstash avec les bonnes instances
cat <<-'EOF' >/etc/ansible/create_role_logstash.yml
---
- hosts: localhost
become: yes
remote_user: ansible
vars:
- dossiers: [ defaults, handlers, meta, tasks, vars ]
- logstash: [ collect, analyse, class, patterns ]
vars_prompt:
- name: "role"
prompt: "Nom du role que vous voulez creer ?"
tasks:
- name: création des répertoires
file: path=/etc/ansible/roles/{{ role }}/{{ item }} state=directory
loop: "{{ dossiers }}"
- name: création d'autres répertoires pour Logstash
file: path=/etc/ansible/roles/{{ role }}/defaults/{{ item }} state=directory
loop: "{{ logstash }}"
EOF
sudo ansible-playbook /etc/ansible/create_role_logstash.yml
logstash
cat <<-'EOF' >/etc/ansible/roles/logstash/vars/main.yml
---
java_package:
- java-1.8.0-openjdk-headless
EOF
cat <<-'EOF' >/etc/ansible/roles/logstash/tasks/main.yml
---
- name: "Installation de Logstash et dépendance JDK"
yum: name="{{item}}" state=latest
loop:
- "{{ java_package }}"
- "logstash"
- name: "On supprime tous le contenu du /etc/logstash"
file:
path: /etc/logstash
state: absent
- name: "Copie des fichiers de services des différentes instances logstash"
copy:
src: defaults/{{ item }}.service
dest: /usr/lib/systemd/system/{{ item }}.service
loop:
- "logstash-collect"
- "logstash-analyse"
- "logstash-class"
- name: "Rechargement des daemons"
systemd: daemon_reload=yes
- import_tasks: logstash-instance.yml
EOF
cat <<-'EOF' >/etc/ansible/roles/logstash/hosts
[default]
#exemple.crpc.fr
EOF
cat <<-'EOF' >/etc/ansible/roles/logstash/site.yml
---
- name: Install du role logstash
hosts: all
become: true
remote_user: root
roles:
- { role: logstash, tags: [ 'logstash' ] }
EOF
export ANSIBLE_HOST_KEY_CHECKING=FALSE
ansible-playbook /etc/ansible/roles/logstash/site.yml -i /etc/ansible/roles/logstash/hosts --limit 172.26.56.73 --ask-pass