$ cat test.yml 
---
- hosts: localhost

  tasks:
    - name: Write ip4 adrees in a file
      ansible.builtin.lineinfile:
        line: "My ip4 is: {{ ansible_enp5s0.ipv4.address }}"
        dest: /tmp/test/toto.txt
        create: true
        
$ ansible-playbook test.yml 

PLAY [localhost] ***********************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *****************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [Write ip4 adrees in a file] ******************************************************************************************************************************************************************************************
changed: [localhost]

PLAY RECAP *****************************************************************************************************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0


$ cat /tmp/test/toto.txt 
My ip4 is: 192.168.0.4