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

Time:08-24

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.

CodePudding user response:

The service module – Manage services is just

a proxy for multiple more specific service manager modules (such as ansible.builtin.systemd and ansible.builtin.sysvinit).

and

Controls services on remote hosts. Supported init systems include BSD init, OpenRC, SysV, Solaris SMF, systemd, upstart.

According the source code ansible/modules/service.py the error message

get_service_tools not implemented on target platform

shouldn't happen for systems with systemd, but in example for launchd. See Ansible Issue #10412 "Ansible OSX get_service_tools not implemented on target platform".

So you could try with systemd module – Manage systemd units and if fail2ban has a fail2ban.service file implemented correctly.

CodePudding user response:

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.

  • Related