File creation in ansible

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 and delegate_to: localhost the same (assume that 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?