aboutsummaryrefslogtreecommitdiffstats
path: root/roles/nagios_client/tasks/main.yml
blob: 44424ab84edf3651067d6f2f2fa68cd0c334a558 (plain)
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
- name: install packages
  dnf:
    name: '{{ nagios_packages }}'
    state: present

- name: add nagios ssh key
  authorized_key:
    user: nagios
    key: '{{ nagios_ssh_pubkey }}'
    state: present

- name: set selinux context for nagios .ssh directory
  sefcontext:
    target: '{{ nagios_home }}/\.ssh(/.*)?'
    setype: ssh_home_t
    state: present
  register: nagios_ssh_sefcontext
  tags: selinux

- name: apply selinux context to nagios .ssh directory
  command: 'restorecon -R {{ nagios_home }}/.ssh'
  when: nagios_ssh_sefcontext.changed
  tags: selinux

- name: set nagios shell
  user:
    name: nagios
    shell: /bin/bash

- name: set PATH for nagios user
  copy:
    content: export PATH=/sbin:/bin:/usr/sbin:/usr/bin:{{ nagios_plugin_dir }}
    dest: '{{ nagios_home }}/.bashrc'
    owner: nagios
    group: nagios
    mode: 0644

- name: copy custom nagios plugins
  copy:
    src: '{{ item.src }}'
    dest: '{{ nagios_plugin_dir }}/{{ item.path }}'
    mode: 0555
  loop: "{{ lookup('filetree', nagios_plugin_dir[1:], wantlist=True) }}"
  loop_control:
    label: '{{ item.path }}'
  when: item.state == 'file'
  tags: nagios_plugins

- name: generate sudo rules
  template:
    src: etc/sudoers.d/nagios.j2
    dest: /etc/sudoers.d/nagios
    mode: 0400
  tags: nagios_plugins