#jinja2: lstrip_blocks: True {% set keys = [item.value.ssh_key] %} {% if item.value.additional_ssh_keys is defined %} {% for key in item.value.additional_ssh_keys %} {% if inventory_hostname in key.hosts or 'all' in key.hosts %} {{- keys.append(key.name) -}} {% endif %} {% endfor %} {% endif %} {% for key in keys %} {% if unix_users_ssh_options is defined %} {{ lookup('file', 'pubkeys/' + key) | regex_replace('(.*\S.*)', unix_users_ssh_options + ' \\1') }} {% else %} {{ lookup('file', 'pubkeys/' + key) }} {% endif %} {% endfor %}