Files
semaphore/all.yml
2023-09-23 18:49:05 +02:00

77 lines
1.9 KiB
YAML

---
- name: Main playbook for common services
hosts: all
become: true
# #
# # @author Stéphane Gratias (2023).
# #
pre_tasks:
- name: >-
Show target servers -> Hostname : OS - IP
debug:
msg: "{{ ansible_hostname }} : {{ ansible_distribution }} {{ ansible_distribution_version }} - {{ ansible_default_ipv4.address }}"
tags:
- always
- test
- name: Ensure specified repository packages are into sources list
ansible.builtin.apt_repository:
repo: "{{ item }}"
state: present
loop: "{{ apt_repositories_sources }}"
tags:
- repo
roles:
- { role: grog.management-user, tags: user }
- { role: willshersystems.sshd, tags: ssh }
- { role: claranet.apt, tags: apt }
- { role: robertdebock.fail2ban, tags: ban }
- { role: nickhammond.logrotate, tags: log,
vars: { "{{ logrotate_files }}" }
}
tasks:
- name: Ensure scripts directory exist
file:
path: /usr/local/scripts/
state: directory
owner: root
group: root
mode: 0755
tags:
- alerts
- name: create the main alertings bash script file
template:
src: "../templates/alerts.sh.j2"
dest: "/usr/local/scripts/alerts.sh"
owner: root
group: root
mode: 0744
tags:
- alerts
- name: Creates a cron file for alerts under /etc/cron.d
ansible.builtin.cron:
name: "{{ item.name }}"
weekday: "{{ item.weekday }}"
minute: "{{ item.minute }}"
hour: "{{ item.hour }}"
user: "{{ item.user }}"
job: "{{ item.job }}"
cron_file: "{{ item.cron_file }}"
loop: "{{ alerts_cron }}"
# - name: Show ssh backup
# debug:
# msg: "{{ ssh_backup }}"
# tags:
# - always
# - test