# Generating the xfs /etc/projects file

**URL:** <https://forum.ansible.com/t/generating-the-xfs-etc-projects-file/7630>\
**Category:** Get Help\
**Created:** [August 5, 2024, 9:34am UTC](https://forum.ansible.com/t/generating-the-xfs-etc-projects-file/7630 "2024-08-05T09:34:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hyperman](https://avatars.discourse-cdn.com/v4/letter/h/8e7dd6/32.png) [@hyperman](https://forum.ansible.com/u/hyperman)\
**Post date:** [August 5, 2024, 9:34am UTC](https://forum.ansible.com/t/generating-the-xfs-etc-projects-file/7630/1 "2024-08-05T09:34:43Z")

</div>

I want to apply xfs projects in a server-specific way and need to setup the xfs /etc/projects file before I can use the community.general.xfs\_quota module.

I have on each server an xfs mountpoint with a folder structure like this:

/mountpoint/projects/$PROJECTNAME/crashdumps

I want to create 1 shared XFS quota for all these folders with e.g. id 1000.

With a shell script this is easy enough:

```auto
pushd /;
for x in /mountpoint/projects/*/crashdumps; do
 echo 1000:$x;
done|sort > /etc/projects ;
popd

```

But can I do this with ansible, in a way that the task is only marked changed when the /etc/projects file is actually changed?

To be clear: Ansible should look at the existing folder structure. I prefer not to maintain a per server /etc/projects file or list of folders.

---

<div class="post-metadata">

**Author:** ![hyperman](https://avatars.discourse-cdn.com/v4/letter/h/8e7dd6/32.png) [@hyperman](https://forum.ansible.com/u/hyperman)\
**Post date:** [August 5, 2024, 11:27am UTC](https://forum.ansible.com/t/generating-the-xfs-etc-projects-file/7630/2 "2024-08-05T11:27:10Z")

</div>

I found a solution. I can run the script inside an ansible shell task with changed\_when: false, and dump the generated file in a variable. Then a copy with content:“{{variable}}” will either d nothing or modify the file and mark the script as changed.

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [August 5, 2024, 9:12pm UTC](https://forum.ansible.com/t/generating-the-xfs-etc-projects-file/7630/3 "2024-08-05T21:12:25Z")

</div>

You might consider taking the md5sum of the file at the start of the script, and again at the end. If they differ, then emit a unique testable string. Register the result, and mark the shell task `changed_when:` that string exists in your registered stdout.
