-
Notifications
You must be signed in to change notification settings - Fork 0
/
ossec-agent.yml
57 lines (57 loc) · 1.68 KB
/
ossec-agent.yml
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
---
- hosts: all:!ossim-server
remote_user: vagrant
become: yes
become_method: sudo
vars:
ossec_server: 192.168.33.10
package_inotify_tools: inotify-tools-3.13-2.el7.art.x86_64.rpm
package_ossec_hids: ossec-hids-2.9.1-1764.el7.art.x86_64.rpm
package_ossec_hids_agent: ossec-hids-agent-2.9.1-1764.el7.art.x86_64.rpm
tasks:
- name: Copy {{item}} rpm file to server
copy:
src: packages/{{item}}
dest: /tmp/{{item}}
with_items:
- "{{ package_inotify_tools }}"
- "{{ package_ossec_hids }}"
- "{{ package_ossec_hids_agent }}"
- name: install OSSEC Agent
yum:
name: /tmp/{{item}}
state: present
with_items:
- "{{ package_inotify_tools }}"
- "{{ package_ossec_hids }}"
- "{{ package_ossec_hids_agent }}"
- name: Copy systemd services file to server
copy:
src: systemd/{{item}}
dest: /lib/systemd/system/{{item}}
with_items:
- ossec-agent.target
- ossec-agentd.service
- ossec-execd.service
- ossec-logcollector.service
- ossec-syscheckd.service
- name: write the ossec-agent config file
template:
src: configs/ossec-agent.j2
dest: /var/ossec/etc/ossec-agent.conf
- name: "Check if client.keys exists"
stat: path=/var/ossec/etc/client.keys
register: check_keys
- name: Run the command for regis to OSSEC server
command: /var/ossec/bin/agent-auth -m {{ossec_server}} -p 1515
when: not check_keys.stat.exists
- name: ensure OSSEC Agent is running
service:
name: ossec-agentd
state: started
enabled: yes
handlers:
- name: restart ossec-agentd
service:
name: ossec-agentd
state: restarted