i have a variable (domain_name) located on external YML file,
I wish to run a task in case the variable is empty. From some reason, it is always skipping no matter if i have a value or not
External Yaml
domain_name:
ldap_server_hostname: 10.168.233.77 # Ip can be used as well
ldap_port: 389
i have a variable (domain_name) located on external YML file,
I wish to run a task in case the variable is empty. From some reason, it is always skipping no matter if i have a
value or not
You are doing a string test on an undefined variable, try (untested):
when using domain_name|default(“”)|length > 0 and the paramter is empry i’m geeting the follwoing error message. When the parameter include value it is working
fatal: [10.164.237.140]: FAILED! => {“msg”: “The conditional check ‘domain_name | default("") | length > 0’ failed. The error was: Unexpected templating type error occurred on ({% if domain_name | default("") | length > 0 %} True {% else %} False {% endif %}): object of type ‘NoneType’ has no len()\n\nThe error appears to be in ‘/data/ansible/new2_keycloak/create-realm-secert.yml’: line 13, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Copy realm no LDAP Support\n ^ here\n”}