File creation in ansible

10 views
Skip to first unread message

Leon Tan

unread,
Oct 1, 2021, 12:31:16 AM10/1/21
to Ansible Development

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?

Reply all
Reply to author
Forward
0 new messages