-
Notifications
You must be signed in to change notification settings - Fork 2
/
agent.yml
43 lines (43 loc) · 1.22 KB
/
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
---
- hosts: agent1,agent2
become: true
tasks:
- name: Copy files
ansible.builtin.copy:
src: "files/{{ item }}.sh"
dest: "~/{{ item }}"
mode: "0755"
with_items:
- "createdump"
- "deletedump"
- name: Add custom logging
ansible.builtin.copy:
src: "files/dump.conf"
dest: "/etc/rsyslog.d/dump.conf"
notify: restart rsyslog
- name: Add snmp commands
ansible.builtin.lineinfile:
dest: "/etc/snmp/snmpd.conf"
line: "{{ item.name }} {{ item.command }}"
regexp: "^{{ item.name }}"
with_items:
- {name: "extend createdump", command: "/usr/bin/sudo /root/createdump"}
- {name: "extend deletedump", command: "/usr/bin/sudo /root/deletedump"}
notify: restart snmpd
- name: Edit sudoers
ansible.builtin.lineinfile:
dest: "/etc/sudoers"
line: "Debian-snmp ALL=NOPASSWD:{{ item }}"
validate: '/usr/sbin/visudo -cf %s'
with_items:
- "/root/createdump"
- "/root/deletedump"
handlers:
- name: restart rsyslog
service:
name: rsyslog
state: restarted
- name: restart snmpd
service:
name: snmpd
state: restarted