robertdebock / ansible-role-fail2ban

Install and configure fail2ban on your system.
https://robertdebock.nl/
Apache License 2.0
59 stars 29 forks source link

Check mode don't work #8

Closed yodatak closed 3 years ago

yodatak commented 4 years ago

Hi when i use my playbook to install your role thje check mode failed on this task , it could be cool to make it work in check mode to be sure to what changes will be made

TASK [robertdebock.fail2ban : test if fail2ban_jail_configuration is set correctly] *** fatal: [192.168.1.X]: FAILED! => {}

MSG:

The conditional check 'item.value | length > 0' failed. The error was: Unexpected templating type error occurred on ({% if item.value | length > 0 %} True {% else %} False {% endif %}): object of type 'bool' has no len()

robertdebock commented 4 years ago

Hi, that's unexpected, you are seeing tasks/assert.yml fail because something in the fail2ban_jail_configuration is set to yes or no. I don't see how that relates to check_mode, it should also fail in regular mode.

I can reproduce this issue using this fail2ban_jail_configuration:

fail2ban_jail_configuration:
  - option: ignoreself
    value: true
    section: DEFAULT

In the example above the value true should be quoted to prevent Ansible from making a boolean out of it. This would work:

fail2ban_jail_configuration:
  - option: ignoreself
    value: "true"
    section: DEFAULT

If you continue to struggle, can you show me the variables you're feeding this role so I can analyse further?

Regards,

Robert de Bock.

robertdebock commented 3 years ago

I think this is related to a Jinja filter boolean, which is somewhat new. Please update Jinja.