Ansible.builtin.file with a loop

I’ve been fighting this for 3 days now. I’m a very rusty Ansible coder (been almost 6 years since I last did any) and I don’t know what’s wrong with this code:

  • name: “Remove Expired Temp Sudo Files”
    path: “{{ etc/sudoers.d }}”
    name: “{{ item }}”
    state: absent
    loop: “{{ expired }}”

The syntax checker only tells me this:
not find expected ‘:’

The error appears to be in ‘/home/METNET/mhaney/enforce_sudo.v4.yml’: line 29, column 13, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

    path: /etc/sudoers.d/
        ^ here

Any ideas?

  • Set at least one tag (the experts follow the tags, so the right people will find you if you tag)

There’s a colon missing behind the module name. I’ve added it here.


Which module was missing the colon? I don’t see it on my local copy nor on the code I posted.

More approximately: line 28, column ~20

ansible.builtin.file is missing the colon.

In the code you posted there is only one module: ansible.builtin.file is an Ansible module.