How can I log inventory_hostname to a file on the remote using a Playbook?

needed to use this (changed to copy as suggested by @Michael Hampton):

---
- hosts: all
  tasks:
   - name: "Create custom fact directory"
     file:
         path: "/etc/ansible/facts.d"
         state: "directory"

   - name: "Insert custom fact file"
     copy:
         content: "#!/bin/bash\necho {\\\"ansible_LAN_hostname\\\" : \\\"{{ inventory_hostname }}\\\"}"
         dest: /etc/ansible/facts.d/lan_hostname.fact
         owner: root
         group: sysadmin
         mode: 0775