--- - name: Deploy custom motd template: src: "{{ item }}" dest: /etc/motd force: True owner: root group: root mode: "0644" loop: "{{ query('first_found', templates, errors='ignore') }}" vars: templates: - "motd/motd.{{ inventory_hostname }}.j2" - "motd/motd.{{ host_group }}.j2" - "motd/motd.default.j2" tags: - motd