robertdebock / ansible-role-rsyslog

Install and configure rsyslog on your system.
https://robertdebock.nl/
Apache License 2.0
36 stars 40 forks source link

Update bool assertions #17

Closed sgriffith3 closed 3 years ago

sgriffith3 commented 3 years ago

name: Update bool assertions about: Update assertions to use type_debug to test variable is bool


Describe the change Hi there! I started running into an issue where I was receiving this failure:

FAILED! => {"msg": "The conditional check 'rsyslog_deploy_default_config is boolean' failed. The error was: template error while templating string: no test named 'boolean'. String: {% if rsyslog_deploy_default_config is boolean %} True {% else %} False {% endif %}"}

After some digging and testing, I have not been able to find any documentation to contradict the error saying that there is no conditional check of is boolean for Jinja2 or Ansible.

So I found the following syntax to check for whether a variable is of the type "bool" or not:

| type_debug == "bool"

This change simply replaces two instances of is boolean with | type_debug == "bool" in the assert.yml file.

Testing I tested this change in an existing playbook I had:

- name: configure hosts
  hosts: <remote_host>
  roles:
  - role: rsyslog
    become: True
    vars:
      rsyslog_remote: <remote_logserver>

Using the ansible version:

ansible 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/ubuntu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
robertdebock commented 3 years ago

Hi,

Thanks for the issue and pull request.

I've recently switched to the format that's used now.

It boils down to upgrading jinja, comes with ansible. See requirements.txt for details.

Closing the PR, it's a strategic choise to use the is boolean filter. Thanks anyway for the help!