From 0261e875679f1bf63c8d689da7fc7e014597885d Mon Sep 17 00:00:00 2001 From: Stonewall Jackson Date: Sat, 4 Feb 2023 01:23:43 -0500 Subject: initial commit --- roles/nagios_client/tasks/main.yml | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 roles/nagios_client/tasks/main.yml (limited to 'roles/nagios_client/tasks') diff --git a/roles/nagios_client/tasks/main.yml b/roles/nagios_client/tasks/main.yml new file mode 100644 index 0000000..44424ab --- /dev/null +++ b/roles/nagios_client/tasks/main.yml @@ -0,0 +1,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 -- cgit