It seems this is working. Is this the correct use of delegate_to?
- lineinfile:
line: "{{ item }}"
path: "{{ logfile }}"
create: yes
delegate_to: 127.0.0.1
with_items:
- "Serial Number: {{ ansible_product_version }}"
On Monday, March 4, 2019 at 6:44:44 PM UTC-8, Ryan wrote:
>
> I have a playbook that uses the following:
> - set_fact: logfile=/home/sandbox/playbooks/LOGS/{{ systemSN }}
>
> Lower in the playbook I have:
>
> - lineinfile:
> line: "{{ item }}"
> path: "{{ logfile }}"
> create: yes
> with_items:
> - "Serial Number: {{ ansible_product_version }}"
>
>
> When I run the playbook on Server 1 which has Ansible 2.3.1.0 I get the
> file created on the local server I am running Ansible from. This is what I
> want. When I run this same playbook on a different server ("Server 2" on a
> different network) with Ansible 2.7.8, the file is created on the remote
> system, which I do not want. Why is the behavior not consistent, and how
> do I specify that I want the file to be created on the local server I am
> running Ansible from, not on the remote systems?
>
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/c5a86494-001d-4e82-9ef2-30495e3ec608%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.