Search keyword in "host_fqdn" variable. If the value has "lab.com" keyword in it, it should directly store the value to "host_fqdn" again or else it should add "lab.com" keyword to the value and store it to "host_fqdn" variable.
vars:
host_fqdn: server
host_fqdn: |
{% if 'lab.com' in {{ host_fqdn }} %}
{% host_fqdn = "{{ host_fqdn }}" %}
{% else %}
{% host_fqdn = "{{ host_fqdn }}.lab.com" %}
{% endif %}