# file does not do what it should - inside a role

**URL:** <https://forum.ansible.com/t/file-does-not-do-what-it-should-inside-a-role/36842>\
**Category:** Ansible Project\
**Created:** [July 13, 2022, 1:08pm UTC](https://forum.ansible.com/t/file-does-not-do-what-it-should-inside-a-role/36842 "2022-07-13T13:08:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [July 13, 2022, 1:08pm UTC](https://forum.ansible.com/t/file-does-not-do-what-it-should-inside-a-role/36842/1 "2022-07-13T13:08:24Z")

</div>

I have a **./roles/pgBackRest\_install/tasks/main.yml** aiming to install pgBackRest.

the entire roles goes through without any problem but these 2 TASKS are practially not havin any effect on the target.  
neiter **/etc/pgbackrest/pgbackrest.conf** , nor **/var/lib/pgbackrest** are being created (eventhough the playbook execution reports “ok” \*the 1st one) and “changed” (the 2nd).

- name: install preps - create config files  
file:  
state: touch # sudo touch /etc/pgbackrest/pgbackrest.conf  
path: " {{ item }} "  
owner: pgbackrest # sudo chown pgbackrest:pgbackrest /etc/pgbackrest/pgbackrest.conf  
group: pgbackrest  
mode: ‘0640’ # sudo chmod 640 /etc/pgbackrest/pgbackrest.conf  
become: true  
loop:

- /etc/pgbackrest/pgbackrest.conf # ERROR: not being created !!!

- name: repository - Create the pgBackRest repository  
file:  
state: directory  
path: " {{ item }} "  
mode: ‘0755’ # sudo chmod 750 /var/lib/pgbackrest  
owner: pgbackrest # sudo chown pgbackrest:pgbackrest /var/lib/pgbackrest  
group: pgbackrest  
become: true  
loop:

- /var/lib/pgbackrest # sudo mkdir -p /var/lib/pgbackrest # ERROR: not being created !!!

any idea, what might be going wrong here? Other **file** TASKS work as expected in that same role.

---

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [July 14, 2022, 7:11am UTC](https://forum.ansible.com/t/file-does-not-do-what-it-should-inside-a-role/36842/2 "2022-07-14T07:11:26Z")

</div>

sorry, I just noted the indentation got messed up. The TASKS in question look as follows:

---

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [July 14, 2022, 8:22am UTC](https://forum.ansible.com/t/file-does-not-do-what-it-should-inside-a-role/36842/3 "2022-07-14T08:22:51Z")

</div>

like so often :-), the problem went away by running the playbook several times now.

Sorry for the false alarm

---

<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:** [July 14, 2022, 3:18pm UTC](https://forum.ansible.com/t/file-does-not-do-what-it-should-inside-a-role/36842/4 "2022-07-14T15:18:14Z")

</div>

You have  
path: " {{ item }} "  
where you probably want  
path: “{{ item }}”  
i.e. without the leading and trailing spaces.
