-
Notifications
You must be signed in to change notification settings - Fork 182
Description
First error is in the _common role:
TASK [prometheus.prometheus._common : Allow port in SELinux] ***************************************
[ERROR]: Task failed: Conditional result (False) was derived from value of type 'NoneType' at '<unknown>'. Conditionals must have a boolean result.
Task failed.
Origin: /home/nibz/.ansible/collections/ansible_collections/prometheus/prometheus/roles/_common/tasks/selinux.yml:44:3
42 - "{{ ansible_parent_role_names | first | regex_replace(ansible_collection_name ~ '.', '') }}_configure"
43
44 - name: Allow port in SELinux
^ column 3
<<< caused by >>>
Conditional result (False) was derived from value of type 'NoneType' at '<unknown>'. Conditionals must have a boolean result.
Origin: /home/nibz/.ansible/collections/ansible_collections/prometheus/prometheus/roles/_common/tasks/selinux.yml:54:7
52 - ansible_version.full is version_compare('2.4', '>=')
53 - ansible_selinux.status == "enabled"
54 - (_common_selinux_port)
^ column 7
Broken conditionals can be temporarily allowed with the `ALLOW_BROKEN_CONDITIONALS` configuration option.
fatal: [hetzner-ansible]: FAILED! => {"changed": false, "msg": "Task failed: Conditional result (False) was derived from value of type 'NoneType' at '<unknown>'. Conditionals must have a boolean result."}
This can be resolved by modifying the following line accordingly:
ansible/roles/_common/tasks/selinux.yml
Line 54 in c7a8953
| - (_common_selinux_port) |
- (_common_selinux_port | length > 0)
Using an unmodified prometheus.prometheus.node_exporter role and the modified prometheus.prometheus._common role as above, I'm running into the following error:
TASK [prometheus.prometheus._common : Allow port in SELinux] ***************************************
[ERROR]: Task failed: Module failed: argument 'ports' is of type NoneType and we were unable to convert to list: <class 'NoneType'> cannot be converted to a list
Origin: /home/nibz/.ansible/collections/ansible_collections/prometheus/prometheus/roles/_common/tasks/selinux.yml:44:3
42 - "{{ ansible_parent_role_names | first | regex_replace(ansible_collection_name ~ '.', '') }}_configure"
43
44 - name: Allow port in SELinux
^ column 3
fatal: [hetzner-ansible]: FAILED! => {"changed": false, "msg": "argument 'ports' is of type NoneType and we were unable to convert to list: <class 'NoneType'> cannot be converted to a list"}
I have a single host, and my playbook is incredibly simple:
---
- name: Host Setup
hosts: myhost
roles:
- prometheus.prometheus.node_exporter
The error points to a failure to get the "port", which looks to be set on this line:
| _common_selinux_port: "{{ node_exporter_web_listen_address | urlsplit('port') }}" |
I initially tried changing the variable to http://0.0.0.0:9100, which did resolve the issue, but caused trouble with the service starting on the host. I have found that this change resolves the issue:
_common_selinux_port: "{{ node_exporter_web_listen_address | split(':') | last }}"
This is the full output of running the above playbook against the host. Since I had run it several times already, not everything is shown as changed: output.txt
A quick test of another exporter role (systemd_exporter) shows the same errors, which are resolved in the same fashion.
My current Ansible:
$ ansible --version
ansible [core 2.19.2]
config file = None
configured module search path = ['/home/nibz/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.13/site-packages/ansible
ansible collection location = /home/nibz/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.13.7 (main, Aug 15 2025, 12:34:02) [GCC 15.2.1 20250813] (/usr/bin/python)
jinja version = 3.1.6
pyyaml version = 6.0.2 (with libyaml v0.2.5)
Would like guidance on if this is a required fix, and if so if my above changes are sufficient; or if I'm missing something. Thanks!