# File creation in ansible

**URL:** <https://forum.ansible.com/t/file-creation-in-ansible/35811>\
**Category:** Ansible Developer\
**Tags:** windows, rhel\
**Created:** [October 1, 2021, 4:31am UTC](https://forum.ansible.com/t/file-creation-in-ansible/35811 "2021-10-01T04:31:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leon\_Tan](https://avatars.discourse-cdn.com/v4/letter/l/71e660/32.png) [@Leon\_Tan](https://forum.ansible.com/u/Leon_Tan)\
**Post date:** [October 1, 2021, 4:31am UTC](https://forum.ansible.com/t/file-creation-in-ansible/35811/1 "2021-10-01T04:31:16Z")

</div>

I have 2 playbooks, one is for RHEL and another is for windows. The purpose for this is to get some info and write to a CSV file on ansible server.

The RHEL playbook runs as expected but not the windows playbook

RHEL playbook

- name: Create directory for reports  
file:  
path: “{{ report\_directory }}”  
state: directory  
delegate\_to: 1.1.1.1  
run\_once: true
- name: Generate report  
template:  
src: “./files/generate\_csv.j2”  
dest: “{{ report\_directory }}/RHELUser.csv”  
delegate\_to: 1.1.1.1

windows playbook

- name: Create directory for reports  
file:  
path: “{{ report\_directory }}”  
state: directory

# become\_method: enable

delegate\_to: 1.1.1.1  
run\_once: true

# mode: ‘0755’

- name: Generate report  
template:  
src: “./files/testing.j2”  
dest: “{{ report\_directory }}/sql.csv”

# become\_method: enable

delegate\_to: 1.1.1.1

The redhat playbook writes to the correct folder but the windows playbook does not.

Is delegate\_to: [1.1.1.1](https://1.1.1.1/) and delegate\_to: localhost the same (assume that [1.1.1.1](https://1.1.1.1/) is the tower’s IP) ?

and why when I am running the same folder the windows playbook will writer to some other location?
