looks like you have missed " delegate_to: localhost" in first task.
On Thu, Mar 4, 2021 at 4:47 AM 'Chris Bidwell - NOAA Federal' via Ansible Project <[email protected]> wrote: > Hi all, > > So I'm trying to write to a local file from my ansible server based off > information I've gotten from my inventory hosts. For some reason, it keeps > creating the file ON the inventory host instead of my ansible server. Here > is my playbook: > > --- > - hosts: ALL_LINUX > become: yes > vars_files: > - vars.yml > > vars: > - SVR: "rhel.svr" > - WKSTN: "rhel.wkstn" > > tasks: > - name: Make sure files exist > file: > path: "{{ item }}" > state: touch > with_items: > - "{{ SVR }}" > - "{{ WKSTN }}" > > - name: Zero out files > shell: cat /dev/null > "{{ item }}" > with_items: > - "{{ SVR }}" > - "{{ WKSTN }}" > delegate_to: localhost > > - name: Workstation or Server? > shell: cat /etc/redhat-release | awk '{print $5}' > register: rh_type > tags: name > > - name: "Find rhel servers" > lineinfile: > dest: "{{ SVR }}" > line: "{{ inventory_hostname }}" > create: yes > insertafter: EOF > delegate_to: localhost > when: rh_type.stdout == "Server" > with_items: "{{ ansible_play_hosts }}" > > - name: "Find rhel workstations" > lineinfile: > dest: "{{ WKSTN }}" > line: "{{ inventory_hostname }}" > create: yes > insertafter: EOF > delegate_to: localhost > when: rh_type.stdout == "Workstation" > with_items: "{{ ansible_play_hosts }}" > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/CAHKi8CgrQ9KZoT1ViiPBuAr7UrwuUQ54DZc%3DDSnbZq3-Q7M%2B4Q%40mail.gmail.com > <https://groups.google.com/d/msgid/ansible-project/CAHKi8CgrQ9KZoT1ViiPBuAr7UrwuUQ54DZc%3DDSnbZq3-Q7M%2B4Q%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- Thanks, Pushparaj G -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAE5Yv1TUBOZA7DqUMD38mD9HVFeQ1xW1Yrx4ONJx%3DMKyaR5ZTA%40mail.gmail.com.
