# Re: Custom name for a template’s temporary file name?

**URL:** <https://forum.ansible.com/t/re-custom-name-for-a-template-s-temporary-file-name/45405>\
**Category:** Get Help\
**Tags:** validate, template, systemd\
**Created:** [February 25, 2026, 3:38pm UTC](https://forum.ansible.com/t/re-custom-name-for-a-template-s-temporary-file-name/45405 "2026-02-25T15:38:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [February 25, 2026, 3:38pm UTC](https://forum.ansible.com/t/re-custom-name-for-a-template-s-temporary-file-name/45405/1 "2026-02-25T15:38:42Z")

</div>

While doing maintenance on some roles/playbooks, I came across several template tasks that create systemd service unit files.  
A few years ago I had a question about how to validate those: [Custom name for a template's temporary file name?](https://forum.ansible.com/t/custom-name-for-a-templates-temporary-file-name/35422)

What I wanted was impossible, so I created an issue for it in the [systemd github repo](https://github.com/systemd/systemd/issues/20061).

That eventually got fixed in [`systemd` version 250](https://github.com/systemd/systemd/releases/tag/v250):

> `systemd-analyze verify` gained support for verifying unit files under an explicitly specified unit name, independently of what the filename actually is.

I just returned to this and can confirm it now does what I wanted back in 2021.  
The `validate` parameter would look like this:

```yaml
- name: Ensure systemd service unit is available for the foobar service
  become: true
  ansible.builtin.template:
    src: foobar.service.j2
    dest: /etc/systemd/system/foobar.service
    owner: root
    group: root
    mode: "0644"
    validate: systemd-analyze verify %s:foobar.service

```
