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?