# Ansible.builtin.file with a loop

**URL:** <https://forum.ansible.com/t/ansible-builtin-file-with-a-loop/4849>\
**Category:** Get Help\
**Created:** [April 9, 2024, 7:20pm UTC](https://forum.ansible.com/t/ansible-builtin-file-with-a-loop/4849 "2024-04-09T19:20:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarkHaney](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@MarkHaney](https://forum.ansible.com/u/MarkHaney)\
**Post date:** [April 9, 2024, 7:20pm UTC](https://forum.ansible.com/t/ansible-builtin-file-with-a-loop/4849/1 "2024-04-09T19:20:20Z")

</div>

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”  
ansible.builtin.file:  
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:

```
  ansible.builtin.file
    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)

---

<div class="post-metadata">

**Author:** ![jpmens](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jpmens/32/5543_2.png) [@jpmens](https://forum.ansible.com/u/jpmens)\
**Post date:** [April 9, 2024, 7:39pm UTC](https://forum.ansible.com/t/ansible-builtin-file-with-a-loop/4849/2 "2024-04-09T19:39:01Z")

</div>

> [@MarkHaney](#):
>
> ```auto
> - name: "Remove expired temp ..."
> ansible.builtin.file:
> path: /etc/sudoers.d/
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![MarkHaney](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@MarkHaney](https://forum.ansible.com/u/MarkHaney)\
**Post date:** [April 9, 2024, 7:55pm UTC](https://forum.ansible.com/t/ansible-builtin-file-with-a-loop/4849/3 "2024-04-09T19:55:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Denney-tech](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/denney-tech/32/1556_2.png) [@Denney-tech](https://forum.ansible.com/u/Denney-tech)\
**Post date:** [April 9, 2024, 7:57pm UTC](https://forum.ansible.com/t/ansible-builtin-file-with-a-loop/4849/4 "2024-04-09T19:57:01Z")

</div>

> [@MarkHaney](#):
>
> ‘/home/METNET/mhaney/enforce\_sudo.v4.yml’: line 29, column 13,

More approximately: line 28, column ~20

`ansible.builtin.file` is missing the colon.

---

<div class="post-metadata">

**Author:** ![jpmens](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jpmens/32/5543_2.png) [@jpmens](https://forum.ansible.com/u/jpmens)\
**Post date:** [April 9, 2024, 8:12pm UTC](https://forum.ansible.com/t/ansible-builtin-file-with-a-loop/4849/5 "2024-04-09T20:12:23Z")

</div>

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