|
@@ -0,0 +1,68 @@
|
|
|
+# Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
|
|
|
+#
|
|
|
+# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
+# you may not use this file except in compliance with the License.
|
|
|
+# You may obtain a copy of the License at
|
|
|
+#
|
|
|
+# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
+#
|
|
|
+# Unless required by applicable law or agreed to in writing, software
|
|
|
+# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
+# See the License for the specific language governing permissions and
|
|
|
+# limitations under the License.
|
|
|
+---
|
|
|
+
|
|
|
+- name: Install mailx and postfix
|
|
|
+ package:
|
|
|
+ name: "{{ mail_packages }}"
|
|
|
+ state: present
|
|
|
+
|
|
|
+- name: Start postfix service
|
|
|
+ systemd:
|
|
|
+ name: postfix
|
|
|
+ state: started
|
|
|
+
|
|
|
+- block:
|
|
|
+ - name: Install python3
|
|
|
+ package:
|
|
|
+ name: python3
|
|
|
+ state: present
|
|
|
+
|
|
|
+ - name: Update pip version
|
|
|
+ command: pip3 install --upgrade pip
|
|
|
+ changed_when: true
|
|
|
+
|
|
|
+ - name: Install ansible
|
|
|
+ pip:
|
|
|
+ name: ansible
|
|
|
+ state: present
|
|
|
+ executable: pip3
|
|
|
+ when: os_leap in ansible_distribution | lower
|
|
|
+
|
|
|
+- block:
|
|
|
+ - name: Install ansible
|
|
|
+ package:
|
|
|
+ name: ansible
|
|
|
+ state: present
|
|
|
+ when: os_leap not in ansible_distribution | lower
|
|
|
+
|
|
|
+- name: Install community.general collection
|
|
|
+ command: ansible-galaxy collection install {{ community_general_collection }}
|
|
|
+ changed_when: true
|
|
|
+
|
|
|
+- name: Copy auth_failure_check.yml to login_node
|
|
|
+ copy:
|
|
|
+ src: "{{ role_path }}/files/auth_failure_check.yml"
|
|
|
+ dest: "/root/auth_failure_check.yml"
|
|
|
+
|
|
|
+- name: Fetch ansible-playbook path
|
|
|
+ command: whereis ansible-playbook
|
|
|
+ changed_when: false
|
|
|
+ register: ansible_playbook_path
|
|
|
+
|
|
|
+- name: Schedule cron job for alerting
|
|
|
+ cron:
|
|
|
+ name: Auth failure alerting
|
|
|
+ special_time: hourly
|
|
|
+ job: "{{ ansible_playbook_path.stdout.split(' ')[1] }} /root/auth_failure_check.yml -e 'alert_email_address={{ alert_email_address }}'"
|