Search code examples
ubuntuansiblesystemdfail2ban

Ansible: How to ensure that the fail2ban service is enabled on the remote server?


This is my task.

- name: Ensure fail2ban is running and enabled.
  ansible.builtin.service:
   name: fail2ban
   state: started
   enabled: true

I am getting this error.

'fatal: [localhost]: FAILED! => {"changed": false, "msg": "get_service_tools not implemented on target platform"}'

Need help!!

Thanks for your time.


Solution

  • I am getting this error because I was trying to execute on my local which is Mac OS.

        when: ansible_facts['os_family'] == "Debian"
    

    I have used this condition so that it will only execute when the target platform is of Debian.