mirror of
https://github.com/ChristianLempa/boilerplates.git
synced 2025-01-25 07:40:37 +01:00
746aa1d06a
Ensure that the `hosts` definition is always defined, defaulting to an empty set. Due to the lack of an Ansible inventory file this is most likely meant to be set as an Ansible extra variable [1]. We also rename the variable named `hosts` to `my_hosts` because `hosts` is a reserved name in Ansible. Reserved names in Ansible are for example all class variable names of plays, roles, blocks, and tasks [2], and `hosts` for example is used by plays [3]. [1] https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#defining-variables-at-runtime [2] https://github.com/ansible/ansible/blob/v2.16.4/lib/ansible/vars/reserved.py#L39 [3] https://github.com/ansible/ansible/blob/v2.16.4/lib/ansible/playbook/play.py#L58
20 lines
513 B
YAML
20 lines
513 B
YAML
---
|
|
- name: install fail2ban and configure sshd
|
|
hosts: "{{ my_hosts | d([]) }}"
|
|
become: yes
|
|
tasks:
|
|
- name: install fail2ban
|
|
ansible.builtin.apt:
|
|
name:
|
|
- fail2ban
|
|
update_cache: yes
|
|
- name: copy fail2ban configfiles
|
|
ansible.builtin.copy:
|
|
src: configfiles/debian-sshd-default.conf
|
|
dest: /etc/fail2ban/jail.d/debian-sshd-default.conf
|
|
- name: restart fail2ban
|
|
ansible.builtin.systemd_service:
|
|
state: restarted
|
|
daemon_reload: yes
|
|
name: fail2ban
|