12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- ---
- - 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: "{{ alerting_file_path }}"
- mode: "{{ hosts_file_mode }}"
- - 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] }} {{ alerting_file_path }} -e 'alert_email_address={{ hostvars['127.0.0.1']['alert_email_address'] }}'"
|