Have you included *become_method: sudo* ? On Wednesday, 10 March 2021 at 04:58:09 UTC+5:30 Chris Bidwell wrote:
> Thanks for the update, however, it looks like it's not using the sudoer > I'm wanting it to use. I have become: yes up top which I would think would > run as the sudoer user I'm intending. > > If I'm trying to run this playbook in my homedir which is where all my > others are initiated from and added become: yes and knowing that the sudoer > user is listed in my ansible.cfg file, it doesn't seem to be running as > that. > > > > On Wednesday, March 3, 2021 at 10:38:29 PM UTC-7 rajthecomputerguy wrote: > >> 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/b97f3dab-27b2-4411-831d-f4ce6e7da867n%40googlegroups.com.
